View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:33 am



Reply to topic  [ 4 posts ] 
 Interval Empty 
Author Message
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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?


Last edited by Coops on Wed Apr 16, 2014 5:08 am, edited 2 times in total.



Wed Apr 16, 2014 5:01 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Wed Apr 16, 2014 5:07 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Interval Empty
Nothing yet.

Ill try increasing the number maybe.


Wed Apr 16, 2014 5:10 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Interval Empty
I solved it.

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


Wed Apr 16, 2014 5:38 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.050s | 15 Queries | GZIP : Off ]