Lua TutorialLua DocumentationStart with those to improve your Lua. As for your script, you need to check a key, then create a new actor with the old actor's position and velocity, then remove the old actor.
Something like this:
Code:
function Update(self)
if self:IsPlayerControlled() and UInputMan:KeyPressed(key) then
local new = CreateAHuman("youractor");
new.Pos.x = self.Pos.x;
new.Pos.y = self.Pos.y;
new.Vel = self.Vel;
self.ToDelete = true;
end
end
That is utterly untested and most likely will not work. Consider it a base to work from.
Also,
a list of keystrokes with their corresponding numbers. by Darlos.
Edit:Forgot to actually add the actor to the scene and set the team. I was also setting the position incorrectly.
Code:
function Update(self)
if self:IsPlayerControlled() and UInputMan:KeyPressed(key) then
local new = CreateAHuman("youractor");
new.Pos = self.Pos;
new.Vel = self.Vel;
new.Team = self.Team;
MovableMan:AddActor(new);
self.ToDelete = true;
end
end