init.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 not minetest.is_creative_enabled or not minetest.has_feature({
  16. direct_velocity_on_players = true,
  17. use_texture_alpha_string_modes = true,
  18. }) then
  19. error("\nThis version of Minetest Game is incompatible with your engine version "..
  20. "(which is too old). You should download a version of Minetest Game that "..
  21. "matches the installed engine version.\n")
  22. end
  23. -- GUI related stuff
  24. minetest.register_on_joinplayer(function(player)
  25. -- Set formspec prepend
  26. local formspec = [[
  27. bgcolor[#080808BB;true]
  28. listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]]
  29. local name = player:get_player_name()
  30. local info = minetest.get_player_information(name)
  31. if info.formspec_version > 1 then
  32. formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]"
  33. else
  34. formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]"
  35. end
  36. player:set_formspec_prepend(formspec)
  37. -- Set hotbar textures
  38. player:hud_set_hotbar_image("gui_hotbar.png")
  39. player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
  40. end)
  41. function default.get_hotbar_bg(x,y)
  42. local out = ""
  43. for i=0,7,1 do
  44. out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
  45. end
  46. return out
  47. end
  48. default.gui_survival_form = "size[8,8.5]"..
  49. "list[current_player;main;0,4.25;8,1;]"..
  50. "list[current_player;main;0,5.5;8,3;8]"..
  51. "list[current_player;craft;1.75,0.5;3,3;]"..
  52. "list[current_player;craftpreview;5.75,1.5;1,1;]"..
  53. "image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
  54. "listring[current_player;main]"..
  55. "listring[current_player;craft]"..
  56. default.get_hotbar_bg(0,4.25)
  57. -- Load files
  58. local default_path = minetest.get_modpath("default")
  59. dofile(default_path.."/functions.lua")
  60. dofile(default_path.."/trees.lua")
  61. dofile(default_path.."/nodes.lua")
  62. dofile(default_path.."/chests.lua")
  63. dofile(default_path.."/furnace.lua")
  64. dofile(default_path.."/torch.lua")
  65. dofile(default_path.."/tools.lua")
  66. dofile(default_path.."/item_entity.lua")
  67. dofile(default_path.."/craftitems.lua")
  68. dofile(default_path.."/crafting.lua")
  69. dofile(default_path.."/mapgen.lua")
  70. dofile(default_path.."/aliases.lua")
  71. dofile(default_path.."/legacy.lua")