local openedBoxFlag = "opened_pandoras_box"
local cutsceneTileGlitcherFlag = "opening_pandoras_box_glitcher"

function onBegin()
    disableMovement()

    setFlag(openedBoxFlag, true)

    local level = getLevel()
    local box = getFirstEntity("Mod.PandorasBox.PandorasBox")

    say("SpringCollab2020Cruor_opening_pandoras_box_1")

    walkTo(level.Bounds.Left + 176)
    jump(0.8)
    walkTo(box.Position.X - 8)

    say("SpringCollab2020Cruor_opening_pandoras_box_2")

    wait(5 / 60)
    setFlag(cutsceneTileGlitcherFlag, true)

    celeste.Glitch.Value = 0.6

    wait(0.2)
end

function onEnd()
    setFlag(openedBoxFlag, true)
    setFlag(cutsceneTileGlitcherFlag, true)

    celeste.Glitch.Value = 0.0

    teleportTo(56, 112, "cruor_02")
end