My code freezes SMBX
Posted: Thu Dec 24, 2020 9:12 am
Hello, I was recently trying to write some lua and managed to get some stuff working. I made it so that once the player hits a goomba the player dies but I also made it so that if a red Goomba is killed they hide the barrier layer. For reference, here is my code:
The strange thing is that the moment I kill the red Goomba the layer hides but immediately the game freezes. If somebody would be able to help out I would greatly appreciate it.
Code: Select all
local GOOMBA_ID = 1
local REDGOOMBA_ID = 2
local flag = false
function onStart()
end
function onTick()
Text.print(flag, 100, 100)
end
function onNPCHarm(eventToken, harmedNPC, killReason, culpritOrNil)
if harmedNPC.id == GOOMBA_ID and killReason == HARM_TYPE_JUMP then
player:kill()
else if harmedNPC.id == GOOMBA_ID and killReason == HARM_TYPE_SPINJUMP then
player:kill()
else if harmedNPC.id == REDGOOMBA_ID and killReason == HARM_TYPE_JUMP then
flag = true
end
end
end
end
function onEvent(eventName)
if eventName == "barrier" then
if flag == true then
triggerEvent("barrier")
end
end
end