API.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. hud.register(name, def)
  2. -- name: statbar name (health, air, hunger, armor already used by default)
  3. -- def: <HUD item definition> (see below)
  4. hud.change_item(player, name, def)
  5. -- player: player object
  6. -- name: statbar name
  7. -- def: table containing new values
  8. -- currently supported: number, text and offset
  9. hud.swap_statbar(player, name1, name2) -- swaps position and offset of statbar with name1 with statbar with name2
  10. -- player: player object
  11. -- name1: statbar name
  12. -- name2: statbar name
  13. hud.remove_item(player, name)
  14. HUD item definition
  15. {
  16. hud_elem_type = "statbar", -- currently only supported type (same as in lua-api.txt)
  17. position = {x=<x>, y=<y>}, -- position of statbar (same as in lua-api.txt)
  18. size = {x=24, y=24}, -- statbar texture size (default 24x24), needed to be scaled correctly
  19. text = "hud_heart_fg.png", -- texture name (same as in lua-api.txt)
  20. number = 20, -- number/2 = number of full textures(e.g. hearts)
  21. max = 20, -- used to prevent "overflow" of statbars
  22. alignment = {x=-1,y=-1}, -- alignment on screen (same as in lua-api.txt)
  23. offset = HUD_HEALTH_OFFSET,
  24. background = "hud_heart_bg.png", -- statbar background texture name
  25. autohide_bg = false, -- hide statbar background textures when number = 0
  26. events = { -- called on events "damage" and "breath_changed" of players
  27. {
  28. type = "damage",
  29. func = function(player)
  30. -- do something here
  31. end
  32. }
  33. },
  34. }