|  | 
	| FAQ
		 • Search • Login | 
	| 
 
 
 
	
	
		
			|   | Page 1 of 1 
 | [ 5 posts ] |  |   Emitting only one particle instead of many 
        
        
            | Author | Message |  
			| Djinn 
					Joined: Sun Oct 29, 2006 4:26 am
 Posts: 298
   |   Emitting only one particle instead of manyBack again with another question! This time I have something releasing seeds when it gets to a certain frame, which works as expected, except because of the way I did it the entire time it's on that frame it sprays them all over. I put an if statement there which constrains the seed creation appropriately - however, since the seeds create other instances of this, the variables seem to carry across to all of them. So one plant creates four seeds, but only one of the creates more seeds. While that's probably not bad balance-wise, that's not what I'm looking for. Is there a better way to make this emit only one than an if statement? For statements don't seem to work either. Code: function Create(self)self.minframe = 0;
 self.maxframe = 0;
 self.growthframe = 0;
 self.counter = 0;
 self.lifetimer = Timer();
 stop = 0;
 
 end
 
 function Update(self)
 if self.Frame == 7 and stop == 0 then
 local seed = CreateMOSRotating("Missile Seedpod","Xenobiology.rte")
 seed.Pos = self.Pos + Vector(0,-20);
 seed.Vel = Vector(0 + math.random(-8,8),-40);
 seed.RotAngle = 0;
 MovableMan:AddParticle(seed)
 stop = 1
 end
 
 if self.Frame >= 10 then
 self.ToSettle = true;
 end
 end
 
 |  
			| Thu Sep 13, 2012 2:44 pm | 
					
					     |  
		|  |  
			| Coops 
					Joined: Wed Feb 17, 2010 12:07 am
 Posts: 1545
 Location: That small peaceful place called Hell.
   |   Re: Emitting only one particle instead of manyWhat do you mean for statements don't work? Something like this doesn't do it? Code:    if self.Frame == 7 and stop == 0 thenfor i = 1, 4 do
 local seed = CreateMOSRotating("Missile Seedpod","Xenobiology.rte")
 seed.Pos = self.Pos + Vector(0,-20);
 seed.Vel = Vector(0 + math.random(-8,8),-40);
 seed.RotAngle = 0;
 MovableMan:AddParticle(seed)
 end
 stop = 1
 end
 
 |  
			| Thu Sep 13, 2012 4:35 pm | 
					
					   |  
		|  |  
			| Shook 
					Joined: Fri Feb 16, 2007 8:43 pm
 Posts: 1695
 Location: AH SHIT FUCK AUGH
   |   Re: Emitting only one particle instead of manyHypothesis 1: SEMICOLONS (they're missing after some lines, don't know if it's critical)
 Hypothesis 2: self. that stop variable up. As in, set it to "self.stop" instead of just "stop", since the latter can be called by any and every object in the scene. This might be what's hindering the other plants, since they see that "stop = 1", and thus do not spawn any additional seed pods.
 
 
 |  
			| Thu Sep 13, 2012 5:20 pm | 
					
					     |  
		|  |  
			| Djinn 
					Joined: Sun Oct 29, 2006 4:26 am
 Posts: 298
   |   Re: Emitting only one particle instead of manyShook wrote: 
 Hypothesis 2: self. that stop variable up. As in, set it to "self.stop" instead of just "stop", since the latter can be called by any and every object in the scene. This might be what's hindering the other plants, since they see that "stop = 1", and thus do not spawn any additional seed pods.
....Yeeeeep. Forgot to put a self. there. I'm super embarassed, but hey, it works now! Thanks    .
 
 |  
			| Thu Sep 13, 2012 9:49 pm | 
					
					     |  
		|  |  
			| Bad Boy 
					Joined: Fri Sep 10, 2010 1:48 am
 Posts: 666
 Location: Halifax, Canada
   |   Re: Emitting only one particle instead of manyShook wrote: Hypothesis 1: SEMICOLONS (they're missing after some lines, don't know if it's critical)I gather that for lua the semicolons are unnecessary, they're just a matter of form or whatever. Glad you got this sorted out Djinn.
 
 |  
			| Fri Sep 14, 2012 4:50 am | 
					
					   |  
		|  |  
		|  |  
	
		
			|   | 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
 
 |  
   |