So I'm trying to do a check if the player is mounted or not in an OnEvent function. If the player has a mount, trigger "Event A", and if they are not, trigger "Event B". But all the information I could find on how to detect mounts seems to be outdated (I think I've gotten event triggering via lunalua right). Char.itemSlot seems not to apply anymore, so I've been trying to detect all the NPCs in the section so I can play it if there's any mount NPC present, but I'm not quite sure how to do that either.
I've already tried to look this up- examples of npc.get in use, mount detection, etc- but I can't search "npc.get" since "npc" and "get" are too common, and trying to find anything related to mounts just brought me back to Char.itemSlot.
I thought maybe the player class would have something relating to mounts, but it seems it doesn't, unless the wiki is incomplete.
Edit: Nevermind, I found it. "player.mount" is a variable, it's just not documented... <.>
For those like me who want to make a 'dismount Yoshi' cutscene, here's what I put in my luna.lua:
Code: Select all
function onStart()
if player.section == 0 then
triggerEvent("Castle Cutscene 1")
end
end
function onEvent(eventname, x)
if (eventname == "Castle Cutscene Yoshicheck") then
if player.mount ~= 0 then
triggerEvent("Castle Cutscene 4 Yoshi")
else
triggerEvent("Castle Cutscene 4 Noyoshi")
end
end
end
Added in 4 hours 46 minutes 31 seconds:
Now I have a new problem: Triggering an event on load does not appear to work correctly for input locking- if a button is held during loading, the player can move before the event triggers and locks input.
This is different from autostart event, which will successfully lock input.
The reason why I only want it to trigger on section 0 is because that's the entry cutscene- but it shouldn't happen when respawning at a checkpoint, for example.
onStart is supposed to run on the very first frame the level is loaded, but you get several frames of input here before it seems to kick in. Why is this?
Edit: Figured it out again. I'm not sure why this is happening, but you need to manually lock input until an event involving movement first occurs.
FOR SOME REASON, setting lockInput to true with onStart here does work to prevent input, but the event itself is delayed when triggered the same way.
So I manually restrict inputs until Castle Cutscene 2 begins, which is when it starts holding right.
This is still very odd, though. Why does Castle Cutscene 1 laze around for a few frames before starting? Freeloader.
Code: Select all
local lockInput = false
function onStart()
if player.section == 0 then
triggerEvent("Castle Cutscene 1")
lockInput = true
end
end
function onInputUpdate()
if lockInput == true then
player.upKeyPressing = false;
player.leftKeyPressing = false;
player.rightKeyPressing = false;
player.downKeyPressing = false;
player.jumpKeyPressing = false;
player.altJumpKeyPressing = false;
player.runKeyPressing = false;
player.altRunKeyPressing = false;
player.dropItemKeyPressing = false;
player.pauseKeyPressing = false;
end
end
function onEvent(eventname, x)
if (eventname == "Castle Cutscene 2") then
lockInput = false
end
if (eventname == "Castle Cutscene Yoshicheck") then
if player.mount ~= 0 then
triggerEvent("Castle Cutscene 3 Yoshi")
else
triggerEvent("Castle Cutscene 3 Noyoshi")
end
end
if (eventname == "bossroomenter Check") then
if player.character == 1 then
triggerEvent("bossmsg Mario")
else
triggerEvent("bossmsg Luigi")
end
end
end