-
Notifications
You must be signed in to change notification settings - Fork 10
Scoreboard Extension Reference
grasmann edited this page Apr 8, 2019
·
6 revisions
The purpose of scoreboard extension is to allow mods to add their own custom entries into the scoreboard.
local scoreboard_extension = get_mod("scoreboard_extension")id : string : must be unique among all mods
text : string : display text for the scoreboard
type : string : "highest"/"lowest"/nil
callback : function : function(peer_id, local_player_id, stats_id, entry_id) end
local result = scoreboard_extension:register_entry(id, text, type, callback)Returns true if the entry was created
id : text : must be unique among all mods
enabled : boolean : True / False
scoreboard_extension:set_entry(id, enabled)mod.get_jumps = function(peer_id, local_player_id, stats_id, entry_id)
return mod.my_values[peer_id][entry_id]
end
mod.create_scores = function(self)
local scoreboard_extension = get_mod("scoreboard_extension")
if scoreboard_extension then
local created = scoreboard_extension:register_entry(
"jumpmod_times_jumped", "Times Jumped", "highest", mod.get_jumps)
-- scoreboard_extension:set_entry("jumpmod_times_jumped", false)
end
end
mod.on_all_mods_loaded = function()
mod:create_scores()
endThere is no need to add this mod as a dependency or care about the load order. Just make sure that all mods are loaded before you register your entries.
You can use the VMF event on_all_mods_loaded for that.
That way you can simply state there is support for the mod.