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? Говорю на русском. Sorry for bad english.
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 community profile | map converters | map images | pDownloader | pAttach | model encrypter
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 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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 Говорю на русском. Sorry for bad english.
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()) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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