bad argument #1 to 'random' (interval is empty)?!?!?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: bad argument #1 to 'random' (interval is empty)?!?!?

Post by Robin »

miko wrote:If you want to get a random number between -10 and 10 do something like this:

Code: Select all

value=math.random(0,20)-10
or

Code: Select all

value=math.random(-10,10)
Just remember,

Code: Select all

value=math.random(-20)
is the same as

Code: Select all

value=math.random(1,-20)
which gives an error, because there are no numbers >= 1 and <= -20.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests