Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local routine = require("routine")
- local lockedInputs = {}
- local lastInputs = {}
- local inputsLocked = false
- -- Call this function to lock player inputs
- function lockInputs()
- inputsLocked = true
- for k,v in pairs(player.keys) do
- lockedInputs[k] = false
- lastInputs[k] = player.keys[k]
- end
- end
- -- Call this function to unlock player inputs
- function unlockInputs()
- inputsLocked = false
- end
- -- Set up events that, when called in SMBX, start a lua cutscene
- function onEvent(eventName)
- if eventName == "StartCutscene" then
- Routine.run(sampleCutscene) -- Starts the cutscene
- end
- end
- -- Lock inputs if inputs are locked
- function onTick()
- if inputsLocked then
- for k,v in pairs(player.keys) do
- lastInputs[k] = player.keys[k]
- player.keys[k] = lockedInputs[k]
- end
- end
- end
- -- Reset the locked inputs, to prevent some edge case scenarios
- function onTickEnd()
- if inputsLocked then
- for k,v in pairs(player.keys) do
- player.keys[k] = lastInputs[k]
- end
- end
- end
- -- Routine cutscenes are functions that can use the Routine class
- function sampleCutscene()
- lockInputs()
- Text.showMessageBox("Hey, CHUMP!")
- -- https://docs.codehaus.moe/#/reference/Routine
- Routine.wait(1) -- Wait 1 second
- Routine.waitFrames(20) -- Wait 20/64 of a second
- Routine.skip() -- Wait 1 frame
- -- Force the player to run right
- -- right, left, up, down, run, altRun, jump, altJump, dropItem, pause
- lockedInputs.right = true
- Routine.wait(1)
- lockedInputs.right = false
- Text.showMessageBox("Let's fight!")
- unlockInputs()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement