Hello guys.
after I changed the function to npc:transform, my code doesn't produce an error when I load a level.However, when I try to throw a hammer/boomerang I get an error message saying: "attempt to load global "v" (a nil value) and I have no idea what produces this error so I need your help for a hopefully last time.And here's the code:
Code: Select all
local boomerang = {}
local BoomerangLock = 0
function boomerang.onInitAPI()
registerEvent(boomerang, "onTickEnd", "onTickEnd", false)
end
function boomerang.onTickEnd()
if player.powerup == PLAYER_HAMMER then
if BoomerangLock == 0 then
if(player.runKeyPressing) then
for k,v in pairs(NPC.get({170,266,291},-1)) do
v:transform(292)
if BoomerangLock == 0 then
if player:mem(0x106,FIELD_WORD) ~= -1 then
BoomerangLock = 1
v.x = v.x + 2
v.speedX = 25
v.speedY = -10
else
v.x = v.x - 2
v.speedX = -25
v.speedY = -10
BoomerangLock = 1
end
end
end
end
else
local BoomerangCheck = NPC.get(292,-1)
if table.getn(BoomerangCheck) == 0 then
BoomerangLock = 0
else
player:mem(0x160,FIELD_WORD,2)
end
end
end
end
return boomerang
Greetings, yoshiegg