• Help with math.random
    9 replies, posted
Sup guys, how to make math.random slower? Because it's really fast. I can't create timer because he show me error. Help me please. local random = math.random(1, 80) draw.SimpleText(""..random, "magdaclean", 500, 500, Color (0,150,255,200) )
what timer? you show us a local variable making a random number, and a simple text btw you dont need to do ""..random you can just do random. you tell lua to do no symbol at all, and then random. Instead of that you can just do random..the empty symbol is useless
You need to only create the random variable once if you are in a paint hook you could do something like if not random then random = math.random(1,80) end
Are you trying to have the value update less often? You can do this by creating a local variable outside your draw function, and counting up: local randcounter = 0 local randnumber = math.random(1, 80) function SomeDrawFunction() if randcounter >= 1000 then randcounter = 0 randnumber = math.random(1, 80) else randcounter = randcounter + 1 end draw.SimpleText(""..randnumber, "magdaclean", 500, 500, Color (0,150,255,200) ) end
timer.Simple
and what is the error?? you show us 2 lines of code that have nothing to do with the timer (besides the math.random maybe)
No need to use tostring. Lua handles converting ints to strings.
It's going to timer. But i need like random but slower: 10 going to radom 75 this going to 12 or something
This was done to convert the number into a string. As others have said, Lua has implicit conversion between numbers and strings for the basic operations. "123" .. 45 --> "12345" "123" + 45 --> 168
My mistake, bit rusty on the Lua these days!
Sorry, you need to Log In to post a reply to this thread.