
Here's the Code:
Code: Select all
local cloningdespawn = true
local advent = false
adventimer = 0
function onKeyDown(keycode)
if keycode == KEY_RUN and cloningdespawn == true then
local clonation = NPC.spawn(19,player.x + 0.5 * player.width, player.y + 0.5 * player.height + 8, player.section, false, true)
clonation.speedX = 1 * player.direction
SFX.play(9)
advent = true
end
if cloningdespawn == false and keycode == KEY_RUN then
for _,eso in ipairs(NPC.get(19, player.section)) do
eso:kill(8)
advent = false
end
end
end
function onTick()
if advent == true then
adventimer = adventimer + 1
if adventimer > 2 then
adventimer = 0
cloningdespawn = false
end
else
adventimer = adventimer + 1
if adventimer > 2 then
adventimer = 0
cloningdespawn = true
end
end
end
function onNPCKill(eventObj, killedNPC, killReason)
if killedNPC.id == 19 then
cloningdespawn = true
end
end