Attempt to index local 'actor' failure
Code:
SYSTEM: Activity "Command Center" was successfully started
ERROR: no overload of 'AHuman:AddInventoryItem' matched the arguments (AHuman, nil)
candidates are:
AHuman:AddInventoryItem(MovableObject*)
ERROR: Bedrock.rte/Assault.lua:141: attempt to index local 'actor' (a nil value)
ERROR: Bedrock.rte/Assault.lua:141: attempt to index local 'actor' (a nil value)
ERROR: no overload of 'AHuman:AddInventoryItem' matched the arguments (AHuman, nil)
candidates are:
AHuman:AddInventoryItem(MovableObject*)
That is the error, and this is what I believe to be the relevant code.
Code:
function AssaultMission:MakeActor(whichMode)
local actor;
local which = math.random();
if which > 0.25 then
actor = CreateAHuman("Soldier Light");
else
actor = CreateAHuman("Soldier Heavy");
end
local gun;
which = math.random();
if which > 0.80 then
gun = CreateHDFirearm("Shotgun");
elseif which > 0.50 then
gun = CreateHDFirearm("Assault Rifle");
elseif which > 0.40 then
gun = CreateHDFirearm("Compact Rifle");
elseif which > 0.15 then
gun = CreateHDFirearm("Sniper Rifle");
elseif which > 0.5 then
gun = CreateHDFirearm("Compact Cannon");
else
gun = CreateHDFirearm("Flak Cannon");
end
local tool;
which = math.random();
if which > 0.85 then
tool = CreateHDFirearm("Pulse Digger");
elseif which > 0.75 then
tool = CreateHDFirearm("Grenade Launcher");
elseif which > 0.35 then
tool = CreateTDExplosive("Frag Grenade");
elseif which > 0.30 then
tool = CreateHDFirearm("Concrete Gun");
elseif which > 0.29 then
tool = CreateTDExplosive("Stone");
end
local sidearm;
which = math.random();
if which > 0.70 then
sidearm = CreateHDFirearm("Pistol");
elseif which > 0.50 then
sidearm = CreateHDFirearm("Auto Pistol");
elseif which > 0.40 then
sidearm = CreateHDFirearm("Auto Shot Pistol");
end
actor:AddInventoryItem(gun);
actor:AddInventoryItem(tool);
actor:AddInventoryItem(sidearm);
actor:SetControllerMode(Controller.CIM_AI, -1);
actor.AIMode = whichMode;
return actor;
end
if(defendspawntimer:IsPastSimMS(RespawnTimeDefense)) then
if(basecontrol == 0) then
local ship = CreateACDropShip("Drop Ship MK1");
local actor = self:MakeActor(Actor.AIMODE_GOTO);
ship:AddInventoryItem(actor);
actor = self:MakeActor(Actor.AIMODE_GOTO);
actor:ClearAIWaypoints();
actor:AddAISceneWaypoint(Vector(defensemove:GetRandomPoint().X, defensemove:GetRandomPoint().Y));
ship:AddInventoryItem(actor);
ship.Pos.X = defendlz:GetRandomPoint().X;
ship.Pos.Y = 0;
ship.Team = self.Team_1;
ship:SetControllerMode(Controller.CIM_AI, -1);
MovableMan:AddActor(ship);
defendspawntimer:Reset()
end
end
I don't know why the indent is different for "local actor =" or "ship.Pos.X ="
They are all the same indent.
sorry for the giant block of code, I would've posted less but I don't know where the problem even is!
This code is pretty much all taken from the zombie cave mission and I don't really even have a clue as to how it works, so any help would be appreciated.