builtin.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. HUD_IW_MAX = 8
  2. HUD_IW_TICK = 0.5
  3. HUD_SB_SIZE = {x=16, y=16}
  4. local width = 16*10
  5. local gap = 16*1.5
  6. HUD_HEALTH_POS = {x = 0.5,y = 1}
  7. HUD_HEALTH_OFFSET = {x = -width + -gap, y = -107}
  8. HUD_AIR_POS = {x = 0.5, y = 1}
  9. HUD_AIR_OFFSET = {x = gap, y = -127}
  10. HUD_HUNGER_POS = {x = 0.5, y = 1}
  11. HUD_HUNGER_OFFSET = {x = gap, y = -107}
  12. HUD_ARMOR_POS = {x = 0.5, y = 1}
  13. HUD_ARMOR_OFFSET = {x = -width + -gap, y = -127}
  14. hud.register("health", {
  15. hud_elem_type = "statbar",
  16. position = HUD_HEALTH_POS,
  17. size = HUD_SB_SIZE,
  18. text = "hud_heart_fg.png",
  19. number = 20,
  20. alignment = {x = -1, y = -1},
  21. offset = HUD_HEALTH_OFFSET,
  22. background = "hud_heart_bg.png",
  23. events = {
  24. {
  25. type = "damage",
  26. func = function(player)
  27. local props = pova.get_active_modifier(player, "properties")
  28. hud.change_item(player, "health", {number = player:get_hp(), max = props.hp_max})
  29. end,
  30. },
  31. },
  32. max = 20,
  33. })
  34. hud.register("air", {
  35. hud_elem_type = "statbar",
  36. position = HUD_AIR_POS,
  37. size = HUD_SB_SIZE,
  38. text = "hud_air_fg.png",
  39. number = 0,
  40. alignment = {x = -1, y = -1},
  41. offset = HUD_AIR_OFFSET,
  42. background = "bubble_bg.png",
  43. events = {
  44. {
  45. type = "breath",
  46. func = function(player)
  47. local air = player:get_breath()
  48. local props = pova.get_active_modifier(player, "properties")
  49. hud.change_item(player, "air", {number = air, max = props.breath_max})
  50. end,
  51. },
  52. },
  53. max = 20,
  54. })
  55. hud.register("armor", {
  56. hud_elem_type = "statbar",
  57. position = HUD_ARMOR_POS,
  58. size = HUD_SB_SIZE,
  59. text = "hud_armor_fg.png",
  60. number = 0,
  61. alignment = {x = -1, y = -1},
  62. offset = HUD_ARMOR_OFFSET,
  63. background = "hud_armor_bg.png",
  64. max = 20,
  65. })
  66. hud.register("hunger", {
  67. hud_elem_type = "statbar",
  68. position = HUD_HUNGER_POS,
  69. size = HUD_SB_SIZE,
  70. text = "hud_hunger_fg.png",
  71. number = 0,
  72. alignment = {x = -1, y = -1},
  73. offset = HUD_HUNGER_OFFSET,
  74. background = "hud_hunger_bg.png",
  75. max = 20,
  76. })