View unanswered posts | View active topics It is currently Tue Jul 23, 2019 12:10 am



Reply to topic  [ 6 posts ] 
 math.random error 
Author Message
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 math.random error
Bad argument #1 to "random" (interval is empty)

I thought I had fixed it, but I didn't, but the errors were very random, so I didn't care much, but now it's bugging me seriously.

What produces this error?


Thu Oct 13, 2011 9:36 pm
Profile
Data Realms SUPER Elite
Data Realms SUPER Elite

Joined: Thu Jun 03, 2010 10:06 pm
Posts: 3717
Location: Over there.
Reply with quote
Post Re: math.random error
What are you putting into it?


Thu Oct 13, 2011 10:42 pm
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: math.random error
Code:
   self.LaserMaxDist = SceneMan:CastObstacleRay(self.MuzzlePos, Vector(1600*self.reverseNum,0):RadRotate(self.RotAngle),Vector(),self.LaserPos,self.ID,0,0)
      if self.LaserMaxDist < 0 then
         self.LaserSight = 1600
      else
         self.LaserSight = self.LaserMaxDist
      end


math.random(self.LaserSight) is what I'm using, but I'm using it later.


Thu Oct 13, 2011 10:56 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: math.random error
Make absolutely sure that an actual value is getting passed into math.random. Try printing self.LaserSight and firing the gun a few times. Or, y'know, doing whatever action triggers the script.


Fri Oct 14, 2011 3:49 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: math.random error
I'll try printing it to see what happens.


Fri Oct 14, 2011 7:51 pm
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: math.random error
Fixed it, the error ocurred when I aimed at pointblank and the ray result was 0.
So, I changed the else into
Code:
elseif self.LaserMaxDist >= 0 then
  self.LaserSight = math.max(1, self.LaserMaxDist)

and it worked fine.


Sat Oct 15, 2011 7:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.017s | 13 Queries | GZIP : Off ]