C-4 Lua Help - Temporary detonator
Little intro to what I am trying to do:
There is a sad lack of terminator mods in cortex, and that needs fixing. I am not experienced enough to implement this, but I wanted to see how far I could get making the terminator's prequel foe, the forces of Tech-Com. My thinking was that once I had made the good guys, bad guys would come naturally to me. That has yet to happen.
I am sourcing my mod from the very old (in gamer terms) and very bad (in gamer terms also) PS2 game:
Terminator - Dawn of Fate. The reasoning behind this was that it has an astoundingly simple setup, with very few guns or charachters (and because i'm lazy).
The game does, however, contain some rather
interesting weaponry in the form of canister bombs and it's very own setup of C-4 explosive. I have sorted out, to a reasonable degree, the canister bombs. The C-4, however, is posing a problem.
You see, the C-4 in TDoF works on the principle that a detonator appears out of nowhere every time you place a C-4, and disappears mysteriously when you detonate it. If you have ever played the game then you know what I mean. Not wanting to appear too lazy, I decided to keep to the theme, and try to make it. The only problem is, I am a real noob at Lua, and I would have sorted it myself had the wiki not gone down.
So far, I have resprited my C-4 + detonator, made an .ini for them both and started a couple of Lua files for each. The code so far is as follows:
C-4:Code:
function Create(self)
print("C-4 planted!");
--Make sure the blue C-4 list exists.
if c4List == nil then
--If not, create it.
c4List = { };
end
--Add this C-4 to the list.
c4ListB[#c4List + 1] = self;
--Create detonator in actors hand.
for actor in MovableMan.Actors do
local distcheck = SceneMan:shortestDistance(self.Pos,actor.Pos,true).Magnitude
self.AddInventory = HDFirearm
CopyOf = Detonator
end
end
function Destroy(self)
print("C-4 detonated")
--TODO Destroy detonator
end
DetonatorCode:
function Create(self)
--Make sure the red C-4 list exists.
if c4List ~= nil then
--Go through the list of red C-4.
for i=1,#c4List do
--Make sure the C-4 still exists, it may have been destroyed.
if MovableMan:IsParticle(c4List[i]) then
--Detonate the C-4!
c4List[i]:GibThis();
end
end
end
--Empty/create the red C-4 list.
c4List = { };
end
Any help (really, any at all) would be useful right now, so please respond!
I will include an attachment for my mod if it is required, but to save time I will wait until someone asks. Please do if it will help you.Roast.