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!
了解更多
Artermus 3 2018 年 2 月 7 日 上午 3:45
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
---------------------------------
最后由 Artermus 编辑于; 2018 年 2 月 7 日 上午 3:46
< >
正在显示第 1 - 3 条,共 3 条留言
Artermus 3 2018 年 2 月 7 日 上午 5:13 
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 2018 年 2 月 7 日 下午 7:43 
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.
最后由 greensniperhat 编辑于; 2018 年 2 月 7 日 下午 7:43
Artermus 3 2018 年 2 月 8 日 下午 4:16 
I discovered I caused that error
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50