Cortex Command

Cortex Command

Endless content for every part of the game
Built for modding from the ground up, Cortex Command supports a community of talent whose quality work can be enjoyed here: actors, items, vehicles, scenes, game modes, tech factions - you name it!
Learn More
Artermus 3 7 Feb, 2018 @ 3:45am
Trying to attach a turret to a tank
Be trying to as it say above this is the code, for the life of me I keep getting an error even knowing it's pretty spot on.

----------------------------------
function Create(self)
self.Turret = {}
self.Turret[1] = CreateACrab("Dragoon MG Mount")
MovableMan:AddParticle(self.Turret[1])
self.Turret[1].Team = self.Team
self.Turret[1].Offset = Vector(13,-39)
if self.HFlipped == true then
self.Reverse = -1
elseif self.HFlipped == false then
self.Reverse = 1
end
end

function Update(self)
if self.HFlipped then
self.Reverse = -1
elseif not self.HFlipped then
self.Reverse = 1
end

for i = 1, #self.Turret do
if MovableMan:IsParticle(self.Turret) == true then
self.Turret.Vel.X = 0;
self.Turret.Vel.Y = 0;
self.Turret.RotAngle = self.RotAngle;
self.Turret.Pos = self.Pos + self:RotateOffset(self.Turret.Offset)
end
end
end

function Destroy(self)
for i = 1, #self.Turret do
if MovableMan:IsParticle(self.Turret) == true then
if self.Health < 1 then
self.Turret:GibThis()
else
self.Turret.ToDelete = true
end
end
end
end
---------------------------------
Last edited by Artermus; 7 Feb, 2018 @ 3:46am
< >
Showing 1-3 of 3 comments
Artermus 3 7 Feb, 2018 @ 5:13am 
ERROR: [string "Turrets.Obj00000 = ToTurret(MovableMan.Script..."]:1: attempt to call global 'ToTurret' (a nil value)
-----------
This is the error I'm getting, my lua isn't very good, more of a spriter.
greensniperhat 7 Feb, 2018 @ 7:43pm 
Look into the lua codes of other mods, perhaps? Like UAC. I think what you forgot to put is in the for i = 1 loop. it's supposed to be self.Turret[ i ] instead of just self.Turret.
Last edited by greensniperhat; 7 Feb, 2018 @ 7:43pm
Artermus 3 8 Feb, 2018 @ 4:16pm 
I discovered I caused that error
< >
Showing 1-3 of 3 comments
Per page: 1530 50