Skip to content

Commit

Permalink
highscore event
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Oct 18, 2023
1 parent eca5ef3 commit 212781d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mods/super_sam/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions mods/super_sam_highscore/highscore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 212781d

Please sign in to comment.