init.lua 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. -- Minetest 0.4 mod: default
  2. -- See README.txt for licensing and other information.
  3. -- The API documentation in here was moved into game_api.txt
  4. -- Load support for MT game translation.
  5. local S = minetest.get_translator("default")
  6. -- Definitions made by this mod that other mods can use too
  7. default = {}
  8. default.LIGHT_MAX = 14
  9. default.get_translator = S
  10. -- Check for engine features required by MTG
  11. -- This provides clear error behaviour when MTG is newer than the installed engine
  12. -- and avoids obscure, hard to debug runtime errors.
  13. -- This section should be updated before release and older checks can be dropped
  14. -- when newer ones are introduced.
  15. if ItemStack("").add_wear_by_uses == nil then
  16. error("\nThis version of Minetest Game is incompatible with your engine version "..
  17. "(which is too old). You should download a version of Minetest Game that "..
  18. "matches the installed engine version.\n")
  19. end
  20. -- GUI related stuff
  21. minetest.register_on_joinplayer(function(player)
  22. -- Set formspec prepend
  23. local formspec = [[
  24. bgcolor[#080808BB;true]
  25. listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]]
  26. local name = player:get_player_name()
  27. local info = minetest.get_player_information(name)
  28. if info.formspec_version > 1 then
  29. formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]"
  30. else
  31. formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]"
  32. end
  33. player:set_formspec_prepend(formspec)
  34. -- Set hotbar textures
  35. player:hud_set_hotbar_image("gui_hotbar.png")
  36. player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
  37. end)
  38. function default.get_hotbar_bg(x,y)
  39. local out = ""
  40. for i=0,7,1 do
  41. out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
  42. end
  43. return out
  44. end
  45. default.gui_survival_form = "size[8,8.5]"..
  46. "list[current_player;main;0,4.25;8,1;]"..
  47. "list[current_player;main;0,5.5;8,3;8]"..
  48. "list[current_player;craft;1.75,0.5;3,3;]"..
  49. "list[current_player;craftpreview;5.75,1.5;1,1;]"..
  50. "image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
  51. "listring[current_player;main]"..
  52. "listring[current_player;craft]"..
  53. default.get_hotbar_bg(0,4.25)
  54. -- Load files
  55. local default_path = minetest.get_modpath("default")
  56. dofile(default_path.."/functions.lua")
  57. dofile(default_path.."/trees.lua")
  58. dofile(default_path.."/nodes.lua")
  59. dofile(default_path.."/chests.lua")
  60. dofile(default_path.."/furnace.lua")
  61. dofile(default_path.."/torch.lua")
  62. dofile(default_path.."/tools.lua")
  63. dofile(default_path.."/item_entity.lua")
  64. dofile(default_path.."/craftitems.lua")
  65. dofile(default_path.."/crafting.lua")
  66. dofile(default_path.."/mapgen.lua")
  67. dofile(default_path.."/aliases.lua")
  68. dofile(default_path.."/legacy.lua")
  69. -- Smoke test that is run via ./util/test/run.sh
  70. if minetest.settings:get_bool("minetest_game_smoke_test") then
  71. minetest.after(0, function()
  72. minetest.emerge_area(vector.new(0, 0, 0), vector.new(32, 32, 32))
  73. local pos = vector.new(9, 9, 9)
  74. local function check()
  75. if minetest.get_node(pos).name ~= "ignore" then
  76. minetest.request_shutdown()
  77. return
  78. end
  79. minetest.after(0, check)
  80. end
  81. check()
  82. end)
  83. end