|  | 
	| FAQ
		 • Search • Login | 
	| 
 
 
 
	
			
	
	 Preventing release of cargo on Craft gibbing 
        
        
            | Author | Message |  
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Preventing release of cargo on Craft gibbingOkay. You're trying to:have one object release other objects at a specific time interval with animation, but not release those objects if destroyed
 
 Ini Sample 1: Invisible explosion.
 
 Lua Sample 1 (simple): Delete the parent object if it's going to die.
 
 Lua Sample 2 (simple): Add child objects to the inventory of the parent only when needed, leaving only one object present at a time.
 
 Lua Sample 3 (still simple): Animate and spawn entirely with lua, meaning no objects are inside the parent at any time, no hatch-open dots are present ever, and you've got finely tuned individual delay controls.
 
 I'm not saying that your strategy of avoiding lua as much as possible isn't sound, but there are advantages to quite simple lua scripts that overcome the restrictions of .ini quite handily.
 
 
 |  
			| Mon Feb 15, 2010 8:07 pm | 
					
					   |  
		|  |  
			| Djinn 
					Joined: Sun Oct 29, 2006 4:26 am
 Posts: 298
   |   Re: Preventing release of cargo on Craft gibbingGrif wrote: I'm not saying that your strategy of avoiding lua as much as possible isn't sound, but there are advantages to quite simple lua scripts that overcome the restrictions of .ini quite handily.
Oh, I totally agree, my reticence stems more from the fact that I'm already done except for this part and I'm trying to psych myself out of doing something more sensible but more work.
 
 |  
			| Mon Feb 15, 2010 8:38 pm | 
					
					     |  
		|  |  
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Preventing release of cargo on Craft gibbingfunction Create(self)self.lifetimer = Timer();
 end
 
 function Update(self)
 if self.lifetimer:IsPastSimMS(longest delay) == true then
 self.Frame = last frame;
 self.lifetimer:Reset();
 local child = CreateACRocket("rocket","rte");
 child.Pos = self.Pos;
 child.Vel.X = math.random(-10,10);
 MovableMan:AddActor(child);
 elseif self.lifetimer:IsPastSimMS(lower delay) == true then
 self.Frame = last frame before open;
 elseif self.lifetimer:IsPastSimMS(lower delay) == true then
 self.Frame = one frame less;
 continue this process for however many frames. each delay should be X ms past the previous, preferably a smooth integer for even framing. 50 works well for moderate animation rates.
 else
 self.Frame = 0;
 end
 end
 
 Notes: this won't have any 'wind down' effect, but I can add one if you need it. what this will do, filled out properly, is just increment frames based on a timer, until at the end, it spawns a child object and launches it left or right. more complex spawning can be added if necessary (this will probably end up crashing into your parent object)
 once the cycle is complete, it resets the timer and the frames to default states.
 
 Frame numbers are integers demarcated the same way as files are named; you start with Frame = 0 for '000.bmp' and then go up one at a time.
 
 
 |  
			| Mon Feb 15, 2010 9:03 pm | 
					
					   |  
		|  |  
		|  |  
 
	
		| 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
 
 |  
   |