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



Reply to topic  [ 5 posts ] 
 Emitting only one particle instead of many 
Author Message
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post Emitting only one particle instead of many
Back 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
Profile YIM
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Emitting only one particle instead of many
What do you mean for statements don't work?

Something like this doesn't do it?

Code:
   if self.Frame == 7 and stop == 0 then
         for 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
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Emitting only one particle instead of many
Hypothesis 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
Profile WWW
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post Re: Emitting only one particle instead of many
Shook 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
Profile YIM

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Emitting only one particle instead of many
Shook 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 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

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