Data Realms Fan Forums
http://45.55.195.193/

Interval Empty
http://45.55.195.193/viewtopic.php?f=73&t=45629
Page 1 of 1

Author:  Coops [ Wed Apr 16, 2014 5:01 am ]
Post subject:  Interval Empty

Run into a problem regarding math.random

Code:
self.RotAngle = self.RotAngle - math.rad(math.random((a*-200) + 1, (a*200) + 1)/200)


Where a is a number generated between 0 and 6. However if the number generated is 0, I get an error that the second argument of the math.random() is empty.

Error generated is

:bad argument #2 to 'random' (Interval is empty)

so to counteract this I tried adding +1 in both arguments, but alas does nothing to prevent the error.

Maybe I'm completely misinterpreting what the error actually is saying?

Author:  Asklar [ Wed Apr 16, 2014 5:07 am ]
Post subject:  Re: Interval Empty

I'm not sure if it might be this, but when a = 0 you are doing math.random(1,1). Maybe that's causing the problem. Try adding 1 only to the second argument.

Author:  Coops [ Wed Apr 16, 2014 5:10 am ]
Post subject:  Re: Interval Empty

Nothing yet.

Ill try increasing the number maybe.

Author:  Coops [ Wed Apr 16, 2014 5:38 am ]
Post subject:  Re: Interval Empty

I solved it.

Just added an if check to see if the number was over zero.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/