Data Realms Fan Forums http://45.55.195.193/ |
|
Conditional gibs http://45.55.195.193/viewtopic.php?f=73&t=31533 |
Page 1 of 1 |
Author: | Djinn [ Fri Aug 03, 2012 4:20 pm ] |
Post subject: | Conditional gibs |
This is probably covered already, but I was at work and I had a thought - is there a function to add gibs only if a certain condition is met? In this case its if a MOSRotating hits a certain frame, but it could be anything I suppose. Edit To clarify I mean something that adds gibs to the parent rather than cause extra gibs to fly out. I mean like if you blow it up before whatever frame, it gibs x, but if you blow it up after that it gibs x + whatever else. |
Author: | akblabla [ Fri Aug 03, 2012 4:59 pm ] |
Post subject: | Re: Conditional gibs |
Djinn wrote: This is probably covered already, but I was at work and I had a thought - is there a function to add gibs only if a certain condition is met? In this case its if a MOSRotating hits a certain frame, but it could be anything I suppose. Edit To clarify I mean something that adds gibs to the parent rather than cause extra gibs to fly out. I mean like if you blow it up before whatever frame, it gibs x, but if you blow it up after that it gibs x + whatever else. Use lua, Make a function "function Destroy(self)", and generate the gibs with the CreateMOSRotating or whatever you need Code: function Destroy(self) if self.Frame == whateverFrame then local Gib = CreateMOSRotating("Your gib"); Gib.Pos = self.Pos + self:RotateOffset(Vector(X-offset, Y-offset)); Gib.Vel = self.Vel + Vector(math.random(-maxspeed,maxspeed),math.random(-maxspeed,maxspeed)); Gib.RotAngle = self.RotAngle; Gib.AngularVel = self.AngularVel + math.random(-maxAngularVel,maxAngularVel); Gib.HFlipped = self.HFlipped; MovableMan:AddParticle(Gib); end end |
Author: | Djinn [ Fri Aug 03, 2012 5:26 pm ] |
Post subject: | Re: Conditional gibs |
So if I wanted to have multiple different occassions of gibs being added all I would have to do is add some elseif self.frame = x and add them through that. The only other thing I'd have to do is create more local variables for the gibs, correct? |
Author: | akblabla [ Fri Aug 03, 2012 5:34 pm ] |
Post subject: | Re: Conditional gibs |
Djinn wrote: So if I wanted to have multiple different occassions of gibs being added all I would have to do is add some elseif self.frame = x and add them through that. The only other thing I'd have to do is create more local variables for the gibs, correct? Yup Oh and a small thing add this around the script if ((self.Pos.Y > 0 and self.Pos.Y < SceneMan.SceneHeight) or SceneMan.SceneWrapsY) and ((self.Pos.X > 0 and self.Pos.X < SceneMan.SceneWidth) or SceneMan.SceneWrapsX) then end so it looks like this Code: function Destroy(self) if ((self.Pos.Y > 0 and self.Pos.Y < SceneMan.SceneHeight) or SceneMan.SceneWrapsY) and ((self.Pos.X > 0 and self.Pos.X < SceneMan.SceneWidth) or SceneMan.SceneWrapsX) then if self.Frame == whateverFrame then --Repeat for each gib local Gib = CreateMOSRotating("Your gib"); Gib.Pos = self.Pos + self:RotateOffset(Vector(X-offset, Y-offset)); Gib.Vel = self.Vel + Vector(math.random(-maxspeed,maxspeed),math.random(-maxspeed,maxspeed)); Gib.RotAngle = self.RotAngle; Gib.AngularVel = self.AngularVel + math.random(-maxAngularVel,maxAngularVel); Gib.HFlipped = self.HFlipped; MovableMan:AddParticle(Gib); end end end |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |