Author Topic: How can I use Random numbers?  (Read 138 times)

0 Members and 1 Guest are viewing this topic.

Offline Shirakami

How can I use Random numbers?
« on: July 22, 2017, 11:57:10 AM »
Hello. Help me!

I was trying to use a random number in the script, but I could not.

Code: [Select]
local i = rand()
local i = random()
local i = math.rand()
local i = math_rand()

How can I use random numbers in a script?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4233
  • Total likes: 169
  • Helpful: 149
  • Languages: EN, DE, AT
Re: How can I use Random numbers?
« Reply #1 on: July 22, 2017, 02:28:42 PM »
I added the missing functionality in r8272.
Code: [Select]
srand(time()) // initialize random number generator
local bal = rand() // get random number
It uses the functions srand and rand from the standard C libraries.
Parsley, sage, rosemary, and maggikraut.

Offline Shirakami

Re: How can I use Random numbers?
« Reply #2 on: July 22, 2017, 03:17:53 PM »
I added the missing functionality in r8272.

Thank you for your prompt response!  ;D