Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local highscores = {}
- local ac = require("anothercurrency")
- local perLevelCoins = ac.registerCurrency("coinses", true)
- local old = {highscore = 0, highcoins = 0}
- local endtimer = 0
- SaveData.levelData = SaveData.levelData or {}
- SaveData.levelData[Level.filename()] = SaveData.levelData[Level.filename()] or {highscore = 0, highcoins = 0}
- function highscores.onInitAPI()
- registerEvent(highscores,"onStart")
- registerEvent(highscores,"onTick")
- registerEvent(highscores,"onDraw")
- end
- function highscores.onStart()
- Audio.sounds[21].muted = true
- SaveData._basegame.hud.score = 0
- perLevelCoins:setMoney(0)
- old.highscore = SaveData.levelData[Level.filename()].highscore
- old.highcoins = SaveData.levelData[Level.filename()].highcoins
- end
- function highscores.onTick()
- currentCoins = perLevelCoins:getMoney()
- if Level.winState() ~= 0 then
- if endtimer == 0 then
- Audio.MusicChange(player.section,"Golden Stage Clear.spc")
- end
- endtimer = endtimer + 1
- if SaveData._basegame.hud.score > old.highscore then
- SaveData.levelData[Level.filename()].highscore = SaveData._basegame.hud.score
- end
- if currentCoins > old.highcoins then
- SaveData.levelData[Level.filename()].highcoins = currentCoins
- end
- end
- end
- function onDraw()
- if Level.winState() ~= 0 then
- Text.print("Course Clear!",270,200)
- Text.print("Score:",270,240)
- Text.print("Coins:",270,300)
- if endtimer > 64 then
- Text.print(SaveData._basegame.hud.score,390,240)
- if endtimer > 128 then
- Text.print(currentCoins,390,300)
- if endtimer > 192 then
- if SaveData._basegame.hud.score > old.highscore then
- Text.print("New Highscore!",270,260)
- else
- Text.print("Highscore:" .. old.highscore,270,260)
- end
- if currentCoins > old.highcoins then
- Text.print("New Highscore!",270,320)
- else
- Text.print("Highscore:" .. old.highcoins,270,320)
- end
- end
- end
- end
- end
- end
- return highscores
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement