Hugos Posted January 7, 2020 Posted January 7, 2020 I created the function math.random (10, 20), but I get 10 all the time. Help please! How do I always generate different numbers?
Moderators Patrick Posted January 7, 2020 Moderators Posted January 7, 2020 (edited) You're in bad luck dude It has to work. Edited January 7, 2020 by stPatrick
Moderators IIYAMA Posted January 7, 2020 Moderators Posted January 7, 2020 (edited) 20 minutes ago, Hugos said: I created the function math.random (10, 20), but I get 10 all the time. https://docs.coronalabs.com/api/library/math/randomseed.html os.time() can be replaced with getTickCount() Edited January 7, 2020 by IIYAMA
Hugos Posted January 7, 2020 Author Posted January 7, 2020 (edited) 42 minutes ago, IIYAMA said: https://docs.coronalabs.com/api/library/math/randomseed.html os.time() can be replaced with getTickCount() Did not understand a little. Can I see an example of a function that generates a random number in a range? P.S: I use Lua random.match - https://www.gammon.com.au/scripts/doc.php?Lua=math.random (not api) Edited January 7, 2020 by Hugos
Moderators IIYAMA Posted January 7, 2020 Moderators Posted January 7, 2020 1 hour ago, Hugos said: Did not understand a little. Can I see an example of a function that generates a random number in a range? It helps with randomization. And no I wouldn't mention it, if it isn't available in MTA. This is all: Run on top of your script. math.randomseed(getTickCount()) -- or math.randomseed(getTickCount() * getTickCount())
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now