2024-12-04 18:01:28 +01:00
|
|
|
-- Minetest Game mod: default
|
2013-05-18 16:05:16 +02:00
|
|
|
-- See README.txt for licensing and other information.
|
|
|
|
|
2014-12-07 15:17:09 +01:00
|
|
|
-- The API documentation in here was moved into game_api.txt
|
2013-05-18 16:05:16 +02:00
|
|
|
|
2019-09-10 19:09:51 +02:00
|
|
|
-- Load support for MT game translation.
|
|
|
|
local S = minetest.get_translator("default")
|
|
|
|
|
2013-05-18 16:05:16 +02:00
|
|
|
-- Definitions made by this mod that other mods can use too
|
|
|
|
default = {}
|
|
|
|
|
2014-12-07 15:17:09 +01:00
|
|
|
default.LIGHT_MAX = 14
|
2019-09-10 19:09:51 +02:00
|
|
|
default.get_translator = S
|
2014-12-07 15:17:09 +01:00
|
|
|
|
2021-04-27 11:50:32 +02:00
|
|
|
-- Check for engine features required by MTG
|
|
|
|
-- This provides clear error behaviour when MTG is newer than the installed engine
|
|
|
|
-- and avoids obscure, hard to debug runtime errors.
|
|
|
|
-- This section should be updated before release and older checks can be dropped
|
|
|
|
-- when newer ones are introduced.
|
2022-06-13 20:02:08 +02:00
|
|
|
if ItemStack("").add_wear_by_uses == nil then
|
2021-04-27 11:50:32 +02:00
|
|
|
error("\nThis version of Minetest Game is incompatible with your engine version "..
|
|
|
|
"(which is too old). You should download a version of Minetest Game that "..
|
|
|
|
"matches the installed engine version.\n")
|
|
|
|
end
|
|
|
|
|
2014-04-14 22:09:18 +02:00
|
|
|
-- GUI related stuff
|
2018-03-28 19:28:26 +02:00
|
|
|
minetest.register_on_joinplayer(function(player)
|
2019-10-18 03:43:06 +02:00
|
|
|
-- Set formspec prepend
|
2019-10-14 22:53:57 +02:00
|
|
|
local formspec = [[
|
2018-03-28 19:28:26 +02:00
|
|
|
bgcolor[#080808BB;true]
|
2019-10-14 22:53:57 +02:00
|
|
|
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]]
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local info = minetest.get_player_information(name)
|
|
|
|
if info.formspec_version > 1 then
|
|
|
|
formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]"
|
|
|
|
else
|
|
|
|
formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]"
|
|
|
|
end
|
|
|
|
player:set_formspec_prepend(formspec)
|
2019-10-18 03:43:06 +02:00
|
|
|
|
|
|
|
-- Set hotbar textures
|
|
|
|
player:hud_set_hotbar_image("gui_hotbar.png")
|
|
|
|
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
|
2018-03-28 19:28:26 +02:00
|
|
|
end)
|
2014-04-14 22:09:18 +02:00
|
|
|
|
|
|
|
function default.get_hotbar_bg(x,y)
|
|
|
|
local out = ""
|
|
|
|
for i=0,7,1 do
|
|
|
|
out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
|
|
|
|
end
|
|
|
|
return out
|
|
|
|
end
|
|
|
|
|
2014-12-25 00:13:15 +01:00
|
|
|
default.gui_survival_form = "size[8,8.5]"..
|
2014-04-14 22:09:18 +02:00
|
|
|
"list[current_player;main;0,4.25;8,1;]"..
|
|
|
|
"list[current_player;main;0,5.5;8,3;8]"..
|
|
|
|
"list[current_player;craft;1.75,0.5;3,3;]"..
|
|
|
|
"list[current_player;craftpreview;5.75,1.5;1,1;]"..
|
|
|
|
"image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
2015-06-16 17:26:22 +02:00
|
|
|
"listring[current_player;main]"..
|
|
|
|
"listring[current_player;craft]"..
|
2014-04-14 22:09:18 +02:00
|
|
|
default.get_hotbar_bg(0,4.25)
|
|
|
|
|
2013-05-19 18:43:04 +02:00
|
|
|
-- Load files
|
2016-08-28 00:28:02 +02:00
|
|
|
local default_path = minetest.get_modpath("default")
|
|
|
|
|
|
|
|
dofile(default_path.."/functions.lua")
|
|
|
|
dofile(default_path.."/trees.lua")
|
|
|
|
dofile(default_path.."/nodes.lua")
|
2018-07-11 00:02:22 +02:00
|
|
|
dofile(default_path.."/chests.lua")
|
2016-08-28 00:28:02 +02:00
|
|
|
dofile(default_path.."/furnace.lua")
|
2016-10-12 06:05:10 +02:00
|
|
|
dofile(default_path.."/torch.lua")
|
2016-08-28 00:28:02 +02:00
|
|
|
dofile(default_path.."/tools.lua")
|
2016-09-11 17:24:02 +02:00
|
|
|
dofile(default_path.."/item_entity.lua")
|
2016-08-28 00:28:02 +02:00
|
|
|
dofile(default_path.."/craftitems.lua")
|
|
|
|
dofile(default_path.."/crafting.lua")
|
|
|
|
dofile(default_path.."/mapgen.lua")
|
|
|
|
dofile(default_path.."/aliases.lua")
|
|
|
|
dofile(default_path.."/legacy.lua")
|
2024-03-25 20:45:31 +01:00
|
|
|
|
|
|
|
-- Smoke test that is run via ./util/test/run.sh
|
|
|
|
if minetest.settings:get_bool("minetest_game_smoke_test") then
|
|
|
|
minetest.after(0, function()
|
|
|
|
minetest.emerge_area(vector.new(0, 0, 0), vector.new(32, 32, 32))
|
|
|
|
local pos = vector.new(9, 9, 9)
|
|
|
|
local function check()
|
|
|
|
if minetest.get_node(pos).name ~= "ignore" then
|
|
|
|
minetest.request_shutdown()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
minetest.after(0, check)
|
|
|
|
end
|
|
|
|
check()
|
|
|
|
end)
|
|
|
|
end
|