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

--returns the amount of money you have left
function getmoney()
    return save.SaveData:GetMoney()
end

--adds the value [money] to their total
function addmoney(money)
    save.SaveData:AddMoney(tonumber(money))
end

--returns an int that equals their points
function getpoints()
    return save.SaveData:GetPoints();
end

-- Returns if a flag exists, if it does, returns true, if it doesn't returns false
function isflagtrue(flag)
    return save.SaveData:IsFlagTrue(flag)
end

-- Adds a flag with the name inside the function
function addflag(flag)
    save.SaveData:AddFlag(flag)
end

function bettersay(dialog)
    coroutine.yield(bettertext.Say(tostring(dialog)))
end

function onTalk()
	disableMovement ()
	playSound("event:/CC/CC_Lobby/CC_altJingle")
	wait(0.1)
	say("CC_Lobby_ATM")
	bettersay("Points: {#F94A4A}"..tostring(getpoints()).."{#}.{n}Money: {#F94A4A}"..tostring(getmoney()).."G{#}.")
	if not isflagtrue("firstTimeATM") then
		say("CC_Lobby_ATM3")
		playSound("event:/CC/CC_Lobby/CC_money")
		say("CC_Lobby_ATM4")
		addflag("firstTimeATM")
		addmoney(5)
	end
	say("CC_Lobby_ATM2")
end

function onEnd()
	enableMovement()
end