capturetheflag/mods/other/hud_score
ANAND 58db9e7dd0
HUD score improvements (#656)
* Move hud_score mod to 'other' modpack

* hud_score: Reuse element when adding a new element with the same name
2020-09-13 19:17:19 -07:00
..
init.lua HUD score improvements (#656) 2020-09-13 19:17:19 -07:00
mod.conf HUD score improvements (#656) 2020-09-13 19:17:19 -07:00
README.md HUD score improvements (#656) 2020-09-13 19:17:19 -07:00

hud_score

hud_score provides an API to display HUD score elements which can be used to display kill scores, bounty scores, etc.

Methods

  • hud_score.new(name, score_def): Adds a new HUD score element to player name.
    • name [string]: Player name
    • score_def [table]: HUD score element definition. See below.

HUD score element definition

HUD score element definition table, passed to hud_score.new.

Example definition:

{
    name  = "ctf_stats:kill_score", -- Can be any arbitrary string
    color = "0x00FF00",             -- Should be compatible with Minetest's HUD def
    value = 50,                     -- The actual number to be displayed
    -- Field `time` is automatically added by `hud_score.new`
    -- to keep track of element expiry
}

players table

This is a table of tables, indexed by player names. This table holds the HUD data of all online players. Each sub-table is a list of HUD score elements, which are added by hud_score.new.

local players = {
    ["name"] = {
        [1] = <hud_score_element>,
        [2] = <hud_score_element>,
        [3] = <hud_score_element>
        ...
    },
    ["name2"] = {
        ...
    },
    ...
}