local save = require("#Celeste.Mod.CrossoverCollab.Code.PointsStuff.PointsModule")

function onBegin()
wait()

while true do
wait()
if getFlag("RadianceOutroCutscene") then
      makeUnskippable()
      disableRetry()
      setFlag("endingFade", true)
      wait(2)
      setFlag("DreamNoMoreEnding", true)
      playMusic("event:/none")
	  playSound("event:/CC/CC_HollowKnight/SFX/Scene/TrueEndJingle")
      break
    end
  end

  while true do
    wait()
    if (celeste.Input.Jump.Pressed or celeste.Input.DashPressed or celeste.Input.CrouchDashPressed or celeste.Input.MenuConfirm.Pressed) then
      setFlag("LevelComplete", true)
      wait(0.5)
	  addflag("Knight_Alt_heart") -- unlocks extra dream journal page with this LobbyFlag
      wait()

      while true do
        wait() --had to nest it anyways sry dav
        if (celeste.Input.Jump.Pressed or celeste.Input.DashPressed or celeste.Input.CrouchDashPressed or celeste.Input.MenuConfirm.Pressed) then
          setFlag("DNMEndingExit", true)
          break
        end
      end
    end
  end
end

function addflag(flag)
    save.SaveData:AddFlag(flag)
end
