From 212781d371631569f9b47dc77087d943e1473455 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Wed, 18 Oct 2023 11:16:08 +0200 Subject: [PATCH] highscore event --- mods/super_sam/events.lua | 6 ++++++ mods/super_sam_highscore/highscore.lua | 1 + 2 files changed, 7 insertions(+) diff --git a/mods/super_sam/events.lua b/mods/super_sam/events.lua index 6820872..4c88aa2 100644 --- a/mods/super_sam/events.lua +++ b/mods/super_sam/events.lua @@ -2,12 +2,18 @@ -- name -> {fn, fn} local events = {} +-- player state super_sam.EVENT_MODE_CHANGE = "mode_change" -- player, edit|play super_sam.EVENT_TIMEOUT = "timeout" -- player + +-- level events super_sam.EVENT_PLAYER_START = "player_start" -- player, levelname super_sam.EVENT_PLAYER_FINISHED = "player_finished" -- player, levelname, highscore_name, score, rank super_sam.EVENT_PLAYER_ABORTED = "player_aborted" -- player +-- highscore +super_sam.EVENT_UPDATE_HIGHSCORE = "update_highscore" -- levelname, highscore, playername, score + function super_sam.on_event(name, fn) local list = events[name] if not list then diff --git a/mods/super_sam_highscore/highscore.lua b/mods/super_sam_highscore/highscore.lua index 0bcaacd..c6a2fe2 100644 --- a/mods/super_sam_highscore/highscore.lua +++ b/mods/super_sam_highscore/highscore.lua @@ -52,6 +52,7 @@ function super_sam_highscore.update_highscore(playername, score, levelname) table.remove(highscore, #highscore) end + super_sam.emit_event(super_sam.EVENT_UPDATE_HIGHSCORE, levelname, highscore, playername, score) super_sam_highscore.set_level_highscore(levelname, highscore, playername, score) end