Data Realms Fan Forums
http://45.55.195.193/

Recursive Rockets
http://45.55.195.193/viewtopic.php?f=73&t=17807
Page 1 of 1

Author:  Djinn [ Thu Feb 11, 2010 11:58 pm ]
Post subject:  Recursive Rockets

Hey all, been a while, trying to get a hang of this Lua stuff gradually by reverse engineering neat stuff, but I figured I's start with something simple enough.

Essentially, what I'm trying to do is have a Rocket fire out TDExplosives that gib (or explodes after timer, if the engine supports that now) into more of those rockets. That's the core of what I want to do, but I have additional ideas that I'm unsure how to implement: Ideally, each of these TDExplosives should have a semi-random chance of gibbing into the base rocket. Also, if possible, I want to make sure the rockets spawn facing up regardless of the manner their spawning TDE landed, though if there's a strategy for this that works without Lua that would also be nice.

As always, thanks for your help, and I'm very impressed with everything the community has managed to create.

Author:  Grif [ Fri Feb 12, 2010 12:18 am ]
Post subject:  Re: Recursive Rockets

function Create(self)
self.lifetimer = Timer();
end

function Update(self)
if self.lifetimer:IsPastSimMS(5000) == true then
local chance = math.random(1,4)
if chance == 1 then
local acrocket = CreateACRocket("Presetname","RTE")
acrocket.Pos = self.Pos;
acrocket.Vel = Vector(0,0);
acrocket.RotAngle = 0;
MovableMan:AddActor(acrocket)
end
end
end

Script for TDE's that'd cover what you need.

Author:  Djinn [ Fri Feb 12, 2010 1:42 am ]
Post subject:  Re: Recursive Rockets

Thank you once again good sir.

For the reference of others, I inserted a 'self:GibThis();' after 'local chance = math.random(1,1)', because otherwise it made unlimited copies and did crazy ♥♥♥♥. As it stands, the code just makes the one copy after 5000ms. Next I'll try to modify it using altitude so that they won't pop before touching the ground.

Author:  Mind [ Fri Feb 12, 2010 1:53 am ]
Post subject:  Re: Recursive Rockets

Add self.lifetimer:Reset(); after the if chance == 1 line. Pretty sure Grif just accidentally forgot it, cuz with it, it has a 1 in 4 chance of gibbing into "another rocket" like u said. So yea.

Edit: so what else do you want it to do?

Author:  Grif [ Fri Feb 12, 2010 4:33 am ]
Post subject:  Re: Recursive Rockets

there's no need to reset it if it gibs regardless of hitting the chance or not

he wanted 1/4 tde's to explode into an acrocket, and with the modification I told him to make, that's what happens

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/