|  | 
	| FAQ
		 • Search • Login | 
	| 
 
 
 
	
	
		
			|   | Page 1 of 1 
 | [ 5 posts ] |  |  
        
        
            | Author | Message |  
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   math.random errorBad 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 | 
					
					   |  
		|  |  
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   Re: math.random errorCode:    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 | 
					
					   |  
		|  |  
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: math.random errorMake 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 | 
					
					   |  
		|  |  
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   Re: math.random errorI'll try printing it to see what happens. 
 
 |  
			| Fri Oct 14, 2011 7:51 pm | 
					
					   |  
		|  |  
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   Re: math.random errorFixed 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 thenself.LaserSight = math.max(1, self.LaserMaxDist)
and it worked fine.
 
 |  
			| Sat Oct 15, 2011 7:36 pm | 
					
					   |  
		|  |  
		|  |  
	
		
			|   | Page 1 of 1 
 | [ 5 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
 
 |  
 |