#How do you interrupt movement etc. when skipping lua cutscenes?

1 messages · Page 1 of 1 (latest)

cursive tinsel
#

I'm using a lua talker to allow secondary dialog and i have it set up to make the player walk to a position then the dialog plays. If the cutscene is skipped before the player reaches the location, things get a bit wild lol

#
function onTalk()
    player.ForceCameraUpdate = true
    disableMovement()
    walkTo(340)
    setCameraOffset(0.5,0)
    player.Facing = getEnum("Celeste.Facings", "Right")
    if not getFlag("spoken_to") then
        setFlag("spoken_to", true)
        say("DIALOG1")
    else
        say("DIALOG2")
    end
    enableMovement()
end

function onEnd(room, wasSkipped)
    enableMovement()
end
#

here is what i'm using (i've substituted the flags and dialog keys because SSC spoilers lol)

#

essentially if you skip before reaching the walkTo location, the movement is enabled again but the rest of the onTalk function still runs, so the player can move but it will try to move the player to the walkTo location and if they hit it, the dialog plays, all while movement is enabled

#

so is there a way to make it stop everything if they skip during the walkTo part?

cursive tinsel
sweet vortex
#

I think that you can try using walk() instead of walkTo() to see if there is any differences, or make the cutscene unskippable only during the movement

cursive tinsel
#

walk isn't ideal though

#

as the reason it's there is to simulate the approach thing that NPCs have

#

that would only work if the player interacts with them in the right place

cursive tinsel
#
function onTalk()
    player.ForceCameraUpdate = true
    disableMovement()
    setFlag("cutscene_skip_fix", true)
    walkTo(340)
    setFlag("cutscene_skip_fix", false)
    setCameraOffset(0,0)
    player.Facing = getEnum("Celeste.Facings", "Right")
    if not getFlag("spoken_to") then
        setFlag("spoken_to", true)
        say("DIALOG1")
    else
        say("DIALOG2")
    end
    enableMovement()
end

function onEnd(room, wasSkipped)
    if getFlag("cutscene_skip_fix") then
    teleportTo(340,112)
    else
    end
    enableMovement()
end
#

^ updated code based on recommendation but this only deals with the walkTo function continuing

#

the dialog etc. still runs....

azure pond
#

@feral tapir is this just bugged

cursive tinsel
#

before i waste my time trying to figure this out for nothing, do you think this could solve the issue i'm having?

cursive tinsel
#

okay i've set up a basic demo to hopefully show what i'm encountering

#

this is what happens if you skip during the walkTo helper function

#

i'm not moving to the left, it's the function still running, then when you get there, the dialog runs too

#

the enableMovement from onEnd triggers, but the stuff from onTalk still continues

#

this is the exact lua script i'm using for this example:

function onTalk()
    player.ForceCameraUpdate = true
    disableMovement()
    walkTo(1300)
    setCameraOffset(0.5,0)
    player.Facing = getEnum("Celeste.Facings", "Right")
    if not getFlag("spoken_to") then
        setFlag("spoken_to", true)
        say("DIALOG1")
    else
        say("DIALOG2")
    end
    enableMovement()
end

function onEnd(room, wasSkipped)
    enableMovement()
end
regal hatch
#

@cursive tinsel your walkTo() isn't that long, I suggest to disable pause while walking

function onTalk()
    player.ForceCameraUpdate = true
    disableMovement()
    disablePause()
    walkTo(1300)
    enablePause()
    setCameraOffset(0.5,0)
    player.Facing = getEnum("Celeste.Facings", "Right")
    if not getFlag("spoken_to") then
        setFlag("spoken_to", true)
        say("DIALOG1")
    else
        say("DIALOG2")
    end
    enableMovement()
end

function onEnd(room, wasSkipped)
    enableMovement()
end```
cursive tinsel
#

ooooh

#

i'll definitely go with that if i can't get the coroutine thing to work

#

good idea, thanks!

regal hatch
cursive tinsel
#

@undone root do you know what this error means?

#

(11/25/2023 11:35:53) [Everest] [Error] [Lua Cutscenes] Failed to load cutscene in Lua: [string "local lua_helper = celesteMod.LuaCutscenes.Lu..."]:1: attempt to index a nil value (global 'celesteMod')

#
local lua_helper = celesteMod.LuaCutscenes.LuaHelper
local monocle = require("#monocle")

local function makeCoroutine(func)
    return monocle.Coroutine(lua_helper.LuaCoroutineToIEnumerator(coroutine.create(func)))
end

local function approachNPC()
    walkTo(8375)
end

local approachNPCCoroutine

function onTalk()
    disableMovement()
    approachNPCCoroutine = makeCoroutine(approachNPC)
    cutsceneEntity:Add(approachNPCCoroutine)
    player.ForceCameraUpdate = true
    setCameraOffset(0.5,0)
    player.Facing = getEnum("Celeste.Facings", "Right")
    if not getFlag("spoken_to") then
        setFlag("spoken_to", true)
        say("DIALOG1")
    else
        say("DIALOG2")
    end
    enableMovement()
end

function onEnd(room, wasSkipped)
    if approachNPCCoroutine then
        approachNPCCoroutine:Cancel()
        cutsceneEntity:Remove(approachNPCCoroutine)
    end
    enableMovement()
end
#

it's having an issue with the first row but i'm just using what is on the wiki

regal hatch
#

Celeste doesn't seem understand celesteMod (?)
Maybe try below idk

local lua_helper = LuaCutscenes.LuaHelper```
#

or maybe Celeste has a capital C ?

cursive tinsel
#

well i found this

#

#1176649252110336122 message

#

so i've changed it to what they used

#

and it's getting stuck elsewhere now

#

Crash Exception: NLua.Exceptions.LuaScriptException: [string "local lua_helper = require("#Celeste.Mod.LuaC..."]:33: attempt to index a nil value (global 'cutsceneEntity') stack traceback: [string "local lua_helper = require("#Celeste.Mod.LuaC..."]:33: in function <[string "local lua_helper = require("#Celeste.Mod.LuaC..."]:30>

feral tapir
#

cutsceneEntity is for the trigger, not the talker
on talker you want talker

cursive tinsel
#

oooh okay, i'll try that when i get home

#

thank you!

cursive tinsel
#

this was it

#

all works now

#

and the player can skip during the walk animation and nothing breaks!