gui.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. -- Hud alignment
  2. local health_bar_definition =
  3. {
  4. hud_elem_type = "statbar",
  5. position = { x=0.5, y=1 },
  6. text = "heart.png",
  7. number = 20,
  8. direction = 0,
  9. size = {x=16, y=16},
  10. offset = {x=(-9*24)-12, y=-(48+24+8)},
  11. }
  12. core.hud_replace_builtin("health", health_bar_definition)
  13. -- GUI related stuff
  14. default.gui_bg = "bgcolor[#080808BB;true]"
  15. default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]"
  16. default.gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
  17. function default.get_hotbar_bg(x,y)
  18. local out = ""
  19. for i=0,7,1 do
  20. out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
  21. end
  22. return out
  23. end
  24. default.gui_survival_form = "size[8,7.5]"..
  25. -- default.gui_bg..
  26. -- default.gui_bg_img..
  27. -- default.gui_slots..
  28. "list[current_player;main; 0,3.5; 8,1;]"..
  29. "list[current_player;main; 0,4.75; 8,3; 8]"..
  30. "list[current_player;craft; 3,0; 3,3;]"..
  31. "list[current_player;craftpreview; 7,1; 1,1;]"..
  32. -- "image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
  33. "listring[current_player;main]"..
  34. "listring[current_player;craft]"..
  35. default.get_hotbar_bg(0,4.25)
  36. minetest.register_on_joinplayer(function(player)
  37. -- set GUI
  38. if not minetest.settings:get_bool("creative_mode") then
  39. player:set_inventory_formspec(default.gui_survival_form)
  40. end
  41. player:hud_set_hotbar_image("gui_hotbar.png")
  42. player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
  43. end)