View unanswered posts | View active topics It is currently Sun Aug 25, 2019 9:20 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Interval Empty
Author Message

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
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
Data Realms Elite

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
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

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

Ill try increasing the number maybe.

Wed Apr 16, 2014 5:10 am

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: RimsRen

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

Search for:
 Jump to:  Select a forum ------------------ Cortex Command    Dev Log    Wiki    Game Discussion    Game and Licensing Support    Mod Making       Lua Scripting       Requests    Mod Releases       Older Mods    Scene Releases       Scene Making Planetoid Pioneers    Game Discussion    Pioneer Program Lounge Data Realms Off-Topic    Off Topic Chat       Gaming       Forum Games    Site Support & Feedback