From 2f59a0c840e9101c87e2d59fabf34116b3328121 Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Sat, 10 Dec 2016 10:31:17 -0800 Subject: Process ABMs in a spherical volume instead of cubic Increase active_block_range default to a 3 mapblock radius. --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 1818b5a18..3a740f3ca 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -758,7 +758,7 @@ active_object_send_range_blocks (Active object send range) int 3 # How large area of blocks are subject to the active block stuff, stated in mapblocks (16 nodes). # In active blocks objects are loaded and ABMs run. -active_block_range (Active block range) int 2 +active_block_range (Active block range) int 3 # From how far blocks are sent to clients, stated in mapblocks (16 nodes). max_block_send_distance (Max block send distance) int 10 -- cgit v1.2.3 From 094a5a73d3b9817d07c52754749f0828c4005b8c Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 8 Dec 2016 17:37:13 -0800 Subject: Redo light.cpp. Remake the light_decode_table. The table starts out without pre-filled in values since those are always discarded by the code apparently. We calculate a pseudo curve with gamma power function, and then apply a new adjustment table. The adjustment table is setup to make the default gamma of 2.2 look decent: not too dark at light level 3 or so, but too dark at 1 and below to be playable. The curve is much smoother than before and looks reasonable at the whole range, offering a pleasant decay of light levels away from lights. The `display_gamma` setting now actually does something logical: the game is darker at values below 2.2, and brighter at values above 2.2. At 3.0, the game is very bright, but still has a good light scale. At 1.1 or so, the bottom 5 light levels are virtually black, but you can still see enough detail at light levels 7-8, so the range and spread is adequate. I must add that my monitor is somewhat dark to begin with, since I have a `hc` screen that doesn't dynamic range colors or try to pull up `black` pixels for me (it is tuned for accurate color and light levels), so this should look even better on more dynamic display tunings. --- builtin/settingtypes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 3a740f3ca..8668e1472 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -442,9 +442,9 @@ fov (Field of view) int 72 30 160 # This requires the "zoom" privilege on the server. zoom_fov (Field of view for zoom) int 15 15 160 -# Adjust the gamma encoding for the light tables. Lower numbers are brighter. +# Adjust the gamma encoding for the light tables. Higher numbers are brighter. # This setting is for the client only and is ignored by the server. -display_gamma (Gamma) float 1.8 1.0 3.0 +display_gamma (Gamma) float 2.2 1.0 3.0 # Path to texture directory. All textures are first searched from here. texture_path (Texture path) path -- cgit v1.2.3 From a1346c916e1d0f0cde2ccecc680857896c717a3d Mon Sep 17 00:00:00 2001 From: Dorian Wouters Date: Sat, 31 Dec 2016 18:12:26 +0100 Subject: Fix /grant & /revoke not working with custom auth handler (#4974) core.auth_table is not supposed to be accessed directly. --- builtin/game/chatcommands.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 2bd93855b..71edeb26a 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -162,7 +162,7 @@ local function handle_grant_command(caller, grantname, grantprivstr) return false, "Your privileges are insufficient." end - if not core.auth_table[grantname] then + if not core.get_auth_handler().get_auth(grantname) then return false, "Player " .. grantname .. " does not exist." end local grantprivs = core.string_to_privs(grantprivstr) @@ -232,7 +232,7 @@ core.register_chatcommand("revoke", { local revoke_name, revoke_priv_str = string.match(param, "([^ ]+) (.+)") if not revoke_name or not revoke_priv_str then return false, "Invalid parameters (see /help revoke)" - elseif not core.auth_table[revoke_name] then + elseif not core.get_auth_handler().get_auth(revoke_name) then return false, "Player " .. revoke_name .. " does not exist." end local revoke_privs = core.string_to_privs(revoke_priv_str) -- cgit v1.2.3 From e8b7179ccd5b1f70eba3f9ac570c5f10474cf7a7 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 28 Dec 2016 13:01:32 +0000 Subject: Expose and document chatcommands as minetest.registered_chatcommands --- builtin/game/chatcommands.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 71edeb26a..eb6edc1c8 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -4,14 +4,15 @@ -- Chat command handler -- -core.chatcommands = {} +core.registered_chatcommands = {} +core.chatcommands = core.registered_chatcommands -- BACKWARDS COMPATIBILITY function core.register_chatcommand(cmd, def) def = def or {} def.params = def.params or "" def.description = def.description or "" def.privs = def.privs or {} def.mod_origin = core.get_current_modname() or "??" - core.chatcommands[cmd] = def + core.registered_chatcommands[cmd] = def end core.register_on_chat_message(function(name, message) @@ -19,7 +20,7 @@ core.register_on_chat_message(function(name, message) if not param then param = "" end - local cmd_def = core.chatcommands[cmd] + local cmd_def = core.registered_chatcommands[cmd] if not cmd_def then return false end @@ -107,7 +108,7 @@ core.register_chatcommand("help", { if param == "" then local msg = "" local cmds = {} - for cmd, def in pairs(core.chatcommands) do + for cmd, def in pairs(core.registered_chatcommands) do if core.check_player_privs(name, def.privs) then cmds[#cmds + 1] = cmd end @@ -118,7 +119,7 @@ core.register_chatcommand("help", { .. " or '/help all' to list everything." elseif param == "all" then local cmds = {} - for cmd, def in pairs(core.chatcommands) do + for cmd, def in pairs(core.registered_chatcommands) do if core.check_player_privs(name, def.privs) then cmds[#cmds + 1] = format_help_line(cmd, def) end @@ -134,7 +135,7 @@ core.register_chatcommand("help", { return true, "Available privileges:\n"..table.concat(privs, "\n") else local cmd = param - local def = core.chatcommands[cmd] + local def = core.registered_chatcommands[cmd] if not def then return false, "Command not available: "..cmd else @@ -161,7 +162,7 @@ local function handle_grant_command(caller, grantname, grantprivstr) if not (caller_privs.privs or caller_privs.basic_privs) then return false, "Your privileges are insufficient." end - + if not core.get_auth_handler().get_auth(grantname) then return false, "Player " .. grantname .. " does not exist." end @@ -204,7 +205,7 @@ core.register_chatcommand("grant", { local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)") if not grantname or not grantprivstr then return false, "Invalid parameters (see /help grant)" - end + end return handle_grant_command(name, grantname, grantprivstr) end, }) @@ -215,7 +216,7 @@ core.register_chatcommand("grantme", { func = function(name, param) if param == "" then return false, "Invalid parameters (see /help grantme)" - end + end return handle_grant_command(name, name, param) end, }) -- cgit v1.2.3 From 8f9611bcb20f4eca69abb204bf5dc28f62fab4a2 Mon Sep 17 00:00:00 2001 From: Ezhh Date: Sat, 7 Jan 2017 11:33:38 +0000 Subject: Make column alignment consistent in advanced settings (#5004) --- builtin/mainmenu/dlg_settings_advanced.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index b0d923768..85218c852 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -544,7 +544,7 @@ end local function create_settings_formspec(tabview, name, tabdata) local formspec = "size[12,6.5;true]" .. - "tablecolumns[color;tree;text;text]" .. + "tablecolumns[color;tree;text,width=32;text]" .. "tableoptions[background=#00000000;border=false]" .. "table[0,0;12,5.5;list_settings;" -- cgit v1.2.3 From 73fdb635974cb11521d80f15261b97d6fac53cd0 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 9 Jan 2017 16:39:40 +0100 Subject: builtin/.../falling.lua: Avoid crash when hitting unknown nodes --- builtin/game/falling.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 4696ce481..39a74008c 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -83,7 +83,7 @@ core.register_entity(":__builtin:falling_node", { -- it's drops if n2.name ~= "air" and (not nd or nd.liquidtype == "none") then core.remove_node(np) - if nd.buildable_to == false then + if nd and nd.buildable_to == false then -- Add dropped items local drops = core.get_node_drops(n2.name, "") for _, dropped_item in pairs(drops) do -- cgit v1.2.3 From ec30d49e026af2d0cb8329eb66aec48d12e79839 Mon Sep 17 00:00:00 2001 From: Rui Date: Tue, 10 Jan 2017 04:39:45 +0900 Subject: Add staticdata parameter to add_entity (#5009) * Add staticdata parameter to add_entity * Add add_entity_with_staticdata to core.features --- builtin/game/features.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/game/features.lua b/builtin/game/features.lua index 2aad458da..646b254ea 100644 --- a/builtin/game/features.lua +++ b/builtin/game/features.lua @@ -9,6 +9,7 @@ core.features = { no_legacy_abms = true, texture_names_parens = true, area_store_custom_ids = true, + add_entity_with_staticdata = true, } function core.has_feature(arg) -- cgit v1.2.3 From 7ae7f1ea4cbbda7d7849a1240ce30d867e850bfb Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sun, 9 Oct 2016 14:36:22 -0400 Subject: Enable mod security by default --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 8668e1472..779224be4 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -1186,7 +1186,7 @@ mgvalleys_np_inter_valley_slope (Valley Slope) noise_params 0.5, 0.5, (128, 128, [*Security] # Prevent mods from doing insecure things like running shell commands. -secure.enable_security (Enable mod security) bool false +secure.enable_security (Enable mod security) bool true # Comma-separated list of trusted mods that are allowed to access insecure # functions even when mod security is on (via request_insecure_environment()). -- cgit v1.2.3 From bb154c2e1cf185f181c3e85df9addb79e6d18b4c Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Thu, 15 Oct 2015 13:05:33 -0400 Subject: Main menu tweaks --- builtin/init.lua | 7 +++---- builtin/mainmenu/dlg_settings_advanced.lua | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'builtin') diff --git a/builtin/init.lua b/builtin/init.lua index 4400a19d6..b34ad14a0 100644 --- a/builtin/init.lua +++ b/builtin/init.lua @@ -37,9 +37,9 @@ dofile(commonpath .. "misc_helpers.lua") if INIT == "game" then dofile(gamepath .. "init.lua") elseif INIT == "mainmenu" then - local mainmenuscript = core.setting_get("main_menu_script") - if mainmenuscript ~= nil and mainmenuscript ~= "" then - dofile(mainmenuscript) + local mm_script = core.setting_get("main_menu_script") + if mm_script and mm_script ~= "" then + dofile(mm_script) else dofile(core.get_mainmenu_path() .. DIR_DELIM .. "init.lua") end @@ -48,4 +48,3 @@ elseif INIT == "async" then else error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT))) end - diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index 85218c852..60ec1250f 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -667,4 +667,4 @@ end -- The documentation of mapgen noise parameter formats (title plus 16 lines) -- Noise parameter 'mgv5_np_ground' in group format (13 lines) ---assert(loadfile(core.get_mainmenu_path()..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false)) +--assert(loadfile(core.get_builtin_path()..DIR_DELIM.."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false)) -- cgit v1.2.3 From e12019cfd9ff4e9afa1d7dd326a0094b15fb9b2b Mon Sep 17 00:00:00 2001 From: paramat Date: Sun, 15 Jan 2017 01:21:36 +0000 Subject: Documentation: Correct biome heat / humidity noise parameters When the new set of biomes was added in MTGame the 'spread' for heat and humidity noise parameters was increased to 1000, i forgot to update settingtypes.txt and minetest.conf. --- builtin/settingtypes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 779224be4..2dfe86e04 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -910,9 +910,9 @@ emergequeue_limit_generate (Limit of emerge queues to generate) int 32 num_emerge_threads (Number of emerge threads) int 1 # Noise parameters for biome API temperature, humidity and biome blend. -mg_biome_np_heat (Mapgen biome heat noise parameters) noise_params 50, 50, (750, 750, 750), 5349, 3, 0.5, 2.0 +mg_biome_np_heat (Mapgen biome heat noise parameters) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 mg_biome_np_heat_blend (Mapgen heat blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 -mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (750, 750, 750), 842, 3, 0.5, 2.0 +mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 [***Mapgen v5] -- cgit v1.2.3 From f3bd4c405df6bce64b7a98789d825eeac9c279b2 Mon Sep 17 00:00:00 2001 From: red-001 Date: Fri, 6 Jan 2017 20:29:29 +0000 Subject: Add keyword based search to serverlist --- builtin/mainmenu/common.lua | 2 +- builtin/mainmenu/init.lua | 2 +- builtin/mainmenu/tab_credits.lua | 2 +- builtin/mainmenu/tab_multiplayer.lua | 116 ++++++++++++++++++++++++++++++---- builtin/mainmenu/tab_server.lua | 2 +- builtin/mainmenu/tab_settings.lua | 4 +- builtin/mainmenu/tab_simple_main.lua | 4 +- builtin/mainmenu/tab_singleplayer.lua | 4 +- 8 files changed, 113 insertions(+), 23 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index da3667828..5e3df0864 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -77,7 +77,7 @@ function order_favorite_list(list) end -------------------------------------------------------------------------------- -function render_favorite(spec, is_favorite) +function render_serverlist_row(spec, is_favorite) local text = "" if spec.name then text = text .. core.formspec_escape(spec.name:trim()) diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 7f0c1e386..1b527a053 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -128,7 +128,7 @@ local function init_globals() end -- Create main tabview - local tv_main = tabview_create("maintab", {x = 12, y = 5.2}, {x = 0, y = 0}) + local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0}) if PLATFORM == "Android" then tv_main:add(tabs.simple_main) diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index c2ad19183..80e03f84d 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -85,7 +85,7 @@ return { "label[0.5,3.5;http://minetest.net]" .. "tablecolumns[color;text]" .. "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. - "table[3.5,-0.25;8.5,5.8;list_credits;" .. + "table[3.5,-0.25;8.5,6.05;list_credits;" .. "#FFFF00," .. fgettext("Core Developers") .. ",," .. table.concat(core_developers, ",,") .. ",,," .. "#FFFF00," .. fgettext("Active Contributors") .. ",," .. diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua index 00150f26d..3c2b2cdbe 100644 --- a/builtin/mainmenu/tab_multiplayer.lua +++ b/builtin/mainmenu/tab_multiplayer.lua @@ -20,7 +20,16 @@ local function get_formspec(tabview, name, tabdata) -- Update the cached supported proto info, -- it may have changed after a change by the settings menu. common_update_cached_supp_proto() - local fav_selected = menudata.favorites[tabdata.fav_selected] + local fav_selected = nil + if menudata.search_result then + fav_selected = menudata.search_result[tabdata.fav_selected] + else + fav_selected = menudata.favorites[tabdata.fav_selected] + end + + if not tabdata.search_for then + tabdata.search_for = "" + end local retval = "label[7.75,-0.15;" .. fgettext("Address / Port") .. "]" .. @@ -33,7 +42,9 @@ local function get_formspec(tabview, name, tabdata) "field[8,1.95;2.95,0.5;te_name;;" .. core.formspec_escape(core.setting_get("name")) .. "]" .. "pwdfield[10.78,1.95;1.77,0.5;te_pwd;]" .. - "box[7.73,2.35;4.3,2.28;#999999]" + "box[7.73,2.35;4.3,2.28;#999999]".. + "field[0.15,0.25;4.5,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]".. + "button[4.8,0;2.7,0.1;btn_mp_search;" .. fgettext("Search") .. "]" if tabdata.fav_selected and fav_selected then if gamedata.fav then @@ -58,9 +69,27 @@ local function get_formspec(tabview, name, tabdata) image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" .. "color,span=1;" .. "text,padding=1]" .. - "table[-0.15,-0.1;7.75,5.5;favourites;" + "table[-0.15,0.4;7.75,5.35;favourites;" + + if menudata.search_result then + for i = 1, #menudata.search_result do + local favs = core.get_favorites("local") + local server = menudata.search_result[i] - if #menudata.favorites > 0 then + for fav_id = 1, #favs do + if server.address == favs[fav_id].address and + server.port == favs[fav_id].port then + server.is_favorite = true + end + end + + if i ~= 1 then + retval = retval .. "," + end + + retval = retval .. render_serverlist_row(server, server.is_favorite) + end + elseif #menudata.favorites > 0 then local favs = core.get_favorites("local") if #favs > 0 then for i = 1, #favs do @@ -75,9 +104,9 @@ local function get_formspec(tabview, name, tabdata) end end end - retval = retval .. render_favorite(menudata.favorites[1], (#favs > 0)) + retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0)) for i = 2, #menudata.favorites do - retval = retval .. "," .. render_favorite(menudata.favorites[i], (i <= #favs)) + retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs)) end end @@ -92,6 +121,8 @@ end -------------------------------------------------------------------------------- local function main_button_handler(tabview, fields, name, tabdata) + local serverlist = menudata.search_result or menudata.favorites + if fields.te_name then gamedata.playername = fields.te_name core.setting_set("name", fields.te_name) @@ -99,10 +130,10 @@ local function main_button_handler(tabview, fields, name, tabdata) if fields.favourites then local event = core.explode_table_event(fields.favourites) - local fav = menudata.favorites[event.row] + local fav = serverlist[event.row] if event.type == "DCL" then - if event.row <= #menudata.favorites then + if event.row <= #serverlist then if menudata.favorites_is_public and not is_server_protocol_compat_or_error( fav.proto_min, fav.proto_max) then @@ -131,7 +162,7 @@ local function main_button_handler(tabview, fields, name, tabdata) end if event.type == "CHG" then - if event.row <= #menudata.favorites then + if event.row <= #serverlist then gamedata.fav = false local favs = core.get_favorites("local") local address = fav.address @@ -157,7 +188,7 @@ local function main_button_handler(tabview, fields, name, tabdata) if fields.key_up or fields.key_down then local fav_idx = core.get_table_index("favourites") - local fav = menudata.favorites[fav_idx] + local fav = serverlist[fav_idx] if fav_idx then if fields.key_up and fav_idx > 1 then @@ -176,7 +207,7 @@ local function main_button_handler(tabview, fields, name, tabdata) local address = fav.address local port = fav.port - + gamedata.serverdescription = fav.description if address and port then core.setting_set("address", address) core.setting_set("remote_port", port) @@ -199,6 +230,65 @@ local function main_button_handler(tabview, fields, name, tabdata) return true end + if fields.btn_mp_search or fields.key_enter_field == "te_search" then + tabdata.fav_selected = 1 + local input = fields.te_search:lower() + tabdata.search_for = fields.te_search + + if #menudata.favorites < 2 then + return true + end + + menudata.search_result = {} + + -- setup the keyword list + local keywords = {} + for word in input:gmatch("%S+") do + table.insert(keywords, word) + end + + if #keywords == 0 then + menudata.search_result = nil + return true + end + + -- Search the serverlist + local search_result = {} + for i = 1, #menudata.favorites do + local server = menudata.favorites[i] + local found = 0 + for k = 1, #keywords do + local keyword = keywords[k] + if server.name then + local name = server.name:lower() + local _, count = name:gsub(keyword, keyword) + found = found + count * 4 + end + + if server.description then + local desc = server.description:lower() + local _, count = desc:gsub(keyword, keyword) + found = found + count * 2 + end + end + if found > 0 then + local points = (#menudata.favorites - i) / 5 + found + server.points = points + table.insert(search_result, server) + end + end + if #search_result > 0 then + table.sort(search_result, function(a, b) + return a.points > b.points + end) + menudata.search_result = search_result + local first_server = search_result[1] + core.setting_set("address", first_server.address) + core.setting_set("remote_port", first_server.port) + end + return true + end + if (fields.btn_mp_connect or fields.key_enter) and fields.te_address and fields.te_port then gamedata.playername = fields.te_name gamedata.password = fields.te_pwd @@ -206,9 +296,9 @@ local function main_button_handler(tabview, fields, name, tabdata) gamedata.port = fields.te_port gamedata.selected_world = 0 local fav_idx = core.get_table_index("favourites") - local fav = menudata.favorites[fav_idx] + local fav = serverlist[fav_idx] - if fav_idx and fav_idx <= #menudata.favorites and + if fav_idx and fav_idx <= #serverlist and fav.address == fields.te_address and fav.port == fields.te_port then diff --git a/builtin/mainmenu/tab_server.lua b/builtin/mainmenu/tab_server.lua index 6b96825a0..be57ad7ef 100644 --- a/builtin/mainmenu/tab_server.lua +++ b/builtin/mainmenu/tab_server.lua @@ -26,7 +26,7 @@ local function get_formspec(tabview, name, tabdata) "button[4,4.15;2.6,0.5;world_delete;" .. fgettext("Delete") .. "]" .. "button[6.5,4.15;2.8,0.5;world_create;" .. fgettext("New") .. "]" .. "button[9.2,4.15;2.55,0.5;world_configure;" .. fgettext("Configure") .. "]" .. - "button[8.5,4.95;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" .. + "button[8.5,5;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" .. "label[4,-0.25;" .. fgettext("Select World:") .. "]" .. "checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" .. dump(core.setting_getbool("creative_mode")) .. "]" .. diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index af8df0ccb..e59572a41 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -209,12 +209,12 @@ local function formspec(tabview, name, tabdata) .. fgettext("Reset singleplayer world") .. "]" else tab_string = tab_string .. - "button[8,4.75;3.75,0.5;btn_change_keys;" + "button[8,4.85;3.75,0.5;btn_change_keys;" .. fgettext("Change keys") .. "]" end tab_string = tab_string .. - "button[0,4.75;3.75,0.5;btn_advanced_settings;" + "button[0,4.85;3.75,0.5;btn_advanced_settings;" .. fgettext("Advanced Settings") .. "]" diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua index 3818f321f..a773a4912 100644 --- a/builtin/mainmenu/tab_simple_main.lua +++ b/builtin/mainmenu/tab_simple_main.lua @@ -70,9 +70,9 @@ local function get_formspec(tabview, name, tabdata) end end end - retval = retval .. render_favorite(menudata.favorites[1], (#favs > 0)) + retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0)) for i = 2, #menudata.favorites do - retval = retval .. "," .. render_favorite(menudata.favorites[i], (i <= #favs)) + retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs)) end end diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua index 05060cbc6..236de763c 100644 --- a/builtin/mainmenu/tab_singleplayer.lua +++ b/builtin/mainmenu/tab_singleplayer.lua @@ -57,7 +57,7 @@ local function singleplayer_refresh_gamebar() local btnbar = buttonbar_create("game_button_bar", game_buttonbar_button_handler, - {x=-0.3,y=5.65}, "horizontal", {x=12.4,y=1.15}) + {x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15}) for i=1,#gamemgr.games,1 do local btn_name = "game_btnbar_" .. gamemgr.games[i].id @@ -96,7 +96,7 @@ local function get_formspec(tabview, name, tabdata) "button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" .. "button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" .. "button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" .. - "button[8.5,4.95;3.25,0.5;play;".. fgettext("Play") .. "]" .. + "button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" .. "label[4,-0.25;".. fgettext("Select World:") .. "]".. "checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" .. dump(core.setting_getbool("creative_mode")) .. "]".. -- cgit v1.2.3 From d2f5732f89cd58dafc6a4f398b8ebfd122754852 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 16 Jan 2017 15:15:43 +0000 Subject: Adjust formspec spacing on the Client tab of the mainmenu --- builtin/mainmenu/tab_multiplayer.lua | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua index 3c2b2cdbe..f8edeaddd 100644 --- a/builtin/mainmenu/tab_multiplayer.lua +++ b/builtin/mainmenu/tab_multiplayer.lua @@ -32,27 +32,36 @@ local function get_formspec(tabview, name, tabdata) end local retval = - "label[7.75,-0.15;" .. fgettext("Address / Port") .. "]" .. - "label[7.75,1.05;" .. fgettext("Name / Password") .. "]" .. - "field[8,0.75;3.3,0.5;te_address;;" .. + -- Search + "field[0.15,0.35;6.05,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]".. + "button[5.8,0.1;2,0.1;btn_mp_search;" .. fgettext("Search") .. "]" .. + + -- Address / Port + "label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" .. + "field[8,0.65;3.25,0.5;te_address;;" .. core.formspec_escape(core.setting_get("address")) .. "]" .. - "field[11.15,0.75;1.4,0.5;te_port;;" .. + "field[11.1,0.65;1.4,0.5;te_port;;" .. core.formspec_escape(core.setting_get("remote_port")) .. "]" .. - "button[10.1,4.9;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]" .. - "field[8,1.95;2.95,0.5;te_name;;" .. + + -- Name / Password + "label[7.75,0.95;" .. fgettext("Name / Password") .. "]" .. + "field[8,1.85;2.9,0.5;te_name;;" .. core.formspec_escape(core.setting_get("name")) .. "]" .. - "pwdfield[10.78,1.95;1.77,0.5;te_pwd;]" .. - "box[7.73,2.35;4.3,2.28;#999999]".. - "field[0.15,0.25;4.5,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]".. - "button[4.8,0;2.7,0.1;btn_mp_search;" .. fgettext("Search") .. "]" + "pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" .. + + -- Description Background + "box[7.73,2.25;4.25,2.6;#999999]".. + + -- Connect + "button[10.1,5.15;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]" if tabdata.fav_selected and fav_selected then if gamedata.fav then - retval = retval .. "button[7.85,4.9;2.3,0.5;btn_delete_favorite;" .. + retval = retval .. "button[7.75,5.15;2.3,0.5;btn_delete_favorite;" .. fgettext("Del. Favorite") .. "]" end if fav_selected.description then - retval = retval .. "textarea[8.1,2.4;4.26,2.6;;" .. + retval = retval .. "textarea[8.1,2.3;4.23,2.9;;" .. core.formspec_escape((gamedata.serverdescription or ""), true) .. ";]" end end @@ -69,7 +78,7 @@ local function get_formspec(tabview, name, tabdata) image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" .. "color,span=1;" .. "text,padding=1]" .. - "table[-0.15,0.4;7.75,5.35;favourites;" + "table[-0.15,0.6;7.75,5.15;favourites;" if menudata.search_result then for i = 1, #menudata.search_result do -- cgit v1.2.3 From 2f56a00d9eef82052614e5854a07b39b087efd0b Mon Sep 17 00:00:00 2001 From: red-001 Date: Mon, 16 Jan 2017 23:09:47 +0000 Subject: Remove client-side chat prediction. (#5055) Network lag isn't really a big issue with chat and chat prediction makes writing mods harder. --- builtin/game/features.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/game/features.lua b/builtin/game/features.lua index 646b254ea..ef85fbbc3 100644 --- a/builtin/game/features.lua +++ b/builtin/game/features.lua @@ -10,6 +10,7 @@ core.features = { texture_names_parens = true, area_store_custom_ids = true, add_entity_with_staticdata = true, + no_chat_message_prediction = true, } function core.has_feature(arg) -- cgit v1.2.3 From d218baa3ace1f40813a346543feeac2aa71c480c Mon Sep 17 00:00:00 2001 From: Ezhh Date: Tue, 17 Jan 2017 14:41:25 +0000 Subject: Improve priv descriptions (#5047) --- builtin/game/chatcommands.lua | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index eb6edc1c8..199b9e964 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -71,7 +71,8 @@ end -- core.register_chatcommand("me", { params = "", - description = "chat action (eg. /me orders a pizza)", + description = "Display chat action (e.g., '/me orders a pizza' displays" + .. " ' orders a pizza')", privs = {shout=true}, func = function(name, param) core.chat_send_all("* " .. name .. " " .. param) @@ -147,7 +148,7 @@ core.register_chatcommand("help", { core.register_chatcommand("privs", { params = "", - description = "print out privileges of player", + description = "Print privileges of player", func = function(caller, param) param = param:trim() local name = (param ~= "" and param or caller) @@ -270,7 +271,7 @@ core.register_chatcommand("revoke", { core.register_chatcommand("setpassword", { params = " ", - description = "set given password", + description = "Set player's password", privs = {password=true}, func = function(name, param) local toname, raw_password = string.match(param, "^([^ ]+) +(.+)$") @@ -308,7 +309,7 @@ core.register_chatcommand("setpassword", { core.register_chatcommand("clearpassword", { params = "", - description = "set empty password", + description = "Set empty password", privs = {password=true}, func = function(name, param) local toname = param @@ -325,7 +326,7 @@ core.register_chatcommand("clearpassword", { core.register_chatcommand("auth_reload", { params = "", - description = "reload authentication data", + description = "Reload authentication data", privs = {server=true}, func = function(name, param) local done = core.auth_reload() @@ -335,7 +336,7 @@ core.register_chatcommand("auth_reload", { core.register_chatcommand("teleport", { params = ",, | | ,, | ", - description = "teleport to given position", + description = "Teleport to player or position", privs = {teleport=true}, func = function(name, param) -- Returns (pos, true) if found, otherwise (pos, false) @@ -443,7 +444,7 @@ core.register_chatcommand("teleport", { core.register_chatcommand("set", { params = "[-n] | ", - description = "set or read server configuration setting", + description = "Set or read server configuration setting", privs = {server=true}, func = function(name, param) local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)") @@ -498,7 +499,7 @@ end core.register_chatcommand("emergeblocks", { params = "(here [radius]) | ( )", - description = "starts loading (or generating, if inexistent) map blocks " + description = "Load (or, if nonexistent, generate) map blocks " .. "contained in area pos1 to pos2", privs = {server=true}, func = function(name, param) @@ -524,7 +525,7 @@ core.register_chatcommand("emergeblocks", { core.register_chatcommand("deleteblocks", { params = "(here [radius]) | ( )", - description = "delete map blocks contained in area pos1 to pos2", + description = "Delete map blocks contained in area pos1 to pos2", privs = {server=true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -588,7 +589,7 @@ end core.register_chatcommand("give", { params = " ", - description = "give item to player", + description = "Give item to player", privs = {give=true}, func = function(name, param) local toname, itemstring = string.match(param, "^([^ ]+) +(.+)$") @@ -601,7 +602,7 @@ core.register_chatcommand("give", { core.register_chatcommand("giveme", { params = "", - description = "give item to yourself", + description = "Give item to yourself", privs = {give=true}, func = function(name, param) local itemstring = string.match(param, "(.+)$") @@ -672,9 +673,9 @@ end) core.register_chatcommand("rollback_check", { params = "[] [] [limit]", - description = "Check who has last touched a node or near it," - .. " max. ago (default range=0," - .. " seconds=86400=24h, limit=5)", + description = "Check who last touched a node or a node near it" + .. " within the time specified by . Default: range = 0," + .. " seconds = 86400 = 24h, limit = 5", privs = {rollback=true}, func = function(name, param) if not core.setting_getbool("enable_rollback_recording") then @@ -725,7 +726,7 @@ core.register_chatcommand("rollback_check", { core.register_chatcommand("rollback", { params = " [] | : []", - description = "revert actions of a player; default for is 60", + description = "Revert actions of a player. Default for is 60", privs = {rollback=true}, func = function(name, param) if not core.setting_getbool("enable_rollback_recording") then @@ -770,7 +771,7 @@ core.register_chatcommand("status", { core.register_chatcommand("time", { params = "<0..23>:<0..59> | <0..24000>", - description = "set time of day", + description = "Set time of day", privs = {}, func = function(name, param) if param == "" then @@ -816,7 +817,7 @@ core.register_chatcommand("days", { }) core.register_chatcommand("shutdown", { - description = "shutdown server", + description = "Shutdown server", privs = {server=true}, func = function(name, param) core.log("action", name .. " shuts down server") @@ -847,7 +848,7 @@ core.register_chatcommand("ban", { core.register_chatcommand("unban", { params = "", - description = "remove IP ban", + description = "Remove IP ban", privs = {ban=true}, func = function(name, param) if not core.unban_player_or_ip(param) then @@ -860,7 +861,7 @@ core.register_chatcommand("unban", { core.register_chatcommand("kick", { params = " [reason]", - description = "kick a player", + description = "Kick a player", privs = {kick=true}, func = function(name, param) local tokick, reason = param:match("([^ ]+) (.+)") @@ -879,7 +880,7 @@ core.register_chatcommand("kick", { core.register_chatcommand("clearobjects", { params = "[full|quick]", - description = "clear all objects in world", + description = "Clear all objects in world", privs = {server=true}, func = function(name, param) local options = {} -- cgit v1.2.3 From a378e32751127e2ae3708a33f035d1dcf5d400a1 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 18 Jan 2017 06:48:25 +0000 Subject: Add search to advanced settings (#4806) * Add search to advanced settings * Press enter again to go to next result * Use keyword based search, auto select best option --- builtin/mainmenu/dlg_settings_advanced.lua | 120 +++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 6 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index 60ec1250f..697babeb6 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -344,7 +344,82 @@ local function parse_config_file(read_all, parse_mods) return settings end -local settings = parse_config_file(false, true) +local function filter_settings(settings, searchstring) + if not searchstring or searchstring == "" then + return settings, -1 + end + + -- Setup the keyword list + local keywords = {} + for word in searchstring:lower():gmatch("%S+") do + table.insert(keywords, word) + end + + local result = {} + local category_stack = {} + local current_level = 0 + local best_setting = nil + for _, entry in pairs(settings) do + if entry.type == "category" then + -- Remove all settingless categories + while #category_stack > 0 and entry.level <= current_level do + table.remove(category_stack, #category_stack) + if #category_stack > 0 then + current_level = category_stack[#category_stack].level + else + current_level = 0 + end + end + + -- Push category onto stack + category_stack[#category_stack + 1] = entry + current_level = entry.level + else + -- See if setting matches keywords + local setting_score = 0 + for k = 1, #keywords do + local keyword = keywords[k] + + if string.find(entry.name:lower(), keyword, 1, true) then + setting_score = setting_score + 1 + end + + if entry.readable_name and + string.find(fgettext(entry.readable_name):lower(), keyword, 1, true) then + setting_score = setting_score + 1 + end + + if entry.comment and + string.find(fgettext_ne(entry.comment):lower(), keyword, 1, true) then + setting_score = setting_score + 1 + end + end + + -- Add setting to results if match + if setting_score > 0 then + -- Add parent categories + for _, category in pairs(category_stack) do + result[#result + 1] = category + end + category_stack = {} + + -- Add setting + result[#result + 1] = entry + entry.score = setting_score + + if not best_setting or + setting_score > result[best_setting].score then + best_setting = #result + end + end + end + end + return result, best_setting or -1 +end + +local full_settings = parse_config_file(false, true) +local search_string = "" +local settings = full_settings local selected_setting = 1 local function get_current_value(setting) @@ -546,7 +621,10 @@ local function create_settings_formspec(tabview, name, tabdata) local formspec = "size[12,6.5;true]" .. "tablecolumns[color;tree;text,width=32;text]" .. "tableoptions[background=#00000000;border=false]" .. - "table[0,0;12,5.5;list_settings;" + "field[0.3,0.1;10.2,1;search_string;;" .. core.formspec_escape(search_string) .. "]" .. + "field_close_on_enter[search_string;false]" .. + "button[10.2,-0.2;2,1;search;" .. fgettext("Search") .. "]" .. + "table[0,0.8;12,4.5;list_settings;" local current_level = 0 for _, entry in ipairs(settings) do @@ -597,10 +675,10 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) local list_enter = false if fields["list_settings"] then selected_setting = core.get_table_index("list_settings") - if core.explode_table_event(fields["list_settings"]).type == "DCL" then + if core.explode_table_event(fields["list_settings"]).type == "DCL" then -- Directly toggle booleans local setting = settings[selected_setting] - if setting.type == "bool" then + if setting and setting.type == "bool" then local current_value = get_current_value(setting) core.setting_setbool(setting.name, not core.is_yes(current_value)) core.setting_save() @@ -613,9 +691,39 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) end end + if fields.search or fields.key_enter_field == "search_string" then + if search_string == fields.search_string then + if selected_setting > 0 then + -- Go to next result on enter press + local i = selected_setting + 1 + local looped = false + while i > #settings or settings[i].type == "category" do + i = i + 1 + if i > #settings then + -- Stop infinte looping + if looped then + return false + end + i = 1 + looped = true + end + end + selected_setting = i + core.update_formspec(this:get_formspec()) + return true + end + else + -- Search for setting + search_string = fields.search_string + settings, selected_setting = filter_settings(full_settings, search_string) + core.update_formspec(this:get_formspec()) + end + return true + end + if fields["btn_edit"] or list_enter then local setting = settings[selected_setting] - if setting.type ~= "category" then + if setting and setting.type ~= "category" then local edit_dialog = dialog_create("change_setting", create_change_setting_formspec, handle_change_setting_buttons) edit_dialog:set_parent(this) @@ -627,7 +735,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) if fields["btn_restore"] then local setting = settings[selected_setting] - if setting.type ~= "category" then + if setting and setting.type ~= "category" then core.setting_set(setting.name, setting.default) core.setting_save() core.update_formspec(this:get_formspec()) -- cgit v1.2.3 From c5967f75f0a9827d1b65b384edd6ba07c73ffd2f Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 18 Jan 2017 10:19:57 +0000 Subject: Add minetest.player_exists() (#5064) --- builtin/game/misc.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'builtin') diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 7caa9e7ba..3419c1980 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -56,11 +56,11 @@ function core.check_player_privs(name, ...) elseif arg_type ~= "string" then error("Invalid core.check_player_privs argument type: " .. arg_type, 2) end - + local requested_privs = {...} local player_privs = core.get_player_privs(name) local missing_privileges = {} - + if type(requested_privs[1]) == "table" then -- We were provided with a table like { privA = true, privB = true }. for priv, value in pairs(requested_privs[1]) do @@ -76,11 +76,11 @@ function core.check_player_privs(name, ...) end end end - + if #missing_privileges > 0 then return false, missing_privileges end - + return true, "" end @@ -114,6 +114,10 @@ function core.get_connected_players() return temp_table end +function minetest.player_exists(name) + return minetest.get_auth_handler().get_auth(name) ~= nil +end + -- Returns two position vectors representing a box of `radius` in each -- direction centered around the player corresponding to `player_name` function core.get_player_radius_area(player_name, radius) @@ -244,4 +248,3 @@ end function core.close_formspec(player_name, formname) return minetest.show_formspec(player_name, formname, "") end - -- cgit v1.2.3 From efa54f9c460239c23a2014076764d6c6830589e6 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Fri, 20 Jan 2017 10:49:20 -0800 Subject: Add chatcommand unregister and override API (#5076) Introduces two functions to unregister and override chatcommands. minetest.unregister_chatcommand("") and minetest.override_chatcommand("", {}) --- builtin/game/chatcommands.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 199b9e964..08dc1bb1d 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -15,6 +15,24 @@ function core.register_chatcommand(cmd, def) core.registered_chatcommands[cmd] = def end +function core.unregister_chatcommand(name) + if core.registered_chatcommands[name] then + core.registered_chatcommands[name] = nil + else + core.log("warning", "Not unregistering chatcommand " ..name.. + " because it doesn't exist.") + end +end + +function core.override_chatcommand(name, redefinition) + local chatcommand = core.registered_chatcommands[name] + assert(chatcommand, "Attempt to override non-existent chatcommand "..name) + for k, v in pairs(redefinition) do + rawset(chatcommand, k, v) + end + core.registered_chatcommands[name] = chatcommand +end + core.register_on_chat_message(function(name, message) local cmd, param = string.match(message, "^/([^ ]+) *(.*)") if not param then -- cgit v1.2.3 From 6d5a40713347424084af8ba04e76278961506881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sat, 21 Jan 2017 19:30:42 +0100 Subject: Add show_statusline_on_connect setting (#5084) Add show_statusline_on_connect setting --- builtin/settingtypes.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 2dfe86e04..0f416bc9a 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -703,6 +703,9 @@ map-dir (Map directory) path # Setting it to -1 disables the feature. item_entity_ttl (Item entity TTL) int 900 +# If enabled, show the server status message on player connection. +show_statusline_on_connect (Status message on connection) bool true + # Enable players getting damage and dying. enable_damage (Damage) bool false -- cgit v1.2.3 From 2d7a6f2cc0717eb92de4a91326a871d525ce513d Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 12 Jan 2017 11:27:39 -0800 Subject: Vector: Add vector.sort(a, b): return box edges This function returns the box corners of the smallest box that includes the two given coordinates. --- builtin/common/vector.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin') diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua index 90ba3cc8b..0549f9a56 100644 --- a/builtin/common/vector.lua +++ b/builtin/common/vector.lua @@ -138,3 +138,8 @@ function vector.divide(a, b) z = a.z / b} end end + +function vector.sort(a, b) + return {x = math.min(a.x, b.x), y = math.min(a.y, b.y), z = math.min(a.z, b.z)}, + {x = math.max(a.x, b.x), y = math.max(a.y, b.y), z = math.max(a.z, b.z)} +end -- cgit v1.2.3 From 7fc67199683d3c60fe0b3ddcb2a9594b4804cc38 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 12 Jan 2017 11:56:41 -0800 Subject: core: Add dir_to_yaw and yaw_to_dir helpers These are needed to go from things like entity yaw to a vector and vice versa. --- builtin/game/item.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'builtin') diff --git a/builtin/game/item.lua b/builtin/game/item.lua index bf456a4e0..e51da6d6b 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -147,6 +147,14 @@ function core.wallmounted_to_dir(wallmounted) return wallmounted_to_dir[wallmounted] end +function core.dir_to_yaw(dir) + return -math.atan2(dir.x, dir.z) +end + +function core.yaw_to_dir(yaw) + return {x = -math.sin(yaw), y = 0, z = math.cos(yaw)} +end + function core.get_node_drops(nodename, toolname) local drop = ItemStack({name=nodename}):get_definition().drop if drop == nil then -- cgit v1.2.3 From 59fdf57134f62be8b8b4801c5f0fc4a2fca25f43 Mon Sep 17 00:00:00 2001 From: paramat Date: Sun, 22 Jan 2017 04:21:29 +0000 Subject: Zoom FOV: Reduce minimum zoom FOV to 7 degrees The default of 15 is unchanged. 7 degrees is x10 magnification which is common for binoculars. Alter hardcoded limits in camera.cpp: Minimum 7 degrees. Maximum 160 degrees to match upper limits in advanced settings. --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0f416bc9a..581eef315 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -440,7 +440,7 @@ fov (Field of view) int 72 30 160 # Field of view while zooming in degrees. # This requires the "zoom" privilege on the server. -zoom_fov (Field of view for zoom) int 15 15 160 +zoom_fov (Field of view for zoom) int 15 7 160 # Adjust the gamma encoding for the light tables. Higher numbers are brighter. # This setting is for the client only and is ignored by the server. -- cgit v1.2.3 From 0c9189d10989f85cd5148107b643dc17a49c06ff Mon Sep 17 00:00:00 2001 From: Ezhh Date: Sun, 29 Jan 2017 16:10:17 +0000 Subject: Add console height setting (#5136) --- builtin/settingtypes.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 581eef315..c81dde7de 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -477,6 +477,9 @@ fall_bobbing_amount (Fall bobbing) float 0.0 # - pageflip: quadbuffer based 3d. 3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside,pageflip +# In-game chat console height, between 0.1 (10%) and 1.0 (100%). +console_height (Console height) float 1.0 0.1 1.0 + # In-game chat console background color (R,G,B). console_color (Console color) string (0,0,0) -- cgit v1.2.3 From 3e355ab7d5ccdcd77f104eee57237828410b85d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Courant?= Date: Wed, 1 Feb 2017 00:02:30 +0100 Subject: Make facedir_to_dir and wallmounted_to_dir work with coloured nodes as well. (#5153) --- builtin/game/item.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/game/item.lua b/builtin/game/item.lua index e51da6d6b..a8dc51d61 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -109,7 +109,7 @@ local facedir_to_dir_map = { 1, 4, 3, 2, } function core.facedir_to_dir(facedir) - return facedir_to_dir[facedir_to_dir_map[facedir]] + return facedir_to_dir[facedir_to_dir_map[facedir % 32]] end function core.dir_to_wallmounted(dir) @@ -144,7 +144,7 @@ local wallmounted_to_dir = { {x = 0, y = 0, z = -1}, } function core.wallmounted_to_dir(wallmounted) - return wallmounted_to_dir[wallmounted] + return wallmounted_to_dir[wallmounted % 8] end function core.dir_to_yaw(dir) -- cgit v1.2.3 From 03b34cb3dd0647b3e378f00cdc7203e580c9dcc8 Mon Sep 17 00:00:00 2001 From: kilbith Date: Fri, 3 Feb 2017 14:53:43 +0100 Subject: Serverlist: Add ping indicators (#5164) --- builtin/mainmenu/common.lua | 21 ++++++++++++++++++++- builtin/mainmenu/tab_multiplayer.lua | 1 + builtin/mainmenu/tab_simple_main.lua | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 5e3df0864..17d910e8b 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -54,7 +54,11 @@ end function image_column(tooltip, flagname) return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," .. "0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," .. - "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png") + "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png") .. "," .. + "2=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," .. + "3=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," .. + "4=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," .. + "5=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png") end -------------------------------------------------------------------------------- @@ -97,6 +101,21 @@ function render_serverlist_row(spec, is_favorite) details = "0," end + if spec.ping then + local ping = spec.ping * 1000 + if ping <= 50 then + details = details .. "2," + elseif ping <= 100 then + details = details .. "3," + elseif ping <= 250 then + details = details .. "4," + else + details = details .. "5," + end + else + details = details .. "0," + end + if spec.clients and spec.clients_max then local clients_color = '' local clients_percent = 100 * spec.clients / spec.clients_max diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua index f8edeaddd..033ba38d8 100644 --- a/builtin/mainmenu/tab_multiplayer.lua +++ b/builtin/mainmenu/tab_multiplayer.lua @@ -69,6 +69,7 @@ local function get_formspec(tabview, name, tabdata) --favourites retval = retval .. "tablecolumns[" .. image_column(fgettext("Favorite"), "favorite") .. ";" .. + image_column(fgettext("Ping"), "") .. ",padding=0.25;" .. "color,span=3;" .. "text,align=right;" .. -- clients "text,align=center,padding=0.25;" .. -- "/" diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua index a773a4912..23820aab7 100644 --- a/builtin/mainmenu/tab_simple_main.lua +++ b/builtin/mainmenu/tab_simple_main.lua @@ -43,6 +43,7 @@ local function get_formspec(tabview, name, tabdata) retval = retval .. "tablecolumns[" .. image_column(fgettext("Favorite"), "favorite") .. ";" .. + image_column(fgettext("Ping"), "") .. ",padding=0.25;" .. "color,span=3;" .. "text,align=right;" .. -- clients "text,align=center,padding=0.25;" .. -- "/" -- cgit v1.2.3 From 5707b739f38cc5cf651de5b69d91d4f46511dac0 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 8 Feb 2017 23:00:37 -0800 Subject: Change default nodetimer_interval to 0.2s. (#5193) We want to reduce the chance that we get lots and lots of node timers all happening once a second, because we're better off doing small bits of work as they are available. Reducing this to 0.2 seconds will greatly reduce the total amount of nodetimers that elapse at the same instance, while not effecting total work load. This results in a far better chance of the server keeping up with work loads. --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index c81dde7de..0e8783f83 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -840,7 +840,7 @@ active_block_mgmt_interval (Active Block Management interval) float 2.0 abm_interval (Active Block Modifier interval) float 1.0 # Length of time between NodeTimer execution cycles -nodetimer_interval (NodeTimer interval) float 1.0 +nodetimer_interval (NodeTimer interval) float 0.2 # If enabled, invalid world data won't cause the server to shut down. # Only enable this if you know what you are doing. -- cgit v1.2.3 From f5d4494a51a4f38553c10efd51a5c423cd357c87 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 10 Feb 2017 08:19:31 +0100 Subject: Add textures for air and ignore items (#5196) --- builtin/game/register.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/game/register.lua b/builtin/game/register.lua index 90f095e9f..ec6f28097 100644 --- a/builtin/game/register.lua +++ b/builtin/game/register.lua @@ -331,8 +331,8 @@ core.register_item(":unknown", { core.register_node(":air", { description = "Air (you hacker you!)", - inventory_image = "unknown_node.png", - wield_image = "unknown_node.png", + inventory_image = "air.png", + wield_image = "air.png", drawtype = "airlike", paramtype = "light", sunlight_propagates = true, @@ -348,8 +348,8 @@ core.register_node(":air", { core.register_node(":ignore", { description = "Ignore (you hacker you!)", - inventory_image = "unknown_node.png", - wield_image = "unknown_node.png", + inventory_image = "ignore.png", + wield_image = "ignore.png", drawtype = "airlike", paramtype = "none", sunlight_propagates = false, -- cgit v1.2.3 From bb4db84bdbc7038a6ac495dd5f732f89ac40bfcc Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 27 Dec 2016 23:26:36 +0000 Subject: Use tree to list mods rather than textlist --- builtin/mainmenu/dlg_config_world.lua | 110 ++++++++++------------------------ builtin/mainmenu/modmgr.lua | 54 ++++++++--------- builtin/mainmenu/tab_mods.lua | 7 ++- 3 files changed, 59 insertions(+), 112 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index 7b3ab9852..619c927c5 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -17,14 +17,13 @@ -------------------------------------------------------------------------------- -local enabled_all = false +local enabled_all = false local function modname_valid(name) return not name:find("[^a-z0-9_]") end local function get_formspec(data) - local mod = data.list:get_list()[data.selected_mod] local retval = @@ -32,24 +31,12 @@ local function get_formspec(data) "label[0.5,0;" .. fgettext("World:") .. "]" .. "label[1.75,0;" .. data.worldspec.name .. "]" - if data.hide_gamemods then - retval = retval .. "checkbox[1,6;cb_hide_gamemods;" .. fgettext("Hide Game") .. ";true]" - else - retval = retval .. "checkbox[1,6;cb_hide_gamemods;" .. fgettext("Hide Game") .. ";false]" - end - - if data.hide_modpackcontents then - retval = retval .. "checkbox[6,6;cb_hide_mpcontent;" .. fgettext("Hide mp content") .. ";true]" - else - retval = retval .. "checkbox[6,6;cb_hide_mpcontent;" .. fgettext("Hide mp content") .. ";false]" - end - if mod == nil then mod = {name=""} end local hard_deps, soft_deps = modmgr.get_dependencies(mod.path) - + retval = retval .. "label[0,0.7;" .. fgettext("Mod:") .. "]" .. "label[0.75,0.7;" .. mod.name .. "]" .. @@ -62,41 +49,45 @@ local function get_formspec(data) "button[3.25,7;2.5,0.5;btn_config_world_save;" .. fgettext("Save") .. "]" .. "button[5.75,7;2.5,0.5;btn_config_world_cancel;" .. fgettext("Cancel") .. "]" - if mod ~= nil and mod.name ~= "" and mod.typ ~= "game_mod" then + if mod and mod.name ~= "" and mod.typ ~= "game_mod" then if mod.is_modpack then local rawlist = data.list:get_raw_list() local all_enabled = true - for j=1,#rawlist,1 do - if rawlist[j].modpack == mod.name and - rawlist[j].enabled ~= true then - all_enabled = false - break + for j = 1, #rawlist, 1 do + if rawlist[j].modpack == mod.name and not rawlist[j].enabled then + all_enabled = false + break end end - if all_enabled == false then - retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_enable;" .. fgettext("Enable MP") .. "]" + if all_enabled then + retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_disable;" .. + fgettext("Disable MP") .. "]" else - retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_disable;" .. fgettext("Disable MP") .. "]" + retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_enable;" .. + fgettext("Enable MP") .. "]" end else if mod.enabled then - retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" .. fgettext("enabled") .. ";true]" + retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" .. + fgettext("enabled") .. ";true]" else - retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" .. fgettext("enabled") .. ";false]" + retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" .. + fgettext("enabled") .. ";false]" end end end - if enabled_all then + if enabled_all then retval = retval .. - "button[8.75,0.125;2.5,0.5;btn_disable_all_mods;" .. fgettext("Disable all") .. "]" .. - "textlist[5.5,0.75;5.75,5.4;world_config_modlist;" + "button[8.75,0.125;2.5,0.5;btn_disable_all_mods;" .. fgettext("Disable all") .. "]" else retval = retval .. - "button[8.75,0.125;2.5,0.5;btn_enable_all_mods;" .. fgettext("Enable all") .. "]" .. - "textlist[5.5,0.75;5.75,5.4;world_config_modlist;" + "button[8.75,0.125;2.5,0.5;btn_enable_all_mods;" .. fgettext("Enable all") .. "]" end + retval = retval .. + "tablecolumns[color;tree;text]" .. + "table[5.5,0.75;5.75,6;world_config_modlist;" retval = retval .. modmgr.render_modlist(data.list) retval = retval .. ";" .. data.selected_mod .."]" @@ -129,16 +120,15 @@ end local function handle_buttons(this, fields) - if fields["world_config_modlist"] ~= nil then - local event = core.explode_textlist_event(fields["world_config_modlist"]) - this.data.selected_mod = event.index - core.setting_set("world_config_selected_mod", event.index) + local event = core.explode_table_event(fields["world_config_modlist"]) + this.data.selected_mod = event.row + core.setting_set("world_config_selected_mod", event.row) if event.type == "DCL" then enable_mod(this) end - + return true end @@ -160,44 +150,7 @@ local function handle_buttons(this, fields) return true end - if fields["cb_hide_gamemods"] ~= nil or - fields["cb_hide_mpcontent"] ~= nil then - local current = this.data.list:get_filtercriteria() - - if current == nil then - current = {} - end - - if fields["cb_hide_gamemods"] ~= nil then - if core.is_yes(fields["cb_hide_gamemods"]) then - current.hide_game = true - this.data.hide_gamemods = true - core.setting_set("world_config_hide_gamemods", "true") - else - current.hide_game = false - this.data.hide_gamemods = false - core.setting_set("world_config_hide_gamemods", "false") - end - end - - if fields["cb_hide_mpcontent"] ~= nil then - if core.is_yes(fields["cb_hide_mpcontent"]) then - current.hide_modpackcontents = true - this.data.hide_modpackcontents = true - core.setting_set("world_config_hide_modpackcontents", "true") - else - current.hide_modpackcontents = false - this.data.hide_modpackcontents = false - core.setting_set("world_config_hide_modpackcontents", "false") - end - end - - this.data.list:set_filtercriteria(current) - return true - end - if fields["btn_config_world_save"] then - local filename = this.data.worldspec.path .. DIR_DELIM .. "world.mt" @@ -231,7 +184,7 @@ local function handle_buttons(this, fields) if not worldfile:write() then core.log("error", "Failed to write world config file") end - + this:delete() return true end @@ -252,7 +205,7 @@ local function handle_buttons(this, fields) enabled_all = true return true end - + if fields.btn_disable_all_mods then local list = this.data.list:get_raw_list() @@ -269,14 +222,11 @@ local function handle_buttons(this, fields) end function create_configure_world_dlg(worldidx) - local dlg = dialog_create("sp_config_world", get_formspec, handle_buttons, nil) - dlg.data.hide_gamemods = core.setting_getbool("world_config_hide_gamemods") - dlg.data.hide_modpackcontents = core.setting_getbool("world_config_hide_modpackcontents") dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod")) if dlg.data.selected_mod == nil then dlg.data.selected_mod = 0 @@ -286,14 +236,14 @@ function create_configure_world_dlg(worldidx) if dlg.data.worldspec == nil then dlg:delete() return nil end dlg.data.worldconfig = modmgr.get_worldconfig(dlg.data.worldspec.path) - + if dlg.data.worldconfig == nil or dlg.data.worldconfig.id == nil or dlg.data.worldconfig.id == "" then dlg:delete() return nil end - + dlg.data.list = filterlist.create( modmgr.preparemodlist, --refresh modmgr.comparemod, --compare diff --git a/builtin/mainmenu/modmgr.lua b/builtin/mainmenu/modmgr.lua index 2b7b371bf..0fbfa3e6b 100644 --- a/builtin/mainmenu/modmgr.lua +++ b/builtin/mainmenu/modmgr.lua @@ -18,7 +18,7 @@ -------------------------------------------------------------------------------- function get_mods(path,retval,modpack) local mods = core.get_dir_list(path, true) - + for _, name in ipairs(mods) do if name:sub(1, 1) ~= "." then local prefix = path .. DIR_DELIM .. name .. DIR_DELIM @@ -237,49 +237,45 @@ function modmgr.render_modlist(render_list) local list = render_list:get_list() local last_modpack = nil - - for i,v in ipairs(list) do - if retval ~= "" then - retval = retval .."," + local retval = {} + local in_game_mods = false + for i, v in ipairs(list) do + if v.typ == "game_mod" and not in_game_mods then + in_game_mods = true + retval[#retval + 1] = mt_color_blue + retval[#retval + 1] = "0" + retval[#retval + 1] = fgettext("Subgame Mods") end local color = "" - if v.is_modpack then local rawlist = render_list:get_raw_list() + color = mt_color_dark_green - local all_enabled = true - for j=1,#rawlist,1 do + for j = 1, #rawlist, 1 do if rawlist[j].modpack == list[i].name and - rawlist[j].enabled ~= true then - all_enabled = false - break + rawlist[j].enabled ~= true then + -- Modpack not entirely enabled so showing as grey + color = mt_color_grey + break end end - - if all_enabled == false then - color = mt_color_grey - else - color = mt_color_dark_green - end - end - - if v.typ == "game_mod" then + elseif v.typ == "game_mod" then color = mt_color_blue - else - if v.enabled then - color = mt_color_green - end + elseif v.enabled then + color = mt_color_green end - retval = retval .. color - if v.modpack ~= nil then - retval = retval .. " " + retval[#retval + 1] = color + if v.modpack ~= nil or v.typ == "game_mod" then + retval[#retval + 1] = "1" + else + retval[#retval + 1] = "0" end - retval = retval .. v.name + retval[#retval + 1] = core.formspec_escape(v.name) end - return retval + return table.concat(retval, ",") end -------------------------------------------------------------------------------- diff --git a/builtin/mainmenu/tab_mods.lua b/builtin/mainmenu/tab_mods.lua index 4a5b6c041..29afd8a4e 100644 --- a/builtin/mainmenu/tab_mods.lua +++ b/builtin/mainmenu/tab_mods.lua @@ -28,7 +28,8 @@ local function get_formspec(tabview, name, tabdata) local retval = "label[0.05,-0.25;".. fgettext("Installed Mods:") .. "]" .. - "textlist[0,0.25;5.1,5;modlist;" .. + "tablecolumns[color;tree;text]" .. + "table[0,0.25;5.1,5;modlist;" .. modmgr.render_modlist(modmgr.global_mods) .. ";" .. tabdata.selected_mod .. "]" @@ -127,8 +128,8 @@ end -------------------------------------------------------------------------------- local function handle_buttons(tabview, fields, tabname, tabdata) if fields["modlist"] ~= nil then - local event = core.explode_textlist_event(fields["modlist"]) - tabdata.selected_mod = event.index + local event = core.explode_table_event(fields["modlist"]) + tabdata.selected_mod = event.row return true end -- cgit v1.2.3 From 2bd10022cb06850a404f180c455954ed2f817ce3 Mon Sep 17 00:00:00 2001 From: Hybrid Dog Date: Sat, 11 Feb 2017 11:39:41 +0100 Subject: Mainmenu: Brighter text colours for readability --- builtin/mainmenu/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 1b527a053..79e6d5c02 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -16,9 +16,9 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. mt_color_grey = "#AAAAAA" -mt_color_blue = "#0000DD" -mt_color_green = "#00DD00" -mt_color_dark_green = "#003300" +mt_color_blue = "#6389FF" +mt_color_green = "#72FF63" +mt_color_dark_green = "#25C191" --for all other colors ask sfan5 to complete his work! -- cgit v1.2.3 From 3d25914986845dcb789d372ec7c20d15e310572a Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 18 Feb 2017 11:16:11 +0000 Subject: Add support for the new arguments of `request_shutdown` to the `/shutdown` chatcommand. (#5252) --- builtin/game/chatcommands.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 08dc1bb1d..54cd6c325 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -836,11 +836,13 @@ core.register_chatcommand("days", { core.register_chatcommand("shutdown", { description = "Shutdown server", + params = "[reconnect] [message]", privs = {server=true}, func = function(name, param) core.log("action", name .. " shuts down server") - core.request_shutdown() core.chat_send_all("*** Server shutting down (operator request).") + local reconnect, message = param:match("([^ ]+)(.*)") + core.request_shutdown(message:trim(), minetest.is_yes(reconnect)) end, }) -- cgit v1.2.3 From e9cd7187e88b05a3e972b781cd85ef1e4f2bc10b Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 10 Feb 2017 17:40:57 +0000 Subject: Statbars.lua: Cache enable_damage setting --- builtin/game/statbars.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'builtin') diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index 61a8b9077..4e7781e53 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -1,3 +1,5 @@ +-- cache setting +local enable_damage = core.setting_getbool("enable_damage") == true local health_bar_definition = { @@ -42,9 +44,8 @@ local function initialize_builtin_statbars(player) player:hud_set_flags(player:hud_get_flags()) end - if player:hud_get_flags().healthbar and - core.is_yes(core.setting_get("enable_damage")) then - if hud_ids[name].id_healthbar == nil then + if player:hud_get_flags().healthbar and enable_damage then + if hud_ids[name].id_healthbar == nil then health_bar_definition.number = player:get_hp() hud_ids[name].id_healthbar = player:hud_add(health_bar_definition) end @@ -56,8 +57,7 @@ local function initialize_builtin_statbars(player) end if (player:get_breath() < 11) then - if player:hud_get_flags().breathbar and - core.is_yes(core.setting_get("enable_damage")) then + if player:hud_get_flags().breathbar and enable_damage then if hud_ids[name].id_breathbar == nil then hud_ids[name].id_breathbar = player:hud_add(breath_bar_definition) end -- cgit v1.2.3 From d0a6cacd51a25f75b0b2e9133514c7cf40a36805 Mon Sep 17 00:00:00 2001 From: kilbith Date: Thu, 16 Feb 2017 20:14:49 -0800 Subject: Multiplayer menu: fix attempt to open nonexistant image Since local servers and local favorites have no ping value (these are only provided by the server) we shouldn't load a broken image filename. Fixes #5238 --- builtin/mainmenu/common.lua | 3 ++- builtin/mainmenu/tab_multiplayer.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 17d910e8b..57950c62c 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -54,7 +54,8 @@ end function image_column(tooltip, flagname) return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," .. "0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," .. - "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png") .. "," .. + "1=" .. core.formspec_escape(defaulttexturedir .. + (flagname and "server_flags_" .. flagname .. ".png" or "blank.png")) .. "," .. "2=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," .. "3=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," .. "4=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," .. diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua index 033ba38d8..0f4921b03 100644 --- a/builtin/mainmenu/tab_multiplayer.lua +++ b/builtin/mainmenu/tab_multiplayer.lua @@ -69,7 +69,7 @@ local function get_formspec(tabview, name, tabdata) --favourites retval = retval .. "tablecolumns[" .. image_column(fgettext("Favorite"), "favorite") .. ";" .. - image_column(fgettext("Ping"), "") .. ",padding=0.25;" .. + image_column(fgettext("Ping")) .. ",padding=0.25;" .. "color,span=3;" .. "text,align=right;" .. -- clients "text,align=center,padding=0.25;" .. -- "/" -- cgit v1.2.3 From 00123ee04d19ecc98e0a6a9255e5697a78167360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Juh=C3=A1sz?= Date: Sat, 18 Feb 2017 20:26:19 +0100 Subject: Fixes for colorwallmounted and colorfacedir nodes Correct node placement prediction for attached colorwallmounted nodes. Correct placement direction for colorfacedir and colorwallmounted nodes. Correct detatch mechanism for attached colorwallmounted nodes. --- builtin/game/falling.lua | 3 ++- builtin/game/item.lua | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 39a74008c..5ef5289be 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -134,7 +134,8 @@ end function builtin_shared.check_attached_node(p, n) local def = core.registered_nodes[n.name] local d = {x = 0, y = 0, z = 0} - if def.paramtype2 == "wallmounted" then + if def.paramtype2 == "wallmounted" or + def.paramtype2 == "colorwallmounted" then -- The fallback vector here is in case 'wallmounted to dir' is nil due -- to voxelmanip placing a wallmounted node without resetting a -- pre-existing param2 value that is out-of-range for wallmounted. diff --git a/builtin/game/item.lua b/builtin/game/item.lua index a8dc51d61..38ef1714f 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -262,7 +262,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) -- Calculate direction for wall mounted stuff like torches and signs if def.place_param2 ~= nil then newnode.param2 = def.place_param2 - elseif def.paramtype2 == 'wallmounted' and not param2 then + elseif (def.paramtype2 == 'wallmounted' or + def.paramtype2 == 'colorwallmounted') and not param2 then local dir = { x = under.x - above.x, y = under.y - above.y, @@ -270,7 +271,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) } newnode.param2 = core.dir_to_wallmounted(dir) -- Calculate the direction for furnaces and chests and stuff - elseif def.paramtype2 == 'facedir' and not param2 then + elseif (def.paramtype2 == 'facedir' or + def.paramtype2 == 'colorfacedir') and not param2 then local placer_pos = placer:getpos() if placer_pos then local dir = { -- cgit v1.2.3 From 4d634ef675020964413020f6215529670af0091a Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 25 Feb 2017 08:28:25 +0000 Subject: Fix crash that can be caused by the shutdown command. (#5292) --- builtin/game/chatcommands.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 54cd6c325..5d5955972 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -842,7 +842,8 @@ core.register_chatcommand("shutdown", { core.log("action", name .. " shuts down server") core.chat_send_all("*** Server shutting down (operator request).") local reconnect, message = param:match("([^ ]+)(.*)") - core.request_shutdown(message:trim(), minetest.is_yes(reconnect)) + message = message or "" + core.request_shutdown(message:trim(), core.is_yes(reconnect)) end, }) -- cgit v1.2.3 From c9ac722ea9ab3783bf59e7cb991bfb3a91211490 Mon Sep 17 00:00:00 2001 From: zaoqi Date: Sun, 5 Mar 2017 01:36:37 +0800 Subject: Add minetest.spawn_falling_node(pos) (#5339) * Add minetest.spawn_falling_node(pos) * lua_api.txt: Add minetest.spawn_falling_node(pos) * Update minetest.spawn_falling_node(pos) --- builtin/game/falling.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'builtin') diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 5ef5289be..764909361 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -118,6 +118,20 @@ local function spawn_falling_node(p, node) end end +function core.spawn_falling_node(pos) + local node = core.get_node(pos) + if node.name == "air" or node.name == "ignore" then + return false + end + local obj = core.add_entity(pos, "__builtin:falling_node") + if obj then + obj:get_luaentity():set_node(node) + core.remove_node(pos) + return true + end + return false +end + local function drop_attached_node(p) local nn = core.get_node(p).name core.remove_node(p) -- cgit v1.2.3 From d785456b3fa35faf47cb972fde9e8668382c5e22 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 23 Feb 2017 20:03:18 +0100 Subject: Optimize item.lua Replace slow ItemStack get_definitions with registered_nodes one's and cached playername as it's used multiple times. Also removed local item = itemstack:peek_item() as it is never used. --- builtin/game/item.lua | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'builtin') diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 38ef1714f..7048dded1 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -156,7 +156,8 @@ function core.yaw_to_dir(yaw) end function core.get_node_drops(nodename, toolname) - local drop = ItemStack({name=nodename}):get_definition().drop + local def = core.registered_nodes[nodename] + local drop = def and def.drop if drop == nil then -- default drop return {nodename} @@ -205,7 +206,6 @@ function core.get_node_drops(nodename, toolname) end function core.item_place_node(itemstack, placer, pointed_thing, param2) - local item = itemstack:peek_item() local def = itemstack:get_definition() if def.type ~= "node" or pointed_thing.type ~= "node" then return itemstack, false @@ -215,20 +215,21 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) local oldnode_under = core.get_node_or_nil(under) local above = pointed_thing.above local oldnode_above = core.get_node_or_nil(above) + local playername = placer:get_player_name() if not oldnode_under or not oldnode_above then - core.log("info", placer:get_player_name() .. " tried to place" + core.log("info", playername .. " tried to place" .. " node in unloaded position " .. core.pos_to_string(above)) return itemstack, false end - local olddef_under = ItemStack({name=oldnode_under.name}):get_definition() + local olddef_under = core.registered_nodes[oldnode_under.name] olddef_under = olddef_under or core.nodedef_default - local olddef_above = ItemStack({name=oldnode_above.name}):get_definition() + local olddef_above = core.registered_nodes[oldnode_above.name] olddef_above = olddef_above or core.nodedef_default if not olddef_above.buildable_to and not olddef_under.buildable_to then - core.log("info", placer:get_player_name() .. " tried to place" + core.log("info", playername .. " tried to place" .. " node in invalid position " .. core.pos_to_string(above) .. ", replacing " .. oldnode_above.name) return itemstack, false @@ -243,17 +244,17 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) place_to = {x = under.x, y = under.y, z = under.z} end - if core.is_protected(place_to, placer:get_player_name()) and + if core.is_protected(place_to, playername) and not minetest.check_player_privs(placer, "protection_bypass") then - core.log("action", placer:get_player_name() + core.log("action", playername .. " tried to place " .. def.name .. " at protected position " .. core.pos_to_string(place_to)) - core.record_protection_violation(place_to, placer:get_player_name()) + core.record_protection_violation(place_to, playername) return itemstack end - core.log("action", placer:get_player_name() .. " places node " + core.log("action", playername .. " places node " .. def.name .. " at " .. core.pos_to_string(place_to)) local oldnode = core.get_node(place_to) @@ -262,8 +263,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) -- Calculate direction for wall mounted stuff like torches and signs if def.place_param2 ~= nil then newnode.param2 = def.place_param2 - elseif (def.paramtype2 == 'wallmounted' or - def.paramtype2 == 'colorwallmounted') and not param2 then + elseif (def.paramtype2 == "wallmounted" or + def.paramtype2 == "colorwallmounted") and not param2 then local dir = { x = under.x - above.x, y = under.y - above.y, @@ -271,8 +272,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) } newnode.param2 = core.dir_to_wallmounted(dir) -- Calculate the direction for furnaces and chests and stuff - elseif (def.paramtype2 == 'facedir' or - def.paramtype2 == 'colorfacedir') and not param2 then + elseif (def.paramtype2 == "facedir" or + def.paramtype2 == "colorfacedir") and not param2 then local placer_pos = placer:getpos() if placer_pos then local dir = { @@ -310,7 +311,6 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2) end -- Run script hook - local _, callback for _, callback in ipairs(core.registered_on_placenodes) do -- Deepcopy pos, node and pointed_thing because callback can modify them local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z} @@ -451,8 +451,9 @@ function core.handle_node_drops(pos, drops, digger) end function core.node_dig(pos, node, digger) - local def = ItemStack({name=node.name}):get_definition() - if not def.diggable or (def.can_dig and not def.can_dig(pos,digger)) then + local def = core.registered_nodes[node.name] + if def and (not def.diggable or + (def.can_dig and not def.can_dig(pos, digger))) then core.log("info", digger:get_player_name() .. " tried to dig " .. node.name .. " which is not diggable " .. core.pos_to_string(pos)) @@ -477,7 +478,7 @@ function core.node_dig(pos, node, digger) local wdef = wielded:get_definition() local tp = wielded:get_tool_capabilities() - local dp = core.get_dig_params(def.groups, tp) + local dp = core.get_dig_params(def and def.groups, tp) if wdef and wdef.after_use then wielded = wdef.after_use(wielded, digger, node, dp) or wielded else -- cgit v1.2.3 From d34f149bdc4f72db904d948413fa6b3f649dca7b Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 6 Mar 2017 08:35:13 +0000 Subject: Climb speed: Increase default setting from 2 to 3 --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0e8783f83..4e800e25b 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -799,7 +799,7 @@ movement_acceleration_fast (Fast mode acceleration) float 10 movement_speed_walk (Walking speed) float 4 movement_speed_crouch (Crouch speed) float 1.35 movement_speed_fast (Fast mode speed) float 20 -movement_speed_climb (Climbing speed) float 2 +movement_speed_climb (Climbing speed) float 3 movement_speed_jump (Jumping speed) float 6.5 movement_speed_descend (Descending speed) float 6 movement_liquid_fluidity (Liquid fluidity) float 1 -- cgit v1.2.3 From ba4b704ebf24952ab9a84c914b8ad6c45dabfaba Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Mon, 27 Feb 2017 23:06:15 -0800 Subject: Allow server side occlusion culling. --- builtin/settingtypes.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4e800e25b..ffd872c20 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -864,6 +864,12 @@ liquid_update (Liquid update tick) float 1.0 # Stated in mapblocks (16 nodes) block_send_optimize_distance (block send optimize distance) int 4 2 +# If enabled the server will perform map block occlusion culling based on +# on the eye position of the player. This can reduce the number of blocks +# sent to the client 50-80%. The client will not longer receive most invisible +# so that the utility of noclip mode is reduced. +server_side_occlusion_culling (Server side occlusion culling) bool false + [*Mapgen] # Name of map generator to be used when creating a new world. -- cgit v1.2.3 From ff8069694748707d4435ebd109c99ff20212826f Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Fri, 3 Mar 2017 12:40:50 -0800 Subject: Enable server side occlusion culling by default. --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ffd872c20..cba03e983 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -868,7 +868,7 @@ block_send_optimize_distance (block send optimize distance) int 4 2 # on the eye position of the player. This can reduce the number of blocks # sent to the client 50-80%. The client will not longer receive most invisible # so that the utility of noclip mode is reduced. -server_side_occlusion_culling (Server side occlusion culling) bool false +server_side_occlusion_culling (Server side occlusion culling) bool true [*Mapgen] -- cgit v1.2.3 From 7a4878cd0b563296b3f2718b79dc9af177dd4fd2 Mon Sep 17 00:00:00 2001 From: Vladislav Tsendrovskii Date: Fri, 17 Feb 2017 04:48:48 +0300 Subject: Save metainfo for falling nodes --- builtin/game/falling.lua | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'builtin') diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 764909361..b1beb1ab0 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -18,9 +18,11 @@ core.register_entity(":__builtin:falling_node", { }, node = {}, + meta = {}, - set_node = function(self, node) + set_node = function(self, node, meta) self.node = node + self.meta = meta or {} self.object:set_properties({ is_visible = true, textures = {node.name}, @@ -28,15 +30,21 @@ core.register_entity(":__builtin:falling_node", { end, get_staticdata = function(self) - return core.serialize(self.node) + local ds = { + node = self.node, + meta = self.meta, + } + return core.serialize(ds) end, on_activate = function(self, staticdata) self.object:set_armor_groups({immortal = 1}) - local node = core.deserialize(staticdata) - if node then - self:set_node(node) + local ds = core.deserialize(staticdata) + if ds and ds.node then + self:set_node(ds.node, ds.meta) + elseif ds then + self:set_node(ds) elseif staticdata ~= "" then self:set_node({name = staticdata}) end @@ -98,6 +106,10 @@ core.register_entity(":__builtin:falling_node", { -- Create node and remove entity if core.registered_nodes[self.node.name] then core.add_node(np, self.node) + if self.meta then + local meta = core.get_meta(np) + meta:from_table(self.meta) + end end self.object:remove() core.check_for_falling(np) @@ -111,10 +123,10 @@ core.register_entity(":__builtin:falling_node", { end }) -local function spawn_falling_node(p, node) +local function spawn_falling_node(p, node, meta) local obj = core.add_entity(p, "__builtin:falling_node") if obj then - obj:get_luaentity():set_node(node) + obj:get_luaentity():set_node(node, meta) end end @@ -189,8 +201,13 @@ function core.check_single_for_falling(p) (not d_bottom.walkable or d_bottom.buildable_to) then n.level = core.get_node_level(p) + local meta = core.get_meta(p) + local metatable = {} + if meta ~= nil then + metatable = meta:to_table() + end core.remove_node(p) - spawn_falling_node(p, n) + spawn_falling_node(p, n, metatable) return true end end -- cgit v1.2.3 From 2efae3ffd720095222c800e016286a45c9fe1e5c Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Sat, 21 Jan 2017 15:02:08 +0100 Subject: [CSM] Client side modding * rename GameScripting to ServerScripting * Make getBuiltinLuaPath static serverside * Add on_shutdown callback * Add on_receiving_chat_message & on_sending_chat_message callbacks * ScriptApiBase: use IGameDef instead of Server This permits to share common attribute between client & server * Enable mod security in client side modding without conditions --- builtin/client/init.lua | 22 ++++++++++++++++ builtin/client/register.lua | 62 +++++++++++++++++++++++++++++++++++++++++++++ builtin/init.lua | 3 +++ 3 files changed, 87 insertions(+) create mode 100644 builtin/client/init.lua create mode 100644 builtin/client/register.lua (limited to 'builtin') diff --git a/builtin/client/init.lua b/builtin/client/init.lua new file mode 100644 index 000000000..d14301ade --- /dev/null +++ b/builtin/client/init.lua @@ -0,0 +1,22 @@ +-- Minetest: builtin/client/init.lua +local scriptpath = core.get_builtin_path()..DIR_DELIM +local clientpath = scriptpath.."client"..DIR_DELIM + +dofile(clientpath .. "register.lua") + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_shutdown(function() + print("shutdown client") +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_receiving_chat_messages(function(message) + print("Received message " .. message) + return false +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_sending_chat_messages(function(message) + print("Sending message " .. message) + return false +end) diff --git a/builtin/client/register.lua b/builtin/client/register.lua new file mode 100644 index 000000000..c793195a1 --- /dev/null +++ b/builtin/client/register.lua @@ -0,0 +1,62 @@ + +core.callback_origins = {} + +function core.run_callbacks(callbacks, mode, ...) + assert(type(callbacks) == "table") + local cb_len = #callbacks + if cb_len == 0 then + if mode == 2 or mode == 3 then + return true + elseif mode == 4 or mode == 5 then + return false + end + end + local ret + for i = 1, cb_len do + local cb_ret = callbacks[i](...) + + if mode == 0 and i == 1 or mode == 1 and i == cb_len then + ret = cb_ret + elseif mode == 2 then + if not cb_ret or i == 1 then + ret = cb_ret + end + elseif mode == 3 then + if cb_ret then + return cb_ret + end + ret = cb_ret + elseif mode == 4 then + if (cb_ret and not ret) or i == 1 then + ret = cb_ret + end + elseif mode == 5 and cb_ret then + return cb_ret + end + end + return ret +end + +-- +-- Callback registration +-- + +local function make_registration() + local t = {} + local registerfunc = function(func) + t[#t + 1] = func + core.callback_origins[func] = { + mod = core.get_current_modname() or "??", + name = debug.getinfo(1, "n").name or "??" + } + --local origin = core.callback_origins[func] + --print(origin.name .. ": " .. origin.mod .. " registering cbk " .. tostring(func)) + end + return t, registerfunc +end + +core.registered_on_shutdown, core.register_on_shutdown = make_registration() +core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration() +core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration() + + diff --git a/builtin/init.lua b/builtin/init.lua index b34ad14a0..590f7fa8c 100644 --- a/builtin/init.lua +++ b/builtin/init.lua @@ -27,6 +27,7 @@ minetest = core -- Load other files local scriptdir = core.get_builtin_path() .. DIR_DELIM local gamepath = scriptdir .. "game" .. DIR_DELIM +local clientpath = scriptdir .. "client" .. DIR_DELIM local commonpath = scriptdir .. "common" .. DIR_DELIM local asyncpath = scriptdir .. "async" .. DIR_DELIM @@ -45,6 +46,8 @@ elseif INIT == "mainmenu" then end elseif INIT == "async" then dofile(asyncpath .. "init.lua") +elseif INIT == "client" then + dofile(clientpath .. "init.lua") else error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT))) end -- cgit v1.2.3 From 9978f5af828550d819890fed1fc56d65838a2c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sun, 22 Jan 2017 00:20:55 +0100 Subject: [CSM] Add on_death, on_hp_modification & oh_damage_taken callbacks (#5093) * Add on_death callback * Add on_hp_modification & on_damage_taken callbacks * move preview code to preview.lua --- builtin/client/init.lua | 17 +++-------------- builtin/client/preview.lua | 24 ++++++++++++++++++++++++ builtin/client/register.lua | 3 +++ 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 builtin/client/preview.lua (limited to 'builtin') diff --git a/builtin/client/init.lua b/builtin/client/init.lua index d14301ade..e06dfc995 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -3,20 +3,9 @@ local scriptpath = core.get_builtin_path()..DIR_DELIM local clientpath = scriptpath.."client"..DIR_DELIM dofile(clientpath .. "register.lua") +dofile(clientpath .. "preview.lua") --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_shutdown(function() - print("shutdown client") +core.register_on_death(function() + core.display_chat_message("You died.") end) --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_receiving_chat_messages(function(message) - print("Received message " .. message) - return false -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_sending_chat_messages(function(message) - print("Sending message " .. message) - return false -end) diff --git a/builtin/client/preview.lua b/builtin/client/preview.lua new file mode 100644 index 000000000..4b277b0c6 --- /dev/null +++ b/builtin/client/preview.lua @@ -0,0 +1,24 @@ +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_shutdown(function() + print("shutdown client") +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_receiving_chat_messages(function(message) + print("[PREVIEW] Received message " .. message) + return false +end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_on_sending_chat_messages(function(message) + print("[PREVIEW] Sending message " .. message) + return false +end) + +core.register_on_hp_modification(function(hp) + print("[PREVIEW] HP modified " .. hp) +end) + +core.register_on_damage_taken(function(hp) + print("[PREVIEW] Damage taken " .. hp) +end) diff --git a/builtin/client/register.lua b/builtin/client/register.lua index c793195a1..ddaf4f424 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -58,5 +58,8 @@ end core.registered_on_shutdown, core.register_on_shutdown = make_registration() core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration() core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration() +core.registered_on_death, core.register_on_death = make_registration() +core.registered_on_hp_modification, core.register_on_hp_modification = make_registration() +core.registered_on_damage_taken, core.register_on_damage_taken = make_registration() -- cgit v1.2.3 From d7bc346981e189851e490f2417ed015a38bca79b Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 22 Jan 2017 08:05:09 +0000 Subject: [CSM] Add client-sided chat commands (#5092) --- builtin/client/chatcommands.lua | 28 ++++++++++++++++++++++++++++ builtin/client/init.lua | 1 + builtin/client/preview.lua | 7 +++++++ builtin/common/chatcommands.lua | 30 ++++++++++++++++++++++++++++++ builtin/game/chatcommands.lua | 29 +---------------------------- builtin/game/init.lua | 1 + 6 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 builtin/client/chatcommands.lua create mode 100644 builtin/common/chatcommands.lua (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua new file mode 100644 index 000000000..b49c222ef --- /dev/null +++ b/builtin/client/chatcommands.lua @@ -0,0 +1,28 @@ +-- Minetest: builtin/client/chatcommands.lua + + +core.register_on_sending_chat_messages(function(message) + if not (message:sub(1,1) == "/") then + return false + end + + core.display_chat_message("issued command: " .. message) + + local cmd, param = string.match(message, "^/([^ ]+) *(.*)") + if not param then + param = "" + end + + local cmd_def = core.registered_chatcommands[cmd] + + if cmd_def then + core.set_last_run_mod(cmd_def.mod_origin) + local success, message = cmd_def.func(param) + if message then + core.display_chat_message(message) + end + return true + end + + return false +end) \ No newline at end of file diff --git a/builtin/client/init.lua b/builtin/client/init.lua index e06dfc995..4797ac4b6 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -1,6 +1,7 @@ -- Minetest: builtin/client/init.lua local scriptpath = core.get_builtin_path()..DIR_DELIM local clientpath = scriptpath.."client"..DIR_DELIM +local commonpath = scriptpath.."common"..DIR_DELIM dofile(clientpath .. "register.lua") dofile(clientpath .. "preview.lua") diff --git a/builtin/client/preview.lua b/builtin/client/preview.lua index 4b277b0c6..c421791f5 100644 --- a/builtin/client/preview.lua +++ b/builtin/client/preview.lua @@ -22,3 +22,10 @@ end) core.register_on_damage_taken(function(hp) print("[PREVIEW] Damage taken " .. hp) end) + +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_chatcommand("dump", { + func = function(name, param) + return true, dump(_G) + end, +}) \ No newline at end of file diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua new file mode 100644 index 000000000..ef3a24410 --- /dev/null +++ b/builtin/common/chatcommands.lua @@ -0,0 +1,30 @@ +-- Minetest: builtin/common/chatcommands.lua + +core.registered_chatcommands = {} + +function core.register_chatcommand(cmd, def) + def = def or {} + def.params = def.params or "" + def.description = def.description or "" + def.privs = def.privs or {} + def.mod_origin = core.get_current_modname() or "??" + core.registered_chatcommands[cmd] = def +end + +function core.unregister_chatcommand(name) + if core.registered_chatcommands[name] then + core.registered_chatcommands[name] = nil + else + core.log("warning", "Not unregistering chatcommand " ..name.. + " because it doesn't exist.") + end +end + +function core.override_chatcommand(name, redefinition) + local chatcommand = core.registered_chatcommands[name] + assert(chatcommand, "Attempt to override non-existent chatcommand "..name) + for k, v in pairs(redefinition) do + rawset(chatcommand, k, v) + end + core.registered_chatcommands[name] = chatcommand +end \ No newline at end of file diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 5d5955972..745b012e6 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -1,37 +1,10 @@ --- Minetest: builtin/chatcommands.lua +-- Minetest: builtin/game/chatcommands.lua -- -- Chat command handler -- -core.registered_chatcommands = {} core.chatcommands = core.registered_chatcommands -- BACKWARDS COMPATIBILITY -function core.register_chatcommand(cmd, def) - def = def or {} - def.params = def.params or "" - def.description = def.description or "" - def.privs = def.privs or {} - def.mod_origin = core.get_current_modname() or "??" - core.registered_chatcommands[cmd] = def -end - -function core.unregister_chatcommand(name) - if core.registered_chatcommands[name] then - core.registered_chatcommands[name] = nil - else - core.log("warning", "Not unregistering chatcommand " ..name.. - " because it doesn't exist.") - end -end - -function core.override_chatcommand(name, redefinition) - local chatcommand = core.registered_chatcommands[name] - assert(chatcommand, "Attempt to override non-existent chatcommand "..name) - for k, v in pairs(redefinition) do - rawset(chatcommand, k, v) - end - core.registered_chatcommands[name] = chatcommand -end core.register_on_chat_message(function(name, message) local cmd, param = string.match(message, "^/([^ ]+) *(.*)") diff --git a/builtin/game/init.lua b/builtin/game/init.lua index b5e2f7cca..793d9fe2b 100644 --- a/builtin/game/init.lua +++ b/builtin/game/init.lua @@ -22,6 +22,7 @@ dofile(gamepath.."deprecated.lua") dofile(gamepath.."misc.lua") dofile(gamepath.."privileges.lua") dofile(gamepath.."auth.lua") +dofile(commonpath .. "chatcommands.lua") dofile(gamepath.."chatcommands.lua") dofile(gamepath.."static_spawn.lua") dofile(gamepath.."detached_inventory.lua") -- cgit v1.2.3 From 2c19d51409ca903021e0b508e5bc15299c4e51dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sun, 22 Jan 2017 11:17:41 +0100 Subject: [CSM] sound_play & sound_stop support + client_lua_api doc (#5096) * squashed: CSM: Implement register_globalstep * Re-use fatal error mechanism from server to disconnect client on CSM error * Little client functions cleanups * squashed: CSM: add core.after function * core.after is shared code between client & server * ModApiUtil get_us_time feature enabled for client --- builtin/client/init.lua | 3 ++- builtin/client/preview.lua | 15 +++++++++++++-- builtin/client/register.lua | 1 + builtin/common/after.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ builtin/game/init.lua | 1 + builtin/game/misc.lua | 44 -------------------------------------------- 6 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 builtin/common/after.lua (limited to 'builtin') diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 4797ac4b6..dd218aab6 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -4,9 +4,10 @@ local clientpath = scriptpath.."client"..DIR_DELIM local commonpath = scriptpath.."common"..DIR_DELIM dofile(clientpath .. "register.lua") +dofile(commonpath .. "after.lua") +dofile(commonpath .. "chatcommands.lua") dofile(clientpath .. "preview.lua") core.register_on_death(function() core.display_chat_message("You died.") end) - diff --git a/builtin/client/preview.lua b/builtin/client/preview.lua index c421791f5..22e8bb97f 100644 --- a/builtin/client/preview.lua +++ b/builtin/client/preview.lua @@ -1,6 +1,6 @@ -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_shutdown(function() - print("shutdown client") + print("[PREVIEW] shutdown client") end) -- This is an example function to ensure it's working properly, should be removed before merge @@ -15,17 +15,28 @@ core.register_on_sending_chat_messages(function(message) return false end) +-- This is an example function to ensure it's working properly, should be removed before merge core.register_on_hp_modification(function(hp) print("[PREVIEW] HP modified " .. hp) end) +-- This is an example function to ensure it's working properly, should be removed before merge core.register_on_damage_taken(function(hp) print("[PREVIEW] Damage taken " .. hp) end) +-- This is an example function to ensure it's working properly, should be removed before merge +core.register_globalstep(function(dtime) + -- print("[PREVIEW] globalstep " .. dtime) +end) + -- This is an example function to ensure it's working properly, should be removed before merge core.register_chatcommand("dump", { func = function(name, param) return true, dump(_G) end, -}) \ No newline at end of file +}) + +core.after(2, function() + print("After 2") +end) diff --git a/builtin/client/register.lua b/builtin/client/register.lua index ddaf4f424..8b60c1222 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -55,6 +55,7 @@ local function make_registration() return t, registerfunc end +core.registered_globalsteps, core.register_globalstep = make_registration() core.registered_on_shutdown, core.register_on_shutdown = make_registration() core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration() core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration() diff --git a/builtin/common/after.lua b/builtin/common/after.lua new file mode 100644 index 000000000..30a9c7bad --- /dev/null +++ b/builtin/common/after.lua @@ -0,0 +1,43 @@ +local jobs = {} +local time = 0.0 +local last = core.get_us_time() / 1000000 + +core.register_globalstep(function(dtime) + local new = core.get_us_time() / 1000000 + if new > last then + time = time + (new - last) + else + -- Overflow, we may lose a little bit of time here but + -- only 1 tick max, potentially running timers slightly + -- too early. + time = time + new + end + last = new + + if #jobs < 1 then + return + end + + -- Iterate backwards so that we miss any new timers added by + -- a timer callback, and so that we don't skip the next timer + -- in the list if we remove one. + for i = #jobs, 1, -1 do + local job = jobs[i] + if time >= job.expire then + core.set_last_run_mod(job.mod_origin) + job.func(unpack(job.arg)) + table.remove(jobs, i) + end + end +end) + +function core.after(after, func, ...) + assert(tonumber(after) and type(func) == "function", + "Invalid core.after invocation") + jobs[#jobs + 1] = { + func = func, + expire = time + after, + arg = {...}, + mod_origin = core.get_last_run_mod() + } +end diff --git a/builtin/game/init.lua b/builtin/game/init.lua index 793d9fe2b..3e192a30a 100644 --- a/builtin/game/init.lua +++ b/builtin/game/init.lua @@ -17,6 +17,7 @@ if core.setting_getbool("profiler.load") then profiler = dofile(scriptpath.."profiler"..DIR_DELIM.."init.lua") end +dofile(commonpath .. "after.lua") dofile(gamepath.."item_entity.lua") dofile(gamepath.."deprecated.lua") dofile(gamepath.."misc.lua") diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 3419c1980..25376c180 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -4,50 +4,6 @@ -- Misc. API functions -- -local jobs = {} -local time = 0.0 -local last = core.get_us_time() / 1000000 - -core.register_globalstep(function(dtime) - local new = core.get_us_time() / 1000000 - if new > last then - time = time + (new - last) - else - -- Overflow, we may lose a little bit of time here but - -- only 1 tick max, potentially running timers slightly - -- too early. - time = time + new - end - last = new - - if #jobs < 1 then - return - end - - -- Iterate backwards so that we miss any new timers added by - -- a timer callback, and so that we don't skip the next timer - -- in the list if we remove one. - for i = #jobs, 1, -1 do - local job = jobs[i] - if time >= job.expire then - core.set_last_run_mod(job.mod_origin) - job.func(unpack(job.arg)) - table.remove(jobs, i) - end - end -end) - -function core.after(after, func, ...) - assert(tonumber(after) and type(func) == "function", - "Invalid core.after invocation") - jobs[#jobs + 1] = { - func = func, - expire = time + after, - arg = {...}, - mod_origin = core.get_last_run_mod() - } -end - function core.check_player_privs(name, ...) local arg_type = type(name) if (arg_type == "userdata" or arg_type == "table") and -- cgit v1.2.3 From c42c53fccf87a3819ca78de52f8f20c47c4fbb9f Mon Sep 17 00:00:00 2001 From: red-001 Date: Tue, 24 Jan 2017 16:26:15 +0000 Subject: [CSM] Add local formspecs. (#5094) --- builtin/client/init.lua | 10 ++++++++++ builtin/client/preview.lua | 2 +- builtin/client/register.lua | 1 + builtin/common/misc_helpers.lua | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/client/init.lua b/builtin/client/init.lua index dd218aab6..b204ee5e6 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -6,8 +6,18 @@ local commonpath = scriptpath.."common"..DIR_DELIM dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "chatcommands.lua") +dofile(clientpath .. "chatcommands.lua") dofile(clientpath .. "preview.lua") core.register_on_death(function() core.display_chat_message("You died.") + local formspec = "size[11,5.5]bgcolor[#320000b4;true]" .. + "label[4.85,1.35;" .. fgettext("You died.") .. "]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]" + core.show_formspec("bultin:death", formspec) +end) + +core.register_on_formspec_input(function(formname, fields) + if formname == "bultin:death" then + core.send_respawn() + end end) diff --git a/builtin/client/preview.lua b/builtin/client/preview.lua index 22e8bb97f..4c01d665f 100644 --- a/builtin/client/preview.lua +++ b/builtin/client/preview.lua @@ -32,7 +32,7 @@ end) -- This is an example function to ensure it's working properly, should be removed before merge core.register_chatcommand("dump", { - func = function(name, param) + func = function(param) return true, dump(_G) end, }) diff --git a/builtin/client/register.lua b/builtin/client/register.lua index 8b60c1222..1e6ac4342 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -62,5 +62,6 @@ core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages core.registered_on_death, core.register_on_death = make_registration() core.registered_on_hp_modification, core.register_on_hp_modification = make_registration() core.registered_on_damage_taken, core.register_on_damage_taken = make_registration() +core.registered_on_formspec_input, core.register_on_formspec_input = make_registration() diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index c2dc7514d..70b23600a 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -606,7 +606,9 @@ if INIT == "mainmenu" then return nil end +end +if INIT == "client" or INIT == "mainmenu" then function fgettext_ne(text, ...) text = core.gettext(text) local arg = {n=select('#', ...), ...} @@ -636,4 +638,3 @@ if INIT == "mainmenu" then return core.formspec_escape(fgettext_ne(text, ...)) end end - -- cgit v1.2.3 From 92b45b2a189b703fc7cfc8ddbc09a7ad563a13bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 27 Jan 2017 07:41:10 +0100 Subject: [CSM] implement client side mod loading (#5123) * client side mods are located in clientmods/ * move builtin/preview.lua to clientmods/preview/init.lua as a preview mod * refactor ModConfiguration class to work properly with client and server using child objects * move some Server constructor mod load code to ModConfiguration to reduce code duplication between client and server * remove mods.{cpp,h} unused functions * use UNORDERED_SET instead of std::set in some modspec storages --- builtin/client/chatcommands.lua | 14 +++++++------- builtin/client/init.lua | 1 - builtin/client/preview.lua | 42 ----------------------------------------- 3 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 builtin/client/preview.lua (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index b49c222ef..43b4d9a72 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -5,24 +5,24 @@ core.register_on_sending_chat_messages(function(message) if not (message:sub(1,1) == "/") then return false end - + core.display_chat_message("issued command: " .. message) - + local cmd, param = string.match(message, "^/([^ ]+) *(.*)") if not param then param = "" end - + local cmd_def = core.registered_chatcommands[cmd] - + if cmd_def then core.set_last_run_mod(cmd_def.mod_origin) - local success, message = cmd_def.func(param) + local _, message = cmd_def.func(param) if message then core.display_chat_message(message) end return true end - + return false -end) \ No newline at end of file +end) diff --git a/builtin/client/init.lua b/builtin/client/init.lua index b204ee5e6..592274540 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -7,7 +7,6 @@ dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "chatcommands.lua") dofile(clientpath .. "chatcommands.lua") -dofile(clientpath .. "preview.lua") core.register_on_death(function() core.display_chat_message("You died.") diff --git a/builtin/client/preview.lua b/builtin/client/preview.lua deleted file mode 100644 index 4c01d665f..000000000 --- a/builtin/client/preview.lua +++ /dev/null @@ -1,42 +0,0 @@ --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_shutdown(function() - print("[PREVIEW] shutdown client") -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_receiving_chat_messages(function(message) - print("[PREVIEW] Received message " .. message) - return false -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_sending_chat_messages(function(message) - print("[PREVIEW] Sending message " .. message) - return false -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_hp_modification(function(hp) - print("[PREVIEW] HP modified " .. hp) -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_damage_taken(function(hp) - print("[PREVIEW] Damage taken " .. hp) -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_globalstep(function(dtime) - -- print("[PREVIEW] globalstep " .. dtime) -end) - --- This is an example function to ensure it's working properly, should be removed before merge -core.register_chatcommand("dump", { - func = function(param) - return true, dump(_G) - end, -}) - -core.after(2, function() - print("After 2") -end) -- cgit v1.2.3 From a50d07d39a76053328846d82a32bac61468bb16f Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 28 Jan 2017 16:24:25 +0000 Subject: [CSM] Improve security for client-sided mods (#5100) --- builtin/client/register.lua | 5 ++++- builtin/common/strict.lua | 5 +++-- builtin/init.lua | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/client/register.lua b/builtin/client/register.lua index 1e6ac4342..c932fb9f8 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -1,6 +1,9 @@ core.callback_origins = {} +local getinfo = debug.getinfo +debug.getinfo = nil + function core.run_callbacks(callbacks, mode, ...) assert(type(callbacks) == "table") local cb_len = #callbacks @@ -47,7 +50,7 @@ local function make_registration() t[#t + 1] = func core.callback_origins[func] = { mod = core.get_current_modname() or "??", - name = debug.getinfo(1, "n").name or "??" + name = getinfo(1, "n").name or "??" } --local origin = core.callback_origins[func] --print(origin.name .. ": " .. origin.mod .. " registering cbk " .. tostring(func)) diff --git a/builtin/common/strict.lua b/builtin/common/strict.lua index 23ba3d727..ccde9676b 100644 --- a/builtin/common/strict.lua +++ b/builtin/common/strict.lua @@ -3,6 +3,7 @@ -- This ignores mod namespaces (variables with the same name as the current mod). local WARN_INIT = false +local getinfo = debug.getinfo function core.global_exists(name) if type(name) ~= "string" then @@ -18,7 +19,7 @@ local declared = {} local warned = {} function meta:__newindex(name, value) - local info = debug.getinfo(2, "Sl") + local info = getinfo(2, "Sl") local desc = ("%s:%d"):format(info.short_src, info.currentline) if not declared[name] then local warn_key = ("%s\0%d\0%s"):format(info.source, @@ -42,7 +43,7 @@ end function meta:__index(name) - local info = debug.getinfo(2, "Sl") + local info = getinfo(2, "Sl") local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name) if not declared[name] and not warned[warn_key] and info.what ~= "C" then core.log("warning", ("Undeclared global variable %q accessed at %s:%s") diff --git a/builtin/init.lua b/builtin/init.lua index 590f7fa8c..c9fa70fc7 100644 --- a/builtin/init.lua +++ b/builtin/init.lua @@ -47,6 +47,7 @@ elseif INIT == "mainmenu" then elseif INIT == "async" then dofile(asyncpath .. "init.lua") elseif INIT == "client" then + os.setlocale = nil dofile(clientpath .. "init.lua") else error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT))) -- cgit v1.2.3 From 073f5cf03d95ce1cdf04ce8a0adcaf1fc571d95f Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 29 Jan 2017 17:43:44 +0000 Subject: [CSM] Add `on_dignode` callback (#5140) --- builtin/client/register.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/client/register.lua b/builtin/client/register.lua index c932fb9f8..c8a5ddbda 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -66,5 +66,6 @@ core.registered_on_death, core.register_on_death = make_registration() core.registered_on_hp_modification, core.register_on_hp_modification = make_registration() core.registered_on_damage_taken, core.register_on_damage_taken = make_registration() core.registered_on_formspec_input, core.register_on_formspec_input = make_registration() +core.registered_on_dignode, core.register_on_dignode = make_registration() -- cgit v1.2.3 From 0727bb3ddd9c550ff962af4546bac8cc058bce73 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 29 Jan 2017 18:28:38 +0000 Subject: [CSM] Add `on_punchnode` callback --- builtin/client/register.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/client/register.lua b/builtin/client/register.lua index c8a5ddbda..1c3966eda 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -67,5 +67,4 @@ core.registered_on_hp_modification, core.register_on_hp_modification = make_regi core.registered_on_damage_taken, core.register_on_damage_taken = make_registration() core.registered_on_formspec_input, core.register_on_formspec_input = make_registration() core.registered_on_dignode, core.register_on_dignode = make_registration() - - +core.registered_on_punchnode, core.register_on_punchnode = make_registration() -- cgit v1.2.3 From 44ca9c9cb2079fa97068adb8ee894c5ae13a9975 Mon Sep 17 00:00:00 2001 From: nerzhul Date: Mon, 13 Mar 2017 15:55:30 +0100 Subject: [CSM] Add enable_client_modding param (default: false) --- builtin/settingtypes.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index cba03e983..ff17973fa 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -264,6 +264,9 @@ show_entity_selectionbox (Show entity selection boxes) bool true # when connecting to the server. enable_remote_media_server (Connect to external media server) bool true +# Enable Lua modding support on client. +enable_client_modding (Client modding) bool false + # URL to the server list displayed in the Multiplayer Tab. serverlist_url (Serverlist URL) string servers.minetest.net -- cgit v1.2.3 From b539985ab827c2eb025ecb28cf1a97bdd3c75d58 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 15 Mar 2017 00:04:53 -0700 Subject: Fix two nul deref if digging unknown nodes. (#5398) Introduced by d785456b3fa35faf47cb972fde9e8668382c5e22 (#5162) --- builtin/game/item.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 7048dded1..671a994c7 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -496,7 +496,7 @@ function core.node_dig(pos, node, digger) core.handle_node_drops(pos, drops, digger) local oldmetadata = nil - if def.after_dig_node then + if def and def.after_dig_node then oldmetadata = core.get_meta(pos):to_table() end @@ -504,7 +504,7 @@ function core.node_dig(pos, node, digger) core.remove_node(pos) -- Run callback - if def.after_dig_node then + if def and def.after_dig_node then -- Copy pos and node because callback can modify them local pos_copy = {x=pos.x, y=pos.y, z=pos.z} local node_copy = {name=node.name, param1=node.param1, param2=node.param2} -- cgit v1.2.3 From d31750cb9375a961bf225ede210435751edfe7c9 Mon Sep 17 00:00:00 2001 From: red-001 Date: Fri, 17 Mar 2017 18:20:13 +0000 Subject: Give CSM access to use `core.colorize()` (#5113) --- builtin/common/misc_helpers.lua | 32 ++++++++++++++++++++++++++++++++ builtin/game/misc.lua | 31 ------------------------------- 2 files changed, 32 insertions(+), 31 deletions(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 70b23600a..e145a5bfc 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -638,3 +638,35 @@ if INIT == "client" or INIT == "mainmenu" then return core.formspec_escape(fgettext_ne(text, ...)) end end + +-- Client-sided mods don't have access to getbool +if core.setting_getbool and core.setting_getbool("disable_escape_sequences") then + + function core.get_color_escape_sequence(color) + return "" + end + + function core.get_background_escape_sequence(color) + return "" + end + + function core.colorize(color, message) + return message + end + +else + + local ESCAPE_CHAR = string.char(0x1b) + function core.get_color_escape_sequence(color) + return ESCAPE_CHAR .. "(c@" .. color .. ")" + end + + function core.get_background_escape_sequence(color) + return ESCAPE_CHAR .. "(b@" .. color .. ")" + end + + function core.colorize(color, message) + return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff") + end + +end diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 25376c180..618d4d97f 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -170,37 +170,6 @@ function core.http_add_fetch(httpenv) return httpenv end -if minetest.setting_getbool("disable_escape_sequences") then - - function core.get_color_escape_sequence(color) - return "" - end - - function core.get_background_escape_sequence(color) - return "" - end - - function core.colorize(color, message) - return message - end - -else - - local ESCAPE_CHAR = string.char(0x1b) - function core.get_color_escape_sequence(color) - return ESCAPE_CHAR .. "(c@" .. color .. ")" - end - - function core.get_background_escape_sequence(color) - return ESCAPE_CHAR .. "(b@" .. color .. ")" - end - - function core.colorize(color, message) - return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff") - end - -end - function core.close_formspec(player_name, formname) return minetest.show_formspec(player_name, formname, "") end -- cgit v1.2.3 From 2e3778ec0c1f77007d064d15310fa816e2a07e88 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 28 Jan 2017 21:43:06 +0000 Subject: Block access to the `io` library --- builtin/common/misc_helpers.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index e145a5bfc..a1417dbd4 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -197,16 +197,17 @@ assert(table.indexof({"foo", "bar"}, "foo") == 1) assert(table.indexof({"foo", "bar"}, "baz") == -1) -------------------------------------------------------------------------------- -function file_exists(filename) - local f = io.open(filename, "r") - if f == nil then - return false - else - f:close() - return true +if INIT ~= "client" then + function file_exists(filename) + local f = io.open(filename, "r") + if f == nil then + return false + else + f:close() + return true + end end end - -------------------------------------------------------------------------------- function string:trim() return (self:gsub("^%s*(.-)%s*$", "%1")) -- cgit v1.2.3 From dd2f1d7551bfd70357ad4f3fb180704194272147 Mon Sep 17 00:00:00 2001 From: red-001 Date: Fri, 24 Mar 2017 07:36:29 +0000 Subject: Add multiline support to colorize. (#5444) --- builtin/common/misc_helpers.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index a1417dbd4..2318cea12 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -667,7 +667,14 @@ else end function core.colorize(color, message) - return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff") + local lines = message:split("\n", true) + local color_code = core.get_color_escape_sequence(color) + + for i, line in ipairs(lines) do + lines[i] = colour_code .. line + end + + return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff") end end -- cgit v1.2.3 From 329d654e378ffc80711687bae0e516ea1712e63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 24 Mar 2017 08:59:52 +0100 Subject: Typo fix --- builtin/common/misc_helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 2318cea12..1d5b51fc6 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -671,7 +671,7 @@ else local color_code = core.get_color_escape_sequence(color) for i, line in ipairs(lines) do - lines[i] = colour_code .. line + lines[i] = color_code .. line end return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff") -- cgit v1.2.3 From 4d5177ff708c7e696eead18200e240047ff520fe Mon Sep 17 00:00:00 2001 From: number Zero Date: Sat, 18 Feb 2017 21:53:05 +0300 Subject: Add mesh generation delay --- builtin/settingtypes.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ff17973fa..d2bdf030a 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -511,6 +511,10 @@ hud_hotbar_max_width (Maximum hotbar width) float 1.0 # Enables caching of facedir rotated meshes. enable_mesh_cache (Mesh cache) bool false +# Delay between mesh updates on the client in ms. Increasing this will slow +# down the rate of mesh updates, thus reducing jitter on slower clients. +mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50 + # Enables minimap. enable_minimap (Minimap) bool true -- cgit v1.2.3 From e70e15134c95d37241bb6f6124105c0f1c08ab8a Mon Sep 17 00:00:00 2001 From: red-001 Date: Fri, 24 Mar 2017 23:43:36 +0000 Subject: Change command prefix to "." and add "help" command. --- builtin/client/chatcommands.lua | 22 +++++++++---- builtin/common/chatcommands.lua | 73 ++++++++++++++++++++++++++++++++++++++++- builtin/game/chatcommands.lua | 55 ------------------------------- builtin/settingtypes.txt | 4 +++ 4 files changed, 91 insertions(+), 63 deletions(-) (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 43b4d9a72..7a1b4b6b7 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -2,27 +2,35 @@ core.register_on_sending_chat_messages(function(message) - if not (message:sub(1,1) == "/") then - return false + local first_char = message:sub(1,1) + if first_char == "/" or first_char == "." then + core.display_chat_message("issued command: " .. message) end - core.display_chat_message("issued command: " .. message) + if first_char ~= "." then + return false + end - local cmd, param = string.match(message, "^/([^ ]+) *(.*)") + local cmd, param = string.match(message, "^%.([^ ]+) *(.*)") if not param then param = "" end - local cmd_def = core.registered_chatcommands[cmd] + if not cmd then + core.display_chat_message("-!- Empty command") + return true + end + local cmd_def = core.registered_chatcommands[cmd] if cmd_def then core.set_last_run_mod(cmd_def.mod_origin) local _, message = cmd_def.func(param) if message then core.display_chat_message(message) end - return true + else + core.display_chat_message("-!- Invalid command: " .. cmd) end - return false + return true end) diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index ef3a24410..05dd94e8d 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -27,4 +27,75 @@ function core.override_chatcommand(name, redefinition) rawset(chatcommand, k, v) end core.registered_chatcommands[name] = chatcommand -end \ No newline at end of file +end + +local cmd_marker = "/" + +if INIT == "client" then + cmd_marker = "." +end + +local function do_help_cmd(name, param) + local function format_help_line(cmd, def) + local msg = core.colorize("#00ffff", cmd_marker .. cmd) + if def.params and def.params ~= "" then + msg = msg .. " " .. def.params + end + if def.description and def.description ~= "" then + msg = msg .. ": " .. def.description + end + return msg + end + if param == "" then + local cmds = {} + for cmd, def in pairs(core.registered_chatcommands) do + if INIT == "client" or core.check_player_privs(name, def.privs) then + cmds[#cmds + 1] = cmd + end + end + table.sort(cmds) + return true, "Available commands: " .. table.concat(cmds, " ") .. "\n" + .. "Use '"..cmd_marker.."help ' to get more information," + .. " or '"..cmd_marker.."help all' to list everything." + elseif param == "all" then + local cmds = {} + for cmd, def in pairs(core.registered_chatcommands) do + if INIT == "client" or core.check_player_privs(name, def.privs) then + cmds[#cmds + 1] = format_help_line(cmd, def) + end + end + table.sort(cmds) + return true, "Available commands:\n"..table.concat(cmds, "\n") + elseif INIT == "game" and param == "privs" then + local privs = {} + for priv, def in pairs(core.registered_privileges) do + privs[#privs + 1] = priv .. ": " .. def.description + end + table.sort(privs) + return true, "Available privileges:\n"..table.concat(privs, "\n") + else + local cmd = param + local def = core.registered_chatcommands[cmd] + if not def then + return false, "Command not available: "..cmd + else + return true, format_help_line(cmd, def) + end + end +end + +if INIT == "client" then + core.register_chatcommand("help", { + params = "[all/]", + description = "Get help for commands", + func = function(param) + return do_help_cmd(nil, param) + end, + }) +else + core.register_chatcommand("help", { + params = "[all/privs/]", + description = "Get help for commands or list privileges", + func = do_help_cmd, + }) +end diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 745b012e6..b4fa4f828 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -82,61 +82,6 @@ core.register_chatcommand("admin", { end, }) -core.register_chatcommand("help", { - privs = {}, - params = "[all/privs/]", - description = "Get help for commands or list privileges", - func = function(name, param) - local function format_help_line(cmd, def) - local msg = core.colorize("#00ffff", "/"..cmd) - if def.params and def.params ~= "" then - msg = msg .. " " .. def.params - end - if def.description and def.description ~= "" then - msg = msg .. ": " .. def.description - end - return msg - end - if param == "" then - local msg = "" - local cmds = {} - for cmd, def in pairs(core.registered_chatcommands) do - if core.check_player_privs(name, def.privs) then - cmds[#cmds + 1] = cmd - end - end - table.sort(cmds) - return true, "Available commands: " .. table.concat(cmds, " ") .. "\n" - .. "Use '/help ' to get more information," - .. " or '/help all' to list everything." - elseif param == "all" then - local cmds = {} - for cmd, def in pairs(core.registered_chatcommands) do - if core.check_player_privs(name, def.privs) then - cmds[#cmds + 1] = format_help_line(cmd, def) - end - end - table.sort(cmds) - return true, "Available commands:\n"..table.concat(cmds, "\n") - elseif param == "privs" then - local privs = {} - for priv, def in pairs(core.registered_privileges) do - privs[#privs + 1] = priv .. ": " .. def.description - end - table.sort(privs) - return true, "Available privileges:\n"..table.concat(privs, "\n") - else - local cmd = param - local def = core.registered_chatcommands[cmd] - if not def then - return false, "Command not available: "..cmd - else - return true, format_help_line(cmd, def) - end - end - end, -}) - core.register_chatcommand("privs", { params = "", description = "Print privileges of player", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index d2bdf030a..e63697f61 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -156,6 +156,10 @@ keymap_chat (Chat key) key KEY_KEY_T # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_cmd (Command key) key / +# Key for opening the chat window to type local commands. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_cmd_local (Command key) key . + # Key for opening the chat console. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keyman_console (Console key) key KEY_F10 -- cgit v1.2.3 From ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9 Mon Sep 17 00:00:00 2001 From: paramat Date: Thu, 23 Mar 2017 00:18:59 +0000 Subject: Map generation limit: Make per-world The setting limits map generation but affects nothing else. Add 'mapgen_limit' to global mapgen parameters. Move 'blockpos_over_mapgen_limit()' to the only place it is called from: map.cpp. Allow teleportation to any part of the world even if over the set mapgen limit. Simplify the reading of this limit in mgvalleys. Remove the 'map_generation_limit' setting. --- builtin/game/chatcommands.lua | 2 +- builtin/settingtypes.txt | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index b4fa4f828..16f5f3be9 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -303,7 +303,7 @@ core.register_chatcommand("teleport", { p.y = tonumber(p.y) p.z = tonumber(p.z) if p.x and p.y and p.z then - local lm = tonumber(minetest.setting_get("map_generation_limit") or 31000) + local lm = 31000 if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then return false, "Cannot teleport out of map bounds!" end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index e63697f61..c9e0f7b87 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -893,13 +893,10 @@ water_level (Water level) int 1 # From how far blocks are generated for clients, stated in mapblocks (16 nodes). max_block_generate_distance (Max block generate distance) int 6 -# Where the map generator stops. -# Please note: -# - Limited to 31000 (setting above has no effect) -# - The map generator works in groups of 80x80x80 nodes (5x5x5 MapBlocks). -# - Those groups have an offset of -32, -32 nodes from the origin. -# - Only groups which are within the map_generation_limit are generated -map_generation_limit (Map generation limit) int 31000 0 31000 +# Limit of map generation, in nodes, in all 6 directions from (0, 0, 0). +# Only mapchunks completely within the mapgen limit are generated. +# Value is stored per-world. +mapgen_limit (Map generation limit) int 31000 0 31000 # Global map generation attributes. # In Mapgen v6 the 'decorations' flag controls all decorations except trees -- cgit v1.2.3 From 1b299b40391b4ea0fe058b63aad14e3360e917d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Tue, 28 Mar 2017 14:50:17 +0200 Subject: Fix a type bug in colorize function This bug was introduced by dd2f1d7551bfd70357ad4f3fb180704194272147 and reported by @kilbith --- builtin/common/misc_helpers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 1d5b51fc6..cf76fbde9 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -667,7 +667,7 @@ else end function core.colorize(color, message) - local lines = message:split("\n", true) + local lines = tostring(message):split("\n", true) local color_code = core.get_color_escape_sequence(color) for i, line in ipairs(lines) do -- cgit v1.2.3 From 81c3dc32a8e48aee076e4b28cae0037a4ae254d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Tue, 28 Mar 2017 16:55:39 -0300 Subject: Add functions to strip color information. (#5472) --- builtin/common/misc_helpers.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index cf76fbde9..f7111680c 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -640,6 +640,8 @@ if INIT == "client" or INIT == "mainmenu" then end end +local ESCAPE_CHAR = string.char(0x1b) + -- Client-sided mods don't have access to getbool if core.setting_getbool and core.setting_getbool("disable_escape_sequences") then @@ -657,7 +659,6 @@ if core.setting_getbool and core.setting_getbool("disable_escape_sequences") the else - local ESCAPE_CHAR = string.char(0x1b) function core.get_color_escape_sequence(color) return ESCAPE_CHAR .. "(c@" .. color .. ")" end @@ -678,3 +679,15 @@ else end end + +function core.strip_foreground_colors(str) + return (str:gsub(ESCAPE_CHAR .. "%(c@[^)]+%)", "")) +end + +function core.strip_background_colors(str) + return (str:gsub(ESCAPE_CHAR .. "%(b@[^)]+%)", "")) +end + +function core.strip_colors(str) + return (str:gsub(ESCAPE_CHAR .. "%([bc]@[^)]+%)", "")) +end -- cgit v1.2.3 From 26f4a5c2d1e3d825816188fcd63f6d1f6758ae60 Mon Sep 17 00:00:00 2001 From: MarkuBu Date: Sat, 1 Apr 2017 16:50:53 +0200 Subject: First commit for fine pointed (#5485) --- builtin/common/misc_helpers.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index f7111680c..1c7ff3958 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -691,3 +691,35 @@ end function core.strip_colors(str) return (str:gsub(ESCAPE_CHAR .. "%([bc]@[^)]+%)", "")) end + +-------------------------------------------------------------------------------- +-- Returns the exact coordinate of a pointed surface +-------------------------------------------------------------------------------- +function core.pointed_thing_to_face_pos(placer, pointed_thing) + local eye_offset_first = placer:get_eye_offset() + local node_pos = pointed_thing.under + local camera_pos = placer:get_pos() + local pos_off = vector.multiply( + vector.subtract(pointed_thing.above, node_pos), 0.5) + local look_dir = placer:get_look_dir() + local offset, nc + local oc = {} + + for c, v in pairs(pos_off) do + if v == 0 then + oc[#oc + 1] = c + else + offset = v + nc = c + end + end + local fine_pos = {[nc] = node_pos[nc] + offset} + camera_pos.y = camera_pos.y + 1.625 + eye_offset_first.y / 10 + local f = (node_pos[nc] + offset - camera_pos[nc]) / look_dir[nc] + + for i = 1, #oc do + fine_pos[oc[i]] = camera_pos[oc[i]] + look_dir[oc[i]] * f + end + return fine_pos +end + -- cgit v1.2.3 From 75fb3e47308823cf39d4aae0fd739ca445e8e36c Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Sun, 2 Apr 2017 08:51:16 +0000 Subject: minetest.after(): simplify further, pause in singleplayer (#5500) Using the `dtime` value entirely, this will stop the clock if the game is paused in singleplayer. Since most of the clocks were fixed a long time ago, this should again be safe to use. --- builtin/common/after.lua | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'builtin') diff --git a/builtin/common/after.lua b/builtin/common/after.lua index 30a9c7bad..cdfaaab86 100644 --- a/builtin/common/after.lua +++ b/builtin/common/after.lua @@ -1,18 +1,8 @@ local jobs = {} local time = 0.0 -local last = core.get_us_time() / 1000000 core.register_globalstep(function(dtime) - local new = core.get_us_time() / 1000000 - if new > last then - time = time + (new - last) - else - -- Overflow, we may lose a little bit of time here but - -- only 1 tick max, potentially running timers slightly - -- too early. - time = time + new - end - last = new + time = time + dtime if #jobs < 1 then return -- cgit v1.2.3 From 859141a0ce38fbd606d95ae7a2f0999acf2fbe84 Mon Sep 17 00:00:00 2001 From: paramat Date: Sun, 12 Mar 2017 13:26:09 +0000 Subject: Cavegen/Mgv5/Mgv7: Add optional giant caverns Add to MapgenBasic for use by multiple mapgens. Add to mgv5 and mgv7, enabled by default. Similar to mgvalleys caverns but half the scale. Parameters for upper y limit, distance caverns taper to full size, and noise threshold (full cavern size). As with mgvalleys caverns are generated first and classic caves are disabled in any mapchunk containing a cavern, to avoid excessive spreading volumes of liquids. This also avoids floating blobs of liquid where a large classic cave has overgenerated out into a neighbouring previously-generated mapchunk. --- builtin/settingtypes.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index c9e0f7b87..bbee77749 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -940,12 +940,25 @@ mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_ # Controls width of tunnels, a smaller value creates wider tunnels. mgv5_cave_width (Mapgen v5 cave width) float 0.125 +# Y-level of cavern upper limit. +mgv5_cavern_limit (Mapgen v5 cavern limit) int -256 + +# Y-distance over which caverns expand to full size. +mgv5_cavern_taper (Mapgen v5 cavern taper) int 256 + +# Defines full size of caverns, smaller values create larger caverns. +mgv5_cavern_threshold (Mapgen v5 cavern threshold) float 0.7 + mgv5_np_filler_depth (Mapgen v5 filler depth noise parameters) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 mgv5_np_factor (Mapgen v5 factor noise parameters) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 mgv5_np_height (Mapgen v5 height noise parameters) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 mgv5_np_cave1 (Mapgen v5 cave1 noise parameters) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 mgv5_np_cave2 (Mapgen v5 cave2 noise parameters) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 +mgv5_np_cavern (Mapgen v5 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 # TODO +# Noise parameters in group format, unsupported by advanced settings +# menu but settable in minetest.conf. +# See documentation of noise parameter formats in minetest.conf.example. #mgv5_np_ground = { # offset = 0 # scale = 40 @@ -1007,6 +1020,15 @@ mgv7_floatland_level (Mapgen v7 floatland level) int 1280 # Y-level to which floatland shadows extend. mgv7_shadow_limit (Mapgen v7 shadow limit) int 1024 +# Y-level of cavern upper limit. +mgv7_cavern_limit (Mapgen v7 cavern limit) int -256 + +# Y-distance over which caverns expand to full size. +mgv7_cavern_taper (Mapgen v7 cavern taper) int 256 + +# Defines full size of caverns, smaller values create larger caverns. +mgv7_cavern_threshold (Mapgen v7 cavern threshold) float 0.7 + mgv7_np_terrain_base (Mapgen v7 terrain base noise parameters) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 mgv7_np_terrain_alt (Mapgen v7 terrain altitude noise parameters) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 mgv7_np_terrain_persist (Mapgen v7 terrain persistation noise parameters) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 @@ -1018,6 +1040,7 @@ mgv7_np_floatland_base (Mapgen v7 floatland base terrain noise parameters) noise mgv7_np_float_base_height (Mapgen v7 floatland base terrain height noise parameters) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 mgv7_np_mountain (Mapgen v7 mountain noise parameters) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 mgv7_np_ridge (Mapgen v7 river channel wall noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 +mgv7_np_cavern (Mapgen v7 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 mgv7_np_cave1 (Mapgen v7 cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 -- cgit v1.2.3 From 460e094a9fbfe589d138c71f12a8bb87627d7a94 Mon Sep 17 00:00:00 2001 From: paramat Date: Tue, 4 Apr 2017 11:59:52 +0100 Subject: Mapgen documentation: Add descriptions to noise parameters Shorten 'readable names'. Add a new advanced settings menu section for Biome API noises. Various minor edits and improvements. --- builtin/settingtypes.txt | 267 +++++++++++++++++++++++++++++++---------------- 1 file changed, 179 insertions(+), 88 deletions(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index bbee77749..dc3164e44 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -929,36 +929,62 @@ emergequeue_limit_generate (Limit of emerge queues to generate) int 32 # at the cost of slightly buggy caves. num_emerge_threads (Number of emerge threads) int 1 -# Noise parameters for biome API temperature, humidity and biome blend. -mg_biome_np_heat (Mapgen biome heat noise parameters) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 -mg_biome_np_heat_blend (Mapgen heat blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 -mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 -mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 +[***Biome API temperature and humidity noise parameters] + +# Temperature variation for biomes. +mg_biome_np_heat (Heat noise) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 + +# Small-scale temperature variation for blending biomes on borders. +mg_biome_np_heat_blend (Heat blend noise) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 + +# Humidity variation for biomes. +mg_biome_np_humidity (Humidity noise) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 + +# Small-scale humidity variation for blending biomes on borders. +mg_biome_np_humidity_blend (Humidity blend noise) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 [***Mapgen v5] +# Map generation attributes specific to Mapgen v5. +# Flags that are not specified in the flag string are not modified from the default. +# Flags starting with 'no' are used to explicitly disable them. +mgv5_spflags (Mapgen v5 specific flags) flags caverns caverns,nocaverns + # Controls width of tunnels, a smaller value creates wider tunnels. -mgv5_cave_width (Mapgen v5 cave width) float 0.125 +mgv5_cave_width (Cave width) float 0.125 # Y-level of cavern upper limit. -mgv5_cavern_limit (Mapgen v5 cavern limit) int -256 +mgv5_cavern_limit (Cavern limit) int -256 # Y-distance over which caverns expand to full size. -mgv5_cavern_taper (Mapgen v5 cavern taper) int 256 +mgv5_cavern_taper (Cavern taper) int 256 # Defines full size of caverns, smaller values create larger caverns. -mgv5_cavern_threshold (Mapgen v5 cavern threshold) float 0.7 - -mgv5_np_filler_depth (Mapgen v5 filler depth noise parameters) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 -mgv5_np_factor (Mapgen v5 factor noise parameters) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 -mgv5_np_height (Mapgen v5 height noise parameters) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 -mgv5_np_cave1 (Mapgen v5 cave1 noise parameters) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 -mgv5_np_cave2 (Mapgen v5 cave2 noise parameters) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 -mgv5_np_cavern (Mapgen v5 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 +mgv5_cavern_threshold (Cavern threshold) float 0.7 + +# Variation of biome filler depth. +mgv5_np_filler_depth (Filler depth noise) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 + +# Variation of terrain vertical scale. +mgv5_np_factor (Factor noise) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 + +# Y-level of average terrain surface. +mgv5_np_height (Height noise) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 + +# First of 2 3D noises that together define tunnels. +mgv5_np_cave1 (Cave1 noise) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 + +# Second of 2 3D noises that together define tunnels. +mgv5_np_cave2 (Cave2 noise) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 + +# 3D noise defining giant caverns. +mgv5_np_cavern (Cavern noise) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 + # TODO # Noise parameters in group format, unsupported by advanced settings # menu but settable in minetest.conf. # See documentation of noise parameter formats in minetest.conf.example. +# 3D noise defining terrain. #mgv5_np_ground = { # offset = 0 # scale = 40 @@ -973,27 +999,52 @@ mgv5_np_cavern (Mapgen v5 cavern noise parameters) noise_params 0, 1, (384, 128, [***Mapgen v6] # Map generation attributes specific to Mapgen v6. -# When snowbiomes are enabled jungles are automatically enabled, the 'jungles' flag is ignored. +# The 'snowbiomes' flag enables the new 5 biome system. +# When the new biome system is enabled jungles are automatically enabled and +# the 'jungles' flag is ignored. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgv6_spflags (Mapgen v6 flags) flags jungles,biomeblend,mudflow,snowbiomes,trees jungles,biomeblend,mudflow,snowbiomes,flat,trees,nojungles,nobiomeblend,nomudflow,nosnowbiomes,noflat,notrees - -# Controls size of deserts and beaches in Mapgen v6. -# When snowbiomes are enabled 'mgv6_freq_desert' is ignored. -mgv6_freq_desert (Mapgen v6 desert frequency) float 0.45 -mgv6_freq_beach (Mapgen v6 beach frequency) float 0.15 - -mgv6_np_terrain_base (Mapgen v6 terrain base noise parameters) noise_params -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 -mgv6_np_terrain_higher (Mapgen v6 terrain altitude noise parameters) noise_params 20, 16, (500, 500, 500), 85039, 5, 0.6, 2.0 -mgv6_np_steepness (Mapgen v6 steepness noise parameters) noise_params 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2.0 -mgv6_np_height_select (Mapgen v6 height select noise parameters) noise_params 0.5, 1, (250, 250, 250), 4213, 5, 0.69, 2.0 -mgv6_np_mud (Mapgen v6 mud noise parameters) noise_params 4, 2, (200, 200, 200), 91013, 3, 0.55, 2.0 -mgv6_np_beach (Mapgen v6 beach noise parameters) noise_params 0, 1, (250, 250, 250), 59420, 3, 0.50, 2.0 -mgv6_np_biome (Mapgen v6 biome noise parameters) noise_params 0, 1, (500, 500, 500), 9130, 3, 0.50, 2.0 -mgv6_np_cave (Mapgen v6 cave noise parameters) noise_params 6, 6, (250, 250, 250), 34329, 3, 0.50, 2.0 -mgv6_np_humidity (Mapgen v6 humidity noise parameters) noise_params 0.5, 0.5, (500, 500, 500), 72384, 3, 0.50, 2.0 -mgv6_np_trees (Mapgen v6 trees noise parameters) noise_params 0, 1, (125, 125, 125), 2, 4, 0.66, 2.0 -mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1, (100, 100, 100), 342902, 3, 0.45, 2.0 +mgv6_spflags (Mapgen v6 specific flags) flags jungles,biomeblend,mudflow,snowbiomes,trees jungles,biomeblend,mudflow,snowbiomes,flat,trees,nojungles,nobiomeblend,nomudflow,nosnowbiomes,noflat,notrees + +# Deserts occur when np_biome exceeds this value. +# When the new biome system is enabled, this is ignored. +mgv6_freq_desert (Desert noise threshold) float 0.45 + +# Sandy beaches occur when np_beach exceeds this value. +mgv6_freq_beach (Beach noise threshold) float 0.15 + +# Y-level of lower terrain and lakebeds. +mgv6_np_terrain_base (Terrain base noise) noise_params -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 + +# Y-level of higher (cliff-top) terrain. +mgv6_np_terrain_higher (Terrain higher noise) noise_params 20, 16, (500, 500, 500), 85039, 5, 0.6, 2.0 + +# Varies steepness of cliffs. +mgv6_np_steepness (Steepness noise) noise_params 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2.0 + +# Defines areas of 'terrain_higher' (cliff-top terrain). +mgv6_np_height_select (Height select noise) noise_params 0.5, 1, (250, 250, 250), 4213, 5, 0.69, 2.0 + +# Varies depth of biome surface nodes. +mgv6_np_mud (Mud noise) noise_params 4, 2, (200, 200, 200), 91013, 3, 0.55, 2.0 + +# Defines areas with sandy beaches. +mgv6_np_beach (Beach noise) noise_params 0, 1, (250, 250, 250), 59420, 3, 0.50, 2.0 + +# Temperature variation for biomes. +mgv6_np_biome (Biome noise) noise_params 0, 1, (500, 500, 500), 9130, 3, 0.50, 2.0 + +# Variation of number of caves. +mgv6_np_cave (Cave noise) noise_params 6, 6, (250, 250, 250), 34329, 3, 0.50, 2.0 + +# Humidity variation for biomes. +mgv6_np_humidity (Humidity noise) noise_params 0.5, 0.5, (500, 500, 500), 72384, 3, 0.50, 2.0 + +# Defines tree areas and tree density. +mgv6_np_trees (Trees noise) noise_params 0, 1, (125, 125, 125), 2, 4, 0.66, 2.0 + +# Defines areas where trees have apples. +mgv6_np_apple_trees (Apple trees noise) noise_params 0, 1, (100, 100, 100), 342902, 3, 0.45, 2.0 [***Mapgen v7] @@ -1002,47 +1053,77 @@ mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1, # Floatlands are currently experimental and subject to change. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,floatlands,nomountains,noridges,nofloatlands +mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns # Controls width of tunnels, a smaller value creates wider tunnels. -mgv7_cave_width (Mapgen v7 cave width) float 0.09 +mgv7_cave_width (Cave width) float 0.09 # Controls the density of floatland mountain terrain. # Is an offset added to the 'np_mountain' noise value. -mgv7_float_mount_density (Mapgen v7 floatland mountain density) float 0.6 +mgv7_float_mount_density (Floatland mountain density) float 0.6 # Typical maximum height, above and below midpoint, of floatland mountain terrain. -mgv7_float_mount_height (Mapgen v7 floatland mountain height) float 128.0 +mgv7_float_mount_height (Floatland mountain height) float 128.0 # Y-level of floatland midpoint and lake surface. -mgv7_floatland_level (Mapgen v7 floatland level) int 1280 +mgv7_floatland_level (Floatland level) int 1280 # Y-level to which floatland shadows extend. -mgv7_shadow_limit (Mapgen v7 shadow limit) int 1024 +mgv7_shadow_limit (Shadow limit) int 1024 # Y-level of cavern upper limit. -mgv7_cavern_limit (Mapgen v7 cavern limit) int -256 +mgv7_cavern_limit (Cavern limit) int -256 # Y-distance over which caverns expand to full size. -mgv7_cavern_taper (Mapgen v7 cavern taper) int 256 +mgv7_cavern_taper (Cavern taper) int 256 # Defines full size of caverns, smaller values create larger caverns. -mgv7_cavern_threshold (Mapgen v7 cavern threshold) float 0.7 - -mgv7_np_terrain_base (Mapgen v7 terrain base noise parameters) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 -mgv7_np_terrain_alt (Mapgen v7 terrain altitude noise parameters) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 -mgv7_np_terrain_persist (Mapgen v7 terrain persistation noise parameters) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 -mgv7_np_height_select (Mapgen v7 height select noise parameters) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0 -mgv7_np_filler_depth (Mapgen v7 filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 -mgv7_np_mount_height (Mapgen v7 mount height noise parameters) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0 -mgv7_np_ridge_uwater (Mapgen v7 river course noise parameters) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0 -mgv7_np_floatland_base (Mapgen v7 floatland base terrain noise parameters) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0 -mgv7_np_float_base_height (Mapgen v7 floatland base terrain height noise parameters) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 -mgv7_np_mountain (Mapgen v7 mountain noise parameters) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 -mgv7_np_ridge (Mapgen v7 river channel wall noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 -mgv7_np_cavern (Mapgen v7 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 -mgv7_np_cave1 (Mapgen v7 cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +mgv7_cavern_threshold (Cavern threshold) float 0.7 + +# Y-level of higher (cliff-top) terrain. +mgv7_np_terrain_base (Terrain base noise) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 + +# Y-level of lower terrain and lakebeds. +mgv7_np_terrain_alt (Terrain alt noise) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 + +# Varies roughness of terrain. +# Defines the 'persistence' value for terrain_base and terrain_alt noises. +mgv7_np_terrain_persist (Terrain persistence noise) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 + +# Defines areas of higher (cliff-top) terrain and affects steepness of cliffs. +mgv7_np_height_select (Height select noise) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0 + +# Variation of biome filler depth. +mgv7_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 + +# Variation of maximum mountain height (in nodes). +mgv7_np_mount_height (Mountain height noise) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0 + +# Defines large-scale river channel structure. +mgv7_np_ridge_uwater (Ridge underwater noise) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0 + +# Defines areas of floatland smooth terrain. +# Smooth floatlands occur when noise > 0. +mgv7_np_floatland_base (Floatland base noise) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0 + +# Variation of hill height and lake depth on floatland smooth terrain. +mgv7_np_float_base_height (Floatland base height noise) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 + +# 3D noise defining mountain structure and height. +# Also defines structure of floatland mountain terrain. +mgv7_np_mountain (Mountain noise) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 + +# 3D noise defining structure of river canyon walls. +mgv7_np_ridge (Ridge noise) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 + +# 3D noise defining giant caverns. +mgv7_np_cavern (Cavern noise) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 + +# First of 2 3D noises that together define tunnels. +mgv7_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 + +# Second of 2 3D noises that together define tunnels. +mgv7_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 [***Mapgen flat] @@ -1050,46 +1131,49 @@ mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67 # Occasional lakes and hills can be added to the flat world. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgflat_spflags (Mapgen flat flags) flags lakes,hills,,nolakes,nohills +mgflat_spflags (Mapgen flat specific flags) flags lakes,hills,,nolakes,nohills # Y of flat ground. -mgflat_ground_level (Mapgen flat ground level) int 8 +mgflat_ground_level (Ground level) int 8 # Y of upper limit of large pseudorandom caves. -mgflat_large_cave_depth (Mapgen flat large cave depth) int -33 +mgflat_large_cave_depth (Large cave depth) int -33 # Controls width of tunnels, a smaller value creates wider tunnels. -mgflat_cave_width (Mapgen flat cave width) float 0.09 +mgflat_cave_width (Cave width) float 0.09 # Terrain noise threshold for lakes. # Controls proportion of world area covered by lakes. # Adjust towards 0.0 for a larger proportion. -mgflat_lake_threshold (Mapgen flat lake threshold) float -0.45 +mgflat_lake_threshold (Lake threshold) float -0.45 # Controls steepness/depth of lake depressions. -mgflat_lake_steepness (Mapgen flat lake steepness) float 48.0 +mgflat_lake_steepness (Lake steepness) float 48.0 # Terrain noise threshold for hills. # Controls proportion of world area covered by hills. # Adjust towards 0.0 for a larger proportion. -mgflat_hill_threshold (Mapgen flat hill threshold) float 0.45 +mgflat_hill_threshold (Hill threshold) float 0.45 # Controls steepness/height of hills. -mgflat_hill_steepness (Mapgen flat hill steepness) float 64.0 +mgflat_hill_steepness (Hill steepness) float 64.0 -# Determines terrain shape. -# The 3 numbers in brackets control the scale of the -# terrain, the 3 numbers should be identical. -mgflat_np_terrain (Mapgen flat terrain noise parameters) noise_params 0, 1, (600, 600, 600), 7244, 5, 0.6, 2.0 +# Defines location and terrain of optional hills and lakes. +mgflat_np_terrain (Terrain noise) noise_params 0, 1, (600, 600, 600), 7244, 5, 0.6, 2.0 -mgflat_np_filler_depth (Mapgen flat filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 -mgflat_np_cave1 (Mapgen flat cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgflat_np_cave2 (Mapgen flat cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# Variation of biome filler depth. +mgflat_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 + +# First of 2 3D noises that together define tunnels. +mgflat_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 + +# Second of 2 3D noises that together define tunnels. +mgflat_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 [***Mapgen fractal] # Controls width of tunnels, a smaller value creates wider tunnels. -mgfractal_cave_width (Mapgen fractal cave width) float 0.09 +mgfractal_cave_width (Cave width) float 0.09 # Choice of 18 fractals from 9 formulas. # 1 = 4D "Roundy" mandelbrot set. @@ -1110,48 +1194,55 @@ mgfractal_cave_width (Mapgen fractal cave width) float 0.09 # 16 = 3D "Cosine Mandelbulb" julia set. # 17 = 4D "Mandelbulb" mandelbrot set. # 18 = 4D "Mandelbulb" julia set. -mgfractal_fractal (Mapgen fractal fractal) int 1 1 18 +mgfractal_fractal (Fractal type) int 1 1 18 # Iterations of the recursive function. # Controls the amount of fine detail. -mgfractal_iterations (Mapgen fractal iterations) int 11 +mgfractal_iterations (Iterations) int 11 # Approximate (X,Y,Z) scale of fractal in nodes. -mgfractal_scale (Mapgen fractal scale) v3f (4096.0, 1024.0, 4096.0) +mgfractal_scale (Scale) v3f (4096.0, 1024.0, 4096.0) # (X,Y,Z) offset of fractal from world centre in units of 'scale'. # Used to move a suitable spawn area of low land close to (0, 0). # The default is suitable for mandelbrot sets, it needs to be edited for julia sets. # Range roughly -2 to 2. Multiply by 'scale' for offset in nodes. -mgfractal_offset (Mapgen fractal offset) v3f (1.79, 0.0, 0.0) +mgfractal_offset (Offset) v3f (1.79, 0.0, 0.0) # W co-ordinate of the generated 3D slice of a 4D fractal. # Determines which 3D slice of the 4D shape is generated. # Has no effect on 3D fractals. # Range roughly -2 to 2. -mgfractal_slice_w (Mapgen fractal slice w) float 0.0 +mgfractal_slice_w (Slice w) float 0.0 # Julia set only: X component of hypercomplex constant determining julia shape. # Range roughly -2 to 2. -mgfractal_julia_x (Mapgen fractal julia x) float 0.33 +mgfractal_julia_x (Julia x) float 0.33 # Julia set only: Y component of hypercomplex constant determining julia shape. # Range roughly -2 to 2. -mgfractal_julia_y (Mapgen fractal julia y) float 0.33 +mgfractal_julia_y (Julia y) float 0.33 # Julia set only: Z component of hypercomplex constant determining julia shape. # Range roughly -2 to 2. -mgfractal_julia_z (Mapgen fractal julia z) float 0.33 +mgfractal_julia_z (Julia z) float 0.33 # Julia set only: W component of hypercomplex constant determining julia shape. # Has no effect on 3D fractals. # Range roughly -2 to 2. -mgfractal_julia_w (Mapgen fractal julia w) float 0.33 +mgfractal_julia_w (Julia w) float 0.33 + +# Y-level of seabed. +mgfractal_np_seabed (Seabed noise) noise_params -14, 9, (600, 600, 600), 41900, 5, 0.6, 2.0 + +# Variation of biome filler depth. +mgfractal_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 + +# First of 2 3D noises that together define tunnels. +mgfractal_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgfractal_np_seabed (Mapgen fractal seabed noise parameters) noise_params -14, 9, (600, 600, 600), 41900, 5, 0.6, 2.0 -mgfractal_np_filler_depth (Mapgen fractal filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 -mgfractal_np_cave1 (Mapgen fractal cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgfractal_np_cave2 (Mapgen fractal cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# Second of 2 3D noises that together define tunnels. +mgfractal_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 # Mapgen Valleys parameters [***Mapgen Valleys] -- cgit v1.2.3 From 6da828c471768f2a9efadce7dd51c6cdc5cde6cc Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Thu, 6 Apr 2017 07:57:49 +0200 Subject: Expose vector helpers to CSM --- builtin/client/init.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 592274540..3ac34d845 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -7,6 +7,7 @@ dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "chatcommands.lua") dofile(clientpath .. "chatcommands.lua") +dofile(commonpath .. "vector.lua") core.register_on_death(function() core.display_chat_message("You died.") -- cgit v1.2.3 From bce0d458d8cda70c10d78ea9ec476474f0a6f01a Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 2 Apr 2017 23:00:34 +0100 Subject: Add Joystick type detection and Xbox controller support * Add joystick type detection (with joystick_type setting to override it) * Fix multiple joysticks from interfering with each other by only reading from one (add joystick_id setting) * Add support for Xbox controllers --- builtin/settingtypes.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index dc3164e44..d95f8cf41 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -107,6 +107,12 @@ continuous_forward (Continuous forward) bool false # Enable Joysticks enable_joysticks (Enable Joysticks) bool false +# The identifier of the joystick to use +joystick_id (Joystick ID) int 0 + +# The type of joystick +joystick_type (Joystick Type) enum auto auto,generic,xbox + # The time in seconds it takes between repeated events # when holding down a joystick button combination. repeat_joystick_button_time (Joystick button repetition interval) float 0.17 -- cgit v1.2.3 From 71ffe699d0d8e5cd2594eb74d0d767eeb8a09cea Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Fri, 7 Apr 2017 17:10:26 +0200 Subject: Settings: Update documentation (#5534) Now documented (sorted a-z): enable_console enable_particles creative_mode hud_scaling inventory_image_hack keymap_console keymap_zoom shader_path view_bobbing --- builtin/settingtypes.txt | 49 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index d95f8cf41..a3b91fe74 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -206,6 +206,10 @@ keymap_screenshot (Screenshot) key KEY_F12 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_drop (Drop item key) key KEY_KEY_Q +# Key to use view zoom when possible. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_zoom (View zoom key) key KEY_KEY_Z + # Key for toggling the display of the HUD. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_hud (HUD toggle key) key KEY_F1 @@ -214,6 +218,10 @@ keymap_toggle_hud (HUD toggle key) key KEY_F1 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_chat (Chat toggle key) key KEY_F2 +# Key for toggling the display of the large chat console. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_console (Large chat console key) key KEY_F10 + # Key for toggling the display of the fog. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_force_fog_off (Fog toggle key) key KEY_F3 @@ -275,6 +283,7 @@ show_entity_selectionbox (Show entity selection boxes) bool true enable_remote_media_server (Connect to external media server) bool true # Enable Lua modding support on client. +# This support is experimental and API can change. enable_client_modding (Client modding) bool false # URL to the server list displayed in the Multiplayer Tab. @@ -317,6 +326,9 @@ enable_3d_clouds (3D clouds) bool true # Method used to highlight selected object. node_highlighting (Node highlighting) enum box box,halo +# Adds particles when digging a node. +enable_particles (Digging particles) bool true + [***Filtering] # Use mip mapping to scale textures. May slightly increase performance. @@ -353,9 +365,12 @@ fsaa (FSAA) enum 0 0,1,2,4,8,16 [***Shaders] # Shaders allow advanced visual effects and may increase performance on some video cards. -# Thy only work with the OpenGL video backend. +# This only works with the OpenGL video backend. enable_shaders (Shaders) bool true +# Path to shader directory. If no path is defined, default location will be used. +shader_path (Shader path) path + [****Tone Mapping] # Enables filmic tone mapping @@ -390,7 +405,7 @@ enable_parallax_occlusion (Parallax occlusion) bool false parallax_occlusion_mode (Parallax occlusion mode) int 1 0 1 # Strength of parallax. -3d_parallax_strength (Parallax occlusion strength) float 0.025 +3d_paralax_strength (Parallax occlusion strength) float 0.025 # Number of parallax occlusion iterations. parallax_occlusion_iterations (Parallax occlusion iterations) int 4 @@ -472,13 +487,16 @@ cloud_height (Cloud height) int 120 # Values larger than 26 will start to produce sharp cutoffs at cloud area corners. cloud_radius (Cloud radius) int 12 +# Enables view bobbing when walking. +view_bobbing (Enable view bobbing) bool true + # Multiplier for view bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. -view_bobbing_amount (View bobbing) float 1.0 +view_bobbing_amount (View bobbing factor) float 1.0 # Multiplier for fall bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. -fall_bobbing_amount (Fall bobbing) float 0.0 +fall_bobbing_amount (Fall bobbing factor) float 0.0 # 3D support. # Currently supported: @@ -518,6 +536,9 @@ desynchronize_mapblock_texture_animation (Desynchronize block animation) bool tr # Useful if there's something to be displayed right or left of hotbar. hud_hotbar_max_width (Maximum hotbar width) float 1.0 +# Modifies the size of the hudbar elements. +hud_scaling (HUD scale factor) float 1.0 + # Enables caching of facedir rotated meshes. enable_mesh_cache (Mesh cache) bool false @@ -548,9 +569,16 @@ ambient_occlusion_gamma (Ambient occlusion gamma) float 2.2 0.25 4.0 # Enables animation of inventory items. inventory_items_animations (Inventory items animations) bool false +# Android systems only: Tries to create inventory textures from meshes +# when no supported render was found. +inventory_image_hack (Inventory image hack) bool false + # Fraction of the visible distance at which fog starts to be rendered fog_start (Fog Start) float 0.4 0.0 0.99 +# Makes all liquids opaque +opaque_water (Opaque liquids) bool false + [**Menus] # Use a cloud animation for the main menu background. @@ -617,6 +645,10 @@ screenshot_quality (Screenshot quality) int 0 0 100 # Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens. screen_dpi (DPI) int 72 +# Windows systems only: Start Minetest with the command line window in the background. +# Contains the same information as the file debug.txt (default name). +enable_console (Enable console window) bool false + [*Sound] enable_sound (Sound) bool true @@ -729,6 +761,9 @@ show_statusline_on_connect (Status message on connection) bool true # Enable players getting damage and dying. enable_damage (Damage) bool false +# Enable creative mode for new created maps. +creative_mode (Creative) bool false + # A chosen map seed for a new map, leave empty for random. # Will be overridden when creating a new world in the main menu. fixed_map_seed (Fixed map seed) string @@ -972,6 +1007,7 @@ mgv5_cavern_threshold (Cavern threshold) float 0.7 mgv5_np_filler_depth (Filler depth noise) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 # Variation of terrain vertical scale. +# When noise is < -0.55 terrain is near-flat. mgv5_np_factor (Factor noise) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 # Y-level of average terrain surface. @@ -1059,7 +1095,7 @@ mgv6_np_apple_trees (Apple trees noise) noise_params 0, 1, (100, 100, 100), 3429 # Floatlands are currently experimental and subject to change. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns +mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,nofloatlands,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns # Controls width of tunnels, a smaller value creates wider tunnels. mgv7_cave_width (Cave width) float 0.09 @@ -1137,7 +1173,7 @@ mgv7_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 # Occasional lakes and hills can be added to the flat world. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgflat_spflags (Mapgen flat specific flags) flags lakes,hills,,nolakes,nohills +mgflat_spflags (Mapgen flat specific flags) flags nolakes,nohills lakes,hills,nolakes,nohills # Y of flat ground. mgflat_ground_level (Ground level) int 8 @@ -1349,7 +1385,6 @@ profiler.load (Load the game profiler) bool false profiler.default_report_format (Default report format) enum txt txt,csv,lua,json,json_pretty # The file path relative to your worldpath in which profiles will be saved to. -# profiler.report_path (Report path) string "" [***Instrumentation] -- cgit v1.2.3 From f73534640a18709921519ee43110292cf658e67f Mon Sep 17 00:00:00 2001 From: Vincent Glize Date: Sat, 8 Apr 2017 08:20:30 +0200 Subject: [CSM] Add event on_connect player API lua (#5540) * Add event on_connect player API lua --- builtin/client/register.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/client/register.lua b/builtin/client/register.lua index 1c3966eda..e6ce25654 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -60,6 +60,7 @@ end core.registered_globalsteps, core.register_globalstep = make_registration() core.registered_on_shutdown, core.register_on_shutdown = make_registration() +core.registered_on_connect, core.register_on_connect = make_registration() core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration() core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration() core.registered_on_death, core.register_on_death = make_registration() -- cgit v1.2.3 From d4e9dd4643607192f5adebeecda86f25074f02cd Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 8 Apr 2017 19:03:57 +0100 Subject: Move chat command handling code from C++ to Lua (#5528) --- builtin/game/chatcommands.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 16f5f3be9..8df3903d2 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -7,13 +7,22 @@ core.chatcommands = core.registered_chatcommands -- BACKWARDS COMPATIBILITY core.register_on_chat_message(function(name, message) + if message:sub(1,1) ~= "/" then + return + end + local cmd, param = string.match(message, "^/([^ ]+) *(.*)") - if not param then - param = "" + if not cmd then + core.chat_send_player(name, "-!- Empty command") + return true end + + param = param or "" + local cmd_def = core.registered_chatcommands[cmd] if not cmd_def then - return false + core.chat_send_player(name, "-!- Invalid command: " .. cmd) + return true end local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs) if has_privs then -- cgit v1.2.3 From 58d83a7bb2f992194c3df304b1dcbb81f98f78c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Juh=C3=A1sz?= Date: Fri, 10 Mar 2017 18:25:58 +0100 Subject: Hardware coloring for itemstacks Adds the possibility to colorize item stacks based on their metadata. In the item/node definition you can specify palette (an image file) and color (fallback color if the item has no palette or metadata). Then you can add palette_index to the metadata. Dropped itemstacks with different colors do not merge. --- builtin/game/item_entity.lua | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'builtin') diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index be158c119..7b8247116 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -53,6 +53,8 @@ core.register_entity(":__builtin:item", { if itemtable then itemname = stack:to_table().name end + -- Backwards compatibility: old clients use the texture + -- to get the type of the item local item_texture = nil local item_type = "" if core.registered_items[itemname] then @@ -66,6 +68,7 @@ core.register_entity(":__builtin:item", { visual_size = {x = s, y = s}, collisionbox = {-c, -c, -c, c, c, c}, automatic_rotate = math.pi * 0.5, + wield_item = itemstring, } self.object:set_properties(prop) end, @@ -101,31 +104,39 @@ core.register_entity(":__builtin:item", { self:set_item(self.itemstring) end, + -- moves items from this stack to an other stack try_merge_with = function(self, own_stack, object, obj) + -- other item's stack local stack = ItemStack(obj.itemstring) - if own_stack:get_name() == stack:get_name() and stack:get_free_space() > 0 then + -- only merge if items are the same + if own_stack:get_name() == stack:get_name() and + own_stack:get_meta() == stack:get_meta() and + own_stack:get_wear() == stack:get_wear() and + stack:get_free_space() > 0 then local overflow = false local count = stack:get_count() + own_stack:get_count() local max_count = stack:get_stack_max() if count > max_count then overflow = true + stack:set_count(max_count) count = count - max_count + own_stack:set_count(count) else self.itemstring = '' + stack:set_count(count) end local pos = object:getpos() pos.y = pos.y + (count - stack:get_count()) / max_count * 0.15 object:moveto(pos, false) local s, c - local max_count = stack:get_stack_max() - local name = stack:get_name() if not overflow then - obj.itemstring = name .. " " .. count + obj.itemstring = stack:to_string() s = 0.2 + 0.1 * (count / max_count) c = s object:set_properties({ visual_size = {x = s, y = s}, - collisionbox = {-c, -c, -c, c, c, c} + collisionbox = {-c, -c, -c, c, c, c}, + wield_item = obj.itemstring }) self.object:remove() -- merging succeeded @@ -133,18 +144,20 @@ core.register_entity(":__builtin:item", { else s = 0.4 c = 0.3 + obj.itemstring = stack:to_string() object:set_properties({ visual_size = {x = s, y = s}, - collisionbox = {-c, -c, -c, c, c, c} + collisionbox = {-c, -c, -c, c, c, c}, + wield_item = obj.itemstring }) - obj.itemstring = name .. " " .. max_count s = 0.2 + 0.1 * (count / max_count) c = s + self.itemstring = own_stack:to_string() self.object:set_properties({ visual_size = {x = s, y = s}, - collisionbox = {-c, -c, -c, c, c, c} + collisionbox = {-c, -c, -c, c, c, c}, + wield_item = self.itemstring }) - self.itemstring = name .. " " .. count end end -- merging didn't succeed -- cgit v1.2.3 From 0a8834608d21998bd05b899bd91ddc2196762926 Mon Sep 17 00:00:00 2001 From: number Zero Date: Thu, 12 Jan 2017 12:19:36 +0300 Subject: Hard-coded undersampling. Adds uniform undersampling for the 3D rendered scene. GUI elements are not undersampled, resulting in better playability for users with low-performance platforms with readable fonts and formspecs. The undersampling setting can be set to 0 (disabled), 2, 3, 4 pixels which translates into a resolution reduction of x4, x9 or x16, and is significant. --- builtin/settingtypes.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index a3b91fe74..2c74d6c44 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -362,6 +362,11 @@ texture_min_size (Minimum texture size for filters) int 64 # when set to higher number than 0. fsaa (FSAA) enum 0 0,1,2,4,8,16 +# Undersampling is similar to using lower screen resolution, but it applies +# to the game world only, keeping the GUI intact. +# It should give significant performance boost at the cost of less detailed image. +undersampling (Undersampling) enum 0 0,2,3,4 + [***Shaders] # Shaders allow advanced visual effects and may increase performance on some video cards. -- cgit v1.2.3 From e8d872332040c16714ff6410d1f859adcec4766e Mon Sep 17 00:00:00 2001 From: red-001 Date: Mon, 10 Apr 2017 20:13:20 +0100 Subject: [CSM] Move `.list_players` and `.disconnect` to builtin. (#5550) --- builtin/client/chatcommands.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 7a1b4b6b7..bb5b905d8 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -34,3 +34,18 @@ core.register_on_sending_chat_messages(function(message) return true end) + +core.register_chatcommand("list_players", { + description = "List online players", + func = function(param) + local players = table.concat(core.get_player_names(), ", ") + core.display_chat_message("Online players: " .. players) + end +}) + +core.register_chatcommand("disconnect", { + description = "Exit to main menu", + func = function(param) + core.disconnect() + end, +}) -- cgit v1.2.3 From eb587996e42544ec8624b256e6d5eea12f9bab88 Mon Sep 17 00:00:00 2001 From: red-001 Date: Mon, 10 Apr 2017 20:14:00 +0100 Subject: [CSM] Use more gettext (#5553) --- builtin/client/chatcommands.lua | 6 +++--- builtin/common/chatcommands.lua | 25 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index bb5b905d8..bb698cdec 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -4,7 +4,7 @@ core.register_on_sending_chat_messages(function(message) local first_char = message:sub(1,1) if first_char == "/" or first_char == "." then - core.display_chat_message("issued command: " .. message) + core.display_chat_message(core.gettext("issued command: ") .. message) end if first_char ~= "." then @@ -17,7 +17,7 @@ core.register_on_sending_chat_messages(function(message) end if not cmd then - core.display_chat_message("-!- Empty command") + core.display_chat_message(core.gettext("-!- Empty command")) return true end @@ -29,7 +29,7 @@ core.register_on_sending_chat_messages(function(message) core.display_chat_message(message) end else - core.display_chat_message("-!- Invalid command: " .. cmd) + core.display_chat_message(core.gettext("-!- Invalid command: ") .. cmd) end return true diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index 05dd94e8d..e8955c6b4 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -31,8 +31,19 @@ end local cmd_marker = "/" +local function gettext(...) + return ... +end + +local function gettext_replace(text, replace) + return text:gsub("$1", replace) +end + + if INIT == "client" then cmd_marker = "." + gettext = core.gettext + gettext_replace = fgettext_ne end local function do_help_cmd(name, param) @@ -54,9 +65,9 @@ local function do_help_cmd(name, param) end end table.sort(cmds) - return true, "Available commands: " .. table.concat(cmds, " ") .. "\n" - .. "Use '"..cmd_marker.."help ' to get more information," - .. " or '"..cmd_marker.."help all' to list everything." + return true, gettext("Available commands: ") .. table.concat(cmds, " ") .. "\n" + .. gettext_replace("Use '$1help ' to get more information," + .. " or '$1help all' to list everything.", cmd_marker) elseif param == "all" then local cmds = {} for cmd, def in pairs(core.registered_chatcommands) do @@ -65,7 +76,7 @@ local function do_help_cmd(name, param) end end table.sort(cmds) - return true, "Available commands:\n"..table.concat(cmds, "\n") + return true, gettext("Available commands:").."\n"..table.concat(cmds, "\n") elseif INIT == "game" and param == "privs" then local privs = {} for priv, def in pairs(core.registered_privileges) do @@ -77,7 +88,7 @@ local function do_help_cmd(name, param) local cmd = param local def = core.registered_chatcommands[cmd] if not def then - return false, "Command not available: "..cmd + return false, gettext("Command not available: ")..cmd else return true, format_help_line(cmd, def) end @@ -86,8 +97,8 @@ end if INIT == "client" then core.register_chatcommand("help", { - params = "[all/]", - description = "Get help for commands", + params = gettext("[all/]"), + description = gettext("Get help for commands"), func = function(param) return do_help_cmd(nil, param) end, -- cgit v1.2.3 From 4e2479e46a8d19fa0e943f84898b602cf38f6480 Mon Sep 17 00:00:00 2001 From: red-001 Date: Tue, 11 Apr 2017 22:35:25 +0100 Subject: [CSM] Allow escaping chatcommands and add missing calls to gettext. (#5565) --- builtin/client/chatcommands.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index bb698cdec..f425216f5 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -2,6 +2,10 @@ core.register_on_sending_chat_messages(function(message) + if message:sub(1,2) == ".." then + return false + end + local first_char = message:sub(1,1) if first_char == "/" or first_char == "." then core.display_chat_message(core.gettext("issued command: ") .. message) @@ -12,9 +16,7 @@ core.register_on_sending_chat_messages(function(message) end local cmd, param = string.match(message, "^%.([^ ]+) *(.*)") - if not param then - param = "" - end + param = param or "" if not cmd then core.display_chat_message(core.gettext("-!- Empty command")) @@ -36,15 +38,15 @@ core.register_on_sending_chat_messages(function(message) end) core.register_chatcommand("list_players", { - description = "List online players", + description = core.gettext("List online players"), func = function(param) local players = table.concat(core.get_player_names(), ", ") - core.display_chat_message("Online players: " .. players) + core.display_chat_message(core.gettext("Online players: ") .. players) end }) core.register_chatcommand("disconnect", { - description = "Exit to main menu", + description = core.gettext("Exit to main menu"), func = function(param) core.disconnect() end, -- cgit v1.2.3 From 34d32ce55ae4f3f29d7b645075dc8efacb2c96d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sat, 15 Apr 2017 23:19:18 +0200 Subject: Implement delayed server shutdown with cancelation (#4664) --- builtin/game/chatcommands.lua | 16 +++++++++++----- builtin/game/misc.lua | 5 +++++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 8df3903d2..25cc06178 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -763,14 +763,20 @@ core.register_chatcommand("days", { core.register_chatcommand("shutdown", { description = "Shutdown server", - params = "[reconnect] [message]", + params = "[delay_in_seconds(0..inf) or -1 for cancel] [reconnect] [message]", privs = {server=true}, func = function(name, param) - core.log("action", name .. " shuts down server") - core.chat_send_all("*** Server shutting down (operator request).") - local reconnect, message = param:match("([^ ]+)(.*)") + local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)") message = message or "" - core.request_shutdown(message:trim(), core.is_yes(reconnect)) + + if delay ~= "" then + delay = tonumber(param) or 0 + else + delay = 0 + core.log("action", name .. " shuts down server") + core.chat_send_all("*** Server shutting down (operator request).") + end + core.request_shutdown(message:trim(), core.is_yes(reconnect), delay) end, }) diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 618d4d97f..a3eb26ac2 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -173,3 +173,8 @@ end function core.close_formspec(player_name, formname) return minetest.show_formspec(player_name, formname, "") end + +function core.cancel_shutdown_requests() + core.request_shutdown("", false, -1) +end + -- cgit v1.2.3 From 04cc9de8f2fbcb11f133c88f02fc11504b3ea6f3 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 15 Apr 2017 10:55:52 +0300 Subject: MeshUpdateQueue: Add a MapBlock cache that minimizes the amount of MapBlock copying done in the main thread Cache size is configurable by the meshgen_block_cache_size (default 20 MB). New profiler stats: - MeshUpdateQueue MapBlock cache hit % - MeshUpdateQueue MapBlock cache size kB Removes one type of stutter that was seen on the client when received MapBlocks were being handled. (the "MeshMakeData::fill" stutter) Kind of related to at least #5239 Originally preceded by these commits, now includes them: - Move the mesh generator thread into src/mesh_generator_thread.{cpp,h} - mesh_generator_thread.cpp: Update code style - MeshUpdateThread: Modify interface to house a different implementation: Actual functionality will be changed by next commits. - MeshMakeData: Add fillBlockData() interface (so that caller can fill in stuff from eg. a MapBlock cache) --- builtin/settingtypes.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 2c74d6c44..5dc48c00e 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -551,6 +551,11 @@ enable_mesh_cache (Mesh cache) bool false # down the rate of mesh updates, thus reducing jitter on slower clients. mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50 +# Size of the MapBlock cache of the mesh generator. Increasing this will +# increase the cache hit %, reducing the data being copied from the main +# thread, thus reducing jitter. +meshgen_block_cache_size (Mapblock mesh generator's MapBlock cache size MB) int 20 0 1000 + # Enables minimap. enable_minimap (Minimap) bool true -- cgit v1.2.3 From efd509f796a4870243ce97012aa27940993f4a79 Mon Sep 17 00:00:00 2001 From: MarkuBu Date: Thu, 13 Apr 2017 13:58:34 +0200 Subject: Pointed thing to face pos: Fix crash if opening door with slab or stair Avoids crash caused when 'pointed thing -under' and '-above' are not face-neighbours, for example in the case of pointing to the top half of a door. --- builtin/common/misc_helpers.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 1c7ff3958..fc284c843 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -706,13 +706,14 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing) local oc = {} for c, v in pairs(pos_off) do - if v == 0 then + if nc or v == 0 then oc[#oc + 1] = c else offset = v nc = c end end + local fine_pos = {[nc] = node_pos[nc] + offset} camera_pos.y = camera_pos.y + 1.625 + eye_offset_first.y / 10 local f = (node_pos[nc] + offset - camera_pos[nc]) / look_dir[nc] @@ -722,4 +723,3 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing) end return fine_pos end - -- cgit v1.2.3 From cfe0291b131630a7400fdcf46b720bd70d8d0fa0 Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 17 Apr 2017 14:17:43 +0100 Subject: Conf.example: Move some lines to minetest.conf.example.extra Some information in conf.example cannot be generated from settingtypes.txt, moving it to a new file makes generating conf.example while preserving that information easier. Regenerate conf.example from settingtypes.txt. --- builtin/mainmenu/dlg_settings_advanced.lua | 6 ------ 1 file changed, 6 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index 697babeb6..c63eb972e 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -769,10 +769,4 @@ end -- Generate minetest.conf.example and settings_translation_file.cpp --- *** Please note *** --- There is text in minetest.conf.example that will not be generated from --- settingtypes.txt but must be preserved: --- The documentation of mapgen noise parameter formats (title plus 16 lines) --- Noise parameter 'mgv5_np_ground' in group format (13 lines) - --assert(loadfile(core.get_builtin_path()..DIR_DELIM.."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false)) -- cgit v1.2.3 From f6d1b682d3c3fa25e11d64d52c93b92760fe2612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Juh=C3=A1sz?= Date: Fri, 21 Apr 2017 12:56:10 +0200 Subject: Add /fixlight chat command --- builtin/game/chatcommands.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 25cc06178..84f2c3fed 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -487,6 +487,25 @@ core.register_chatcommand("deleteblocks", { end, }) +core.register_chatcommand("fixlight", { + params = "(here [radius]) | ( )", + description = "Resets lighting in the area between pos1 and pos2", + privs = {server = true}, + func = function(name, param) + local p1, p2 = parse_range_str(name, param) + if p1 == false then + return false, p2 + end + + if core.fix_light(p1, p2) then + return true, "Successfully reset light in the area ranging from " .. + core.pos_to_string(p1, 1) .. " to " .. core.pos_to_string(p2, 1) + else + return false, "Failed to load one or more blocks in area" + end + end, +}) + core.register_chatcommand("mods", { params = "", description = "List mods installed on the server", -- cgit v1.2.3 From 29ab20c27229672c24a7699afbcd54caad903331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sun, 23 Apr 2017 14:35:08 +0200 Subject: Player data to Database (#5475) * Player data to Database Add player data into databases (SQLite3 & PG only) PostgreSQL & SQLite: better POO Design for databases Add --migrate-players argument to server + deprecation warning * Remove players directory if empty --- builtin/game/chatcommands.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 84f2c3fed..cbf75c1bc 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -279,6 +279,31 @@ core.register_chatcommand("auth_reload", { end, }) +core.register_chatcommand("remove_player", { + params = "", + description = "Remove player data", + privs = {server=true}, + func = function(name, param) + local toname = param + if toname == "" then + return false, "Name field required" + end + + local rc = core.remove_player(toname) + + if rc == 0 then + core.log("action", name .. " removed player data of " .. toname .. ".") + return true, "Player \"" .. toname .. "\" removed." + elseif rc == 1 then + return true, "No such player \"" .. toname .. "\" to remove." + elseif rc == 2 then + return true, "Player \"" .. toname .. "\" is connected, cannot remove." + end + + return false, "Unhandled remove_player return code " .. rc .. "" + end, +}) + core.register_chatcommand("teleport", { params = ",, | | ,, | ", description = "Teleport to player or position", -- cgit v1.2.3 From db17225a976e20c6628afe70dd6b230673287b4d Mon Sep 17 00:00:00 2001 From: Louis Pearson Date: Tue, 25 Apr 2017 06:11:51 -0500 Subject: Footsteps without view bobbing (#5645) * Remove redundant view_bobbing setting Also fixes bug where disabling view_bobbing disables footstep sounds. * Removes redundant view_bobbing setting Setting view_bobbing amount to 0 is now the only way to turn view_bobbing on and off. Also fixed a bug where footstep sounds would not play when view_bobbing was disabled. --- builtin/settingtypes.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 5dc48c00e..29a96ab8e 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -492,10 +492,7 @@ cloud_height (Cloud height) int 120 # Values larger than 26 will start to produce sharp cutoffs at cloud area corners. cloud_radius (Cloud radius) int 12 -# Enables view bobbing when walking. -view_bobbing (Enable view bobbing) bool true - -# Multiplier for view bobbing. +# Enable view bobbing and amount of view bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. view_bobbing_amount (View bobbing factor) float 1.0 -- cgit v1.2.3 From dc5bc6cac7b81ab27e0064bc25b5fd1d8d617340 Mon Sep 17 00:00:00 2001 From: Vincent Glize Date: Sat, 29 Apr 2017 12:08:16 +0200 Subject: [CSM] Add event on_place_node API lua (#5548) * [CSM] Add event on_place_node API lua --- builtin/client/register.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/client/register.lua b/builtin/client/register.lua index e6ce25654..b35ecc849 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -69,3 +69,4 @@ core.registered_on_damage_taken, core.register_on_damage_taken = make_registrati core.registered_on_formspec_input, core.register_on_formspec_input = make_registration() core.registered_on_dignode, core.register_on_dignode = make_registration() core.registered_on_punchnode, core.register_on_punchnode = make_registration() +core.registered_on_placenode, core.register_on_placenode = make_registration() -- cgit v1.2.3 From 21e0a049f81eb0d34adaf45646b11569eeadec52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Fri, 5 May 2017 13:47:11 +0200 Subject: Save minetest screen width/height options when modified (#5683) * Save minetest screen width/height options when modified * Add autosave_screensize setting (default true) * Fix @SmallJoker comments --- builtin/mainmenu/tab_settings.lua | 9 ++++++++- builtin/settingtypes.txt | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index e59572a41..8a97d8334 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -190,7 +190,7 @@ local function formspec(tabview, name, tabdata) .. getSettingIndex.NodeHighlighting() .. "]" .. "dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";" .. getSettingIndex.Leaves() .. "]" .. - "box[3.75,0;3.75,3.45;#999999]" .. + "box[3.75,0;3.75,4.45;#999999]" .. "label[3.85,0.1;" .. fgettext("Texturing:") .. "]" .. "dropdown[3.85,0.55;3.85;dd_filters;" .. dd_options.filters[1] .. ";" .. getSettingIndex.Filter() .. "]" .. @@ -199,6 +199,9 @@ local function formspec(tabview, name, tabdata) "label[3.85,2.15;" .. fgettext("Antialiasing:") .. "]" .. "dropdown[3.85,2.6;3.85;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";" .. getSettingIndex.Antialiasing() .. "]" .. + "label[3.85,3.45;" .. fgettext("Screen:") .. "]" .. + "checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";" + .. dump(core.setting_getbool("autosave_screensize")) .. "]" .. "box[7.75,0;4,4.4;#999999]" .. "checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";" .. dump(core.setting_getbool("enable_shaders")) .. "]" @@ -290,6 +293,10 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) core.setting_set("connected_glass", fields["cb_connected_glass"]) return true end + if fields["cb_autosave_screensize"] then + core.setting_set("autosave_screensize", fields["cb_autosave_screensize"]) + return true + end if fields["cb_shaders"] then if (core.setting_get("video_driver") == "direct3d8" or core.setting_get("video_driver") == "direct3d9") then diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 29a96ab8e..4b82a1e0e 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -459,6 +459,9 @@ screenW (Screen width) int 800 # Height component of the initial window size. screenH (Screen height) int 600 +# Save window size automatically when modified. +autosave_screensize (Autosave Screen Size) bool true + # Fullscreen mode. fullscreen (Full screen) bool false -- cgit v1.2.3 From 5ebf8f945050e9c74a3bb6784a0844d1fb68bdff Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 6 May 2017 20:12:44 +0100 Subject: [CSM] add `on_item_use` (#5544) --- builtin/client/register.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin') diff --git a/builtin/client/register.lua b/builtin/client/register.lua index b35ecc849..6b12ddec8 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -70,3 +70,4 @@ core.registered_on_formspec_input, core.register_on_formspec_input = make_regist core.registered_on_dignode, core.register_on_dignode = make_registration() core.registered_on_punchnode, core.register_on_punchnode = make_registration() core.registered_on_placenode, core.register_on_placenode = make_registration() +core.registered_on_item_use, core.register_on_item_use = make_registration() -- cgit v1.2.3 From 07c17db11450f235b67895ce39a5aef67458107d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 3 Jul 2014 07:46:19 +0200 Subject: Add configurable key bindings for hotbar scrolling, and for changing volume. --- builtin/settingtypes.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4b82a1e0e..61c04e616 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -186,6 +186,26 @@ keymap_fastmove (Fast key) key KEY_KEY_J # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_noclip (Noclip key) key KEY_KEY_H +# Key for selecting the next item in the hotbar. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_hotbar_next (Hotbar next key) key KEY_KEY_N + +# Key for selecting the previous item in the hotbar. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_hotbar_previous (Hotbar previous key) key KEY_KEY_B + +# Key for muting the game. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_mute (Mute key) key KEY_KEY_M + +# Key for increasing the volume. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_increase_volume (Inc. volume key) key + +# Key for decreasing the volume. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_decrease_volume (Dec. volume key) key + # Key for toggling autorun. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_autorun (Autorun key) key -- cgit v1.2.3 From 43d1f375d18a2fbc547a9b4f23d1354d645856ca Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Fri, 12 Dec 2014 14:49:19 -0500 Subject: Use a settings object for the main settings This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table. --- builtin/common/misc_helpers.lua | 6 +- builtin/fstk/tabview.lua | 2 +- builtin/game/auth.lua | 6 +- builtin/game/chatcommands.lua | 20 ++--- builtin/game/deprecated.lua | 21 +++++ builtin/game/forceloading.lua | 2 +- builtin/game/init.lua | 2 +- builtin/game/item.lua | 2 +- builtin/game/item_entity.lua | 2 +- builtin/game/misc.lua | 2 +- builtin/game/statbars.lua | 2 +- builtin/game/static_spawn.lua | 4 +- builtin/init.lua | 2 +- builtin/mainmenu/common.lua | 14 ++-- builtin/mainmenu/dlg_config_world.lua | 4 +- builtin/mainmenu/dlg_create_world.lua | 14 ++-- builtin/mainmenu/dlg_settings_advanced.lua | 32 ++++---- builtin/mainmenu/init.lua | 8 +- builtin/mainmenu/store.lua | 6 +- builtin/mainmenu/tab_multiplayer.lua | 32 ++++---- builtin/mainmenu/tab_server.lua | 34 ++++---- builtin/mainmenu/tab_settings.lua | 120 ++++++++++++++--------------- builtin/mainmenu/tab_simple_main.lua | 30 ++++---- builtin/mainmenu/tab_singleplayer.lua | 18 ++--- builtin/mainmenu/tab_texturepacks.lua | 8 +- builtin/mainmenu/textures.lua | 6 +- builtin/profiler/init.lua | 12 ++- builtin/profiler/instrumentation.lua | 18 ++--- builtin/profiler/reporter.lua | 6 +- builtin/profiler/sampling.lua | 2 +- 30 files changed, 231 insertions(+), 206 deletions(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index fc284c843..1ca400688 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -463,7 +463,7 @@ if INIT == "game" then core.rotate_node = function(itemstack, placer, pointed_thing) core.rotate_and_place(itemstack, placer, pointed_thing, - core.setting_getbool("creative_mode"), + core.settings:get_bool("creative_mode"), {invert_wall = placer:get_player_control().sneak}) return itemstack end @@ -642,8 +642,8 @@ end local ESCAPE_CHAR = string.char(0x1b) --- Client-sided mods don't have access to getbool -if core.setting_getbool and core.setting_getbool("disable_escape_sequences") then +-- Client-side mods don't have access to settings +if core.settings and core.settings:get_bool("disable_escape_sequences") then function core.get_color_escape_sequence(color) return "" diff --git a/builtin/fstk/tabview.lua b/builtin/fstk/tabview.lua index 72551afd7..3715e231b 100644 --- a/builtin/fstk/tabview.lua +++ b/builtin/fstk/tabview.lua @@ -167,7 +167,7 @@ local function switch_to_tab(self, index) self.current_tab = self.tablist[index].name if (self.autosave_tab) then - core.setting_set(self.name .. "_LAST",self.current_tab) + core.settings:set(self.name .. "_LAST",self.current_tab) end -- call for tab to enter diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua index 46fe3d342..8cb4ebf57 100644 --- a/builtin/game/auth.lua +++ b/builtin/game/auth.lua @@ -106,7 +106,7 @@ core.builtin_auth_handler = { end end -- For the admin, give everything - elseif name == core.setting_get("name") then + elseif name == core.settings:get("name") then for priv, def in pairs(core.registered_privileges) do privileges[priv] = true end @@ -125,7 +125,7 @@ core.builtin_auth_handler = { core.log('info', "Built-in authentication handler adding player '"..name.."'") core.auth_table[name] = { password = password, - privileges = core.string_to_privs(core.setting_get("default_privs")), + privileges = core.string_to_privs(core.settings:get("default_privs")), last_login = os.time(), } save_auth_file() @@ -148,7 +148,7 @@ core.builtin_auth_handler = { if not core.auth_table[name] then core.builtin_auth_handler.create_auth(name, core.get_password_hash(name, - core.setting_get("default_password"))) + core.settings:get("default_password"))) end core.auth_table[name].privileges = privileges core.notify_authentication_modified(name) diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index cbf75c1bc..b792a01cd 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -39,7 +39,7 @@ core.register_on_chat_message(function(name, message) return true -- Handled chat message end) -if core.setting_getbool("profiler.load") then +if core.settings:get_bool("profiler.load") then -- Run after register_chatcommand and its register_on_chat_message -- Before any chattcommands that should be profiled profiler.init_chatcommand() @@ -82,7 +82,7 @@ core.register_chatcommand("me", { core.register_chatcommand("admin", { description = "Show the name of the server owner", func = function(name) - local admin = minetest.setting_get("name") + local admin = minetest.settings:get("name") if admin then return true, "The administrator of this server is "..admin.."." else @@ -119,7 +119,7 @@ local function handle_grant_command(caller, grantname, grantprivstr) local privs = core.get_player_privs(grantname) local privs_unknown = "" local basic_privs = - core.string_to_privs(core.setting_get("basic_privs") or "interact,shout") + core.string_to_privs(core.settings:get("basic_privs") or "interact,shout") for priv, _ in pairs(grantprivs) do if not basic_privs[priv] and not caller_privs.privs then return false, "Your privileges are insufficient." @@ -185,7 +185,7 @@ core.register_chatcommand("revoke", { local revoke_privs = core.string_to_privs(revoke_priv_str) local privs = core.get_player_privs(revoke_name) local basic_privs = - core.string_to_privs(core.setting_get("basic_privs") or "interact,shout") + core.string_to_privs(core.settings:get("basic_privs") or "interact,shout") for priv, _ in pairs(revoke_privs) do if not basic_privs[priv] and not core.check_player_privs(name, {privs=true}) then @@ -419,20 +419,20 @@ core.register_chatcommand("set", { func = function(name, param) local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)") if arg and arg == "-n" and setname and setvalue then - core.setting_set(setname, setvalue) + core.settings:set(setname, setvalue) return true, setname .. " = " .. setvalue end local setname, setvalue = string.match(param, "([^ ]+) (.+)") if setname and setvalue then - if not core.setting_get(setname) then + if not core.settings:get(setname) then return false, "Failed. Use '/set -n ' to create a new setting." end - core.setting_set(setname, setvalue) + core.settings:set(setname, setvalue) return true, setname .. " = " .. setvalue end local setname = string.match(param, "([^ ]+)") if setname then - local setvalue = core.setting_get(setname) + local setvalue = core.settings:get(setname) if not setvalue then setvalue = "" end @@ -667,7 +667,7 @@ core.register_chatcommand("rollback_check", { .. " seconds = 86400 = 24h, limit = 5", privs = {rollback=true}, func = function(name, param) - if not core.setting_getbool("enable_rollback_recording") then + if not core.settings:get_bool("enable_rollback_recording") then return false, "Rollback functions are disabled." end local range, seconds, limit = @@ -718,7 +718,7 @@ core.register_chatcommand("rollback", { description = "Revert actions of a player. Default for is 60", privs = {rollback=true}, func = function(name, param) - if not core.setting_getbool("enable_rollback_recording") then + if not core.settings:get_bool("enable_rollback_recording") then return false, "Rollback functions are disabled." end local target_name, seconds = string.match(param, ":([^ ]+) *(%d*)") diff --git a/builtin/game/deprecated.lua b/builtin/game/deprecated.lua index cd1cf5e2d..1a9a96f2a 100644 --- a/builtin/game/deprecated.lua +++ b/builtin/game/deprecated.lua @@ -49,3 +49,24 @@ setmetatable(core.env, { function core.rollback_get_last_node_actor(pos, range, seconds) return core.rollback_get_node_actions(pos, range, seconds, 1)[1] end + +-- +-- core.setting_* +-- + +local settings = core.settings + +local function setting_proxy(name) + return function(...) + core.log("deprecated", "WARNING: minetest.setting_* ".. + "functions are deprecated. ".. + "Use methods on the minetest.settings object.") + return settings[name](settings, ...) + end +end + +core.setting_set = setting_proxy("set") +core.setting_get = setting_proxy("get") +core.setting_setbool = setting_proxy("set_bool") +core.setting_getbool = setting_proxy("get_bool") +core.setting_save = setting_proxy("write") diff --git a/builtin/game/forceloading.lua b/builtin/game/forceloading.lua index 8a05de36c..7c5537e85 100644 --- a/builtin/game/forceloading.lua +++ b/builtin/game/forceloading.lua @@ -40,7 +40,7 @@ function core.forceload_block(pos, transient) elseif other_table[hash] ~= nil then relevant_table[hash] = 1 else - if total_forceloaded >= (tonumber(core.setting_get("max_forceloaded_blocks")) or 16) then + if total_forceloaded >= (tonumber(core.settings:get("max_forceloaded_blocks")) or 16) then return false end total_forceloaded = total_forceloaded+1 diff --git a/builtin/game/init.lua b/builtin/game/init.lua index 3e192a30a..e2635f07a 100644 --- a/builtin/game/init.lua +++ b/builtin/game/init.lua @@ -13,7 +13,7 @@ dofile(gamepath.."constants.lua") assert(loadfile(gamepath.."item.lua"))(builtin_shared) dofile(gamepath.."register.lua") -if core.setting_getbool("profiler.load") then +if core.settings:get_bool("profiler.load") then profiler = dofile(scriptpath.."profiler"..DIR_DELIM.."init.lua") end diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 671a994c7..e36745f93 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -483,7 +483,7 @@ function core.node_dig(pos, node, digger) wielded = wdef.after_use(wielded, digger, node, dp) or wielded else -- Wear out tool - if not core.setting_getbool("creative_mode") then + if not core.settings:get_bool("creative_mode") then wielded:add_wear(dp.wear) if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5}) diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index 7b8247116..c0e36be2d 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -14,7 +14,7 @@ end -- If item_entity_ttl is not set, enity will have default life time -- Setting it to -1 disables the feature -local time_to_live = tonumber(core.setting_get("item_entity_ttl")) +local time_to_live = tonumber(core.settings:get("item_entity_ttl")) if not time_to_live then time_to_live = 900 end diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index a3eb26ac2..bfe407b9d 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -121,7 +121,7 @@ function core.get_node_group(name, group) end function core.setting_get_pos(name) - local value = core.setting_get(name) + local value = core.settings:get(name) if not value then return nil end diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index 4e7781e53..6aa106140 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -1,5 +1,5 @@ -- cache setting -local enable_damage = core.setting_getbool("enable_damage") == true +local enable_damage = core.settings:get_bool("enable_damage") local health_bar_definition = { diff --git a/builtin/game/static_spawn.lua b/builtin/game/static_spawn.lua index 100334226..b1157b42e 100644 --- a/builtin/game/static_spawn.lua +++ b/builtin/game/static_spawn.lua @@ -1,10 +1,10 @@ -- Minetest: builtin/static_spawn.lua local function warn_invalid_static_spawnpoint() - if core.setting_get("static_spawnpoint") and + if core.settings:get("static_spawnpoint") and not core.setting_get_pos("static_spawnpoint") then core.log("error", "The static_spawnpoint setting is invalid: \"".. - core.setting_get("static_spawnpoint").."\"") + core.settings:get("static_spawnpoint").."\"") end end diff --git a/builtin/init.lua b/builtin/init.lua index c9fa70fc7..356e119fb 100644 --- a/builtin/init.lua +++ b/builtin/init.lua @@ -38,7 +38,7 @@ dofile(commonpath .. "misc_helpers.lua") if INIT == "game" then dofile(gamepath .. "init.lua") elseif INIT == "mainmenu" then - local mm_script = core.setting_get("main_menu_script") + local mm_script = core.settings:get("main_menu_script") if mm_script and mm_script ~= "" then dofile(mm_script) else diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 57950c62c..294e1a621 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -43,10 +43,10 @@ end local function configure_selected_world_params(idx) local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path) if worldconfig.creative_mode then - core.setting_set("creative_mode", worldconfig.creative_mode) + core.settings:set("creative_mode", worldconfig.creative_mode) end if worldconfig.enable_damage then - core.setting_set("enable_damage", worldconfig.enable_damage) + core.settings:set("enable_damage", worldconfig.enable_damage) end end @@ -164,8 +164,8 @@ end -------------------------------------------------------------------------------- os.tempfolder = function() - if core.setting_get("TMPFolder") then - return core.setting_get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000) + if core.settings:get("TMPFolder") then + return core.settings:get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000) end local filetocheck = os.tmpname() @@ -206,7 +206,7 @@ function menu_handle_key_up_down(fields, textlist, settingname) oldidx < menudata.worldlist:size() then newidx = oldidx + 1 end - core.setting_set(settingname, menudata.worldlist:get_raw_index(newidx)) + core.settings:set(settingname, menudata.worldlist:get_raw_index(newidx)) configure_selected_world_params(newidx) return true end @@ -328,9 +328,9 @@ function menu_worldmt_legacy(selected) for _, mode_name in pairs(modes_names) do local mode_val = menu_worldmt(selected, mode_name) if mode_val then - core.setting_set(mode_name, mode_val) + core.settings:set(mode_name, mode_val) else - menu_worldmt(selected, mode_name, core.setting_get(mode_name)) + menu_worldmt(selected, mode_name, core.settings:get(mode_name)) end end end diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index 619c927c5..3e5ba16eb 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -123,7 +123,7 @@ local function handle_buttons(this, fields) if fields["world_config_modlist"] ~= nil then local event = core.explode_table_event(fields["world_config_modlist"]) this.data.selected_mod = event.row - core.setting_set("world_config_selected_mod", event.row) + core.settings:set("world_config_selected_mod", event.row) if event.type == "DCL" then enable_mod(this) @@ -227,7 +227,7 @@ function create_configure_world_dlg(worldidx) handle_buttons, nil) - dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod")) + dlg.data.selected_mod = tonumber(core.settings:get("world_config_selected_mod")) if dlg.data.selected_mod == nil then dlg.data.selected_mod = 0 end diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index 477b8bcb9..e9ca7799f 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -18,8 +18,8 @@ local function create_world_formspec(dialogdata) local mapgens = core.get_mapgen_names() - local current_seed = core.setting_get("fixed_map_seed") or "" - local current_mg = core.setting_get("mg_name") + local current_seed = core.settings:get("fixed_map_seed") or "" + local current_mg = core.settings:get("mg_name") local mglist = "" local selindex = 1 @@ -33,7 +33,7 @@ local function create_world_formspec(dialogdata) end mglist = mglist:sub(1, -2) - local gameid = core.setting_get("menu_last_game") + local gameid = core.settings:get("menu_last_game") local game, gameidx = nil , 0 if gameid ~= nil then @@ -90,10 +90,10 @@ local function create_world_buttonhandler(this, fields) local message = nil - core.setting_set("fixed_map_seed", fields["te_seed"]) + core.settings:set("fixed_map_seed", fields["te_seed"]) if not menudata.worldlist:uid_exists_raw(worldname) then - core.setting_set("mg_name",fields["dd_mapgen"]) + core.settings:set("mg_name",fields["dd_mapgen"]) message = core.create_world(worldname,gameindex) else message = fgettext("A world named \"$1\" already exists", worldname) @@ -102,13 +102,13 @@ local function create_world_buttonhandler(this, fields) if message ~= nil then gamedata.errormessage = message else - core.setting_set("menu_last_game",gamemgr.games[gameindex].id) + core.settings:set("menu_last_game",gamemgr.games[gameindex].id) if this.data.update_worldlist_filter then menudata.worldlist:set_filtercriteria(gamemgr.games[gameindex].id) mm_texture.update("singleplayer", gamemgr.games[gameindex].id) end menudata.worldlist:refresh() - core.setting_set("mainmenu_last_selected_world", + core.settings:set("mainmenu_last_selected_world", menudata.worldlist:raw_index_by_uid(worldname)) end else diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index c63eb972e..206ce1620 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -423,7 +423,7 @@ local settings = full_settings local selected_setting = 1 local function get_current_value(setting) - local value = core.setting_get(setting.name) + local value = core.settings:get(setting.name) if value == nil then value = setting.default end @@ -539,11 +539,11 @@ local function handle_change_setting_buttons(this, fields) if setting.type == "bool" then local new_value = fields["dd_setting_value"] -- Note: new_value is the actual (translated) value shown in the dropdown - core.setting_setbool(setting.name, new_value == fgettext("Enabled")) + core.settings:set_bool(setting.name, new_value == fgettext("Enabled")) elseif setting.type == "enum" then local new_value = fields["dd_setting_value"] - core.setting_set(setting.name, new_value) + core.settings:set(setting.name, new_value) elseif setting.type == "int" then local new_value = tonumber(fields["te_setting_value"]) @@ -565,7 +565,7 @@ local function handle_change_setting_buttons(this, fields) core.update_formspec(this:get_formspec()) return true end - core.setting_set(setting.name, new_value) + core.settings:set(setting.name, new_value) elseif setting.type == "float" then local new_value = tonumber(fields["te_setting_value"]) @@ -575,7 +575,7 @@ local function handle_change_setting_buttons(this, fields) core.update_formspec(this:get_formspec()) return true end - core.setting_set(setting.name, new_value) + core.settings:set(setting.name, new_value) elseif setting.type == "flags" then local new_value = fields["te_setting_value"] @@ -589,13 +589,13 @@ local function handle_change_setting_buttons(this, fields) return true end end - core.setting_set(setting.name, new_value) + core.settings:set(setting.name, new_value) else local new_value = fields["te_setting_value"] - core.setting_set(setting.name, new_value) + core.settings:set(setting.name, new_value) end - core.setting_save() + core.settings:write() this:delete() return true end @@ -629,7 +629,7 @@ local function create_settings_formspec(tabview, name, tabdata) local current_level = 0 for _, entry in ipairs(settings) do local name - if not core.setting_getbool("main_menu_technical_settings") and entry.readable_name then + if not core.settings:get_bool("main_menu_technical_settings") and entry.readable_name then name = fgettext_ne(entry.readable_name) else name = entry.name @@ -666,7 +666,7 @@ local function create_settings_formspec(tabview, name, tabdata) "button[10,6;2,1;btn_edit;" .. fgettext("Edit") .. "]" .. "button[7,6;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" .. "checkbox[0,5.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";" - .. dump(core.setting_getbool("main_menu_technical_settings")) .. "]" + .. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]" return formspec end @@ -680,8 +680,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) local setting = settings[selected_setting] if setting and setting.type == "bool" then local current_value = get_current_value(setting) - core.setting_setbool(setting.name, not core.is_yes(current_value)) - core.setting_save() + core.settings:set_bool(setting.name, not core.is_yes(current_value)) + core.settings:write() return true else list_enter = true @@ -736,8 +736,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) if fields["btn_restore"] then local setting = settings[selected_setting] if setting and setting.type ~= "category" then - core.setting_set(setting.name, setting.default) - core.setting_save() + core.settings:set(setting.name, setting.default) + core.settings:write() core.update_formspec(this:get_formspec()) end return true @@ -749,8 +749,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) end if fields["cb_tech_settings"] then - core.setting_set("main_menu_technical_settings", fields["cb_tech_settings"]) - core.setting_save() + core.settings:set("main_menu_technical_settings", fields["cb_tech_settings"]) + core.settings:write() core.update_formspec(this:get_formspec()) return true end diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 79e6d5c02..492bb22d6 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -119,9 +119,9 @@ local function init_globals() menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic) menudata.worldlist:set_sortmode("alphabetic") - if not core.setting_get("menu_last_game") then - local default_game = core.setting_get("default_game") or "minetest" - core.setting_set("menu_last_game", default_game) + if not core.settings:get("menu_last_game") then + local default_game = core.settings:get("default_game") or "minetest" + core.settings:set("menu_last_game", default_game) end mm_texture.init() @@ -149,7 +149,7 @@ local function init_globals() tv_main:set_fixed_size(false) if PLATFORM ~= "Android" then - tv_main:set_tab(core.setting_get("maintab_LAST")) + tv_main:set_tab(core.settings:get("maintab_LAST")) end ui.set_default("maintab") tv_main:show() diff --git a/builtin/mainmenu/store.lua b/builtin/mainmenu/store.lua index ad861082d..59391f8bc 100644 --- a/builtin/mainmenu/store.lua +++ b/builtin/mainmenu/store.lua @@ -233,14 +233,14 @@ function modstore.handle_buttons(parent, fields, name, data) if not core.handle_async( function(param) - local fullurl = core.setting_get("modstore_download_url") .. + local fullurl = core.settings:get("modstore_download_url") .. param.moddetails.download_url if param.version ~= nil then local found = false for i=1,#param.moddetails.versions, 1 do if param.moddetails.versions[i].date:sub(1,10) == param.version then - fullurl = core.setting_get("modstore_download_url") .. + fullurl = core.settings:get("modstore_download_url") .. param.moddetails.versions[i].download_url found = true end @@ -400,7 +400,7 @@ function modstore.getscreenshot(ypos,listentry) listentry.texturename = "in progress" --prepare url and filename - local fullurl = core.setting_get("modstore_download_url") .. + local fullurl = core.settings:get("modstore_download_url") .. listentry.details.screenshot_url local filename = os.tempfolder() .. "_MID_" .. listentry.id diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua index 0f4921b03..a9b2b35fe 100644 --- a/builtin/mainmenu/tab_multiplayer.lua +++ b/builtin/mainmenu/tab_multiplayer.lua @@ -39,14 +39,14 @@ local function get_formspec(tabview, name, tabdata) -- Address / Port "label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" .. "field[8,0.65;3.25,0.5;te_address;;" .. - core.formspec_escape(core.setting_get("address")) .. "]" .. + core.formspec_escape(core.settings:get("address")) .. "]" .. "field[11.1,0.65;1.4,0.5;te_port;;" .. - core.formspec_escape(core.setting_get("remote_port")) .. "]" .. + core.formspec_escape(core.settings:get("remote_port")) .. "]" .. -- Name / Password "label[7.75,0.95;" .. fgettext("Name / Password") .. "]" .. "field[8,1.85;2.9,0.5;te_name;;" .. - core.formspec_escape(core.setting_get("name")) .. "]" .. + core.formspec_escape(core.settings:get("name")) .. "]" .. "pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" .. -- Description Background @@ -135,7 +135,7 @@ local function main_button_handler(tabview, fields, name, tabdata) if fields.te_name then gamedata.playername = fields.te_name - core.setting_set("name", fields.te_name) + core.settings:set("name", fields.te_name) end if fields.favourites then @@ -163,8 +163,8 @@ local function main_button_handler(tabview, fields, name, tabdata) gamedata.serverdescription = fav.description if gamedata.address and gamedata.port then - core.setting_set("address", gamedata.address) - core.setting_set("remote_port", gamedata.port) + core.settings:set("address", gamedata.address) + core.settings:set("remote_port", gamedata.port) core.start() end end @@ -187,8 +187,8 @@ local function main_button_handler(tabview, fields, name, tabdata) end if address and port then - core.setting_set("address", address) - core.setting_set("remote_port", port) + core.settings:set("address", address) + core.settings:set("remote_port", port) end tabdata.fav_selected = event.row end @@ -219,8 +219,8 @@ local function main_button_handler(tabview, fields, name, tabdata) local port = fav.port gamedata.serverdescription = fav.description if address and port then - core.setting_set("address", address) - core.setting_set("remote_port", port) + core.settings:set("address", address) + core.settings:set("remote_port", port) end tabdata.fav_selected = fav_idx @@ -235,8 +235,8 @@ local function main_button_handler(tabview, fields, name, tabdata) asyncOnlineFavourites() tabdata.fav_selected = nil - core.setting_set("address", "") - core.setting_set("remote_port", "30000") + core.settings:set("address", "") + core.settings:set("remote_port", "30000") return true end @@ -293,8 +293,8 @@ local function main_button_handler(tabview, fields, name, tabdata) end) menudata.search_result = search_result local first_server = search_result[1] - core.setting_set("address", first_server.address) - core.setting_set("remote_port", first_server.port) + core.settings:set("address", first_server.address) + core.settings:set("remote_port", first_server.port) end return true end @@ -325,8 +325,8 @@ local function main_button_handler(tabview, fields, name, tabdata) gamedata.serverdescription = "" end - core.setting_set("address", fields.te_address) - core.setting_set("remote_port", fields.te_port) + core.settings:set("address", fields.te_address) + core.settings:set("remote_port", fields.te_port) core.start() return true diff --git a/builtin/mainmenu/tab_server.lua b/builtin/mainmenu/tab_server.lua index be57ad7ef..8f25ce871 100644 --- a/builtin/mainmenu/tab_server.lua +++ b/builtin/mainmenu/tab_server.lua @@ -19,7 +19,7 @@ local function get_formspec(tabview, name, tabdata) local index = menudata.worldlist:get_current_index( - tonumber(core.setting_get("mainmenu_last_selected_world")) + tonumber(core.settings:get("mainmenu_last_selected_world")) ) local retval = @@ -29,29 +29,29 @@ local function get_formspec(tabview, name, tabdata) "button[8.5,5;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" .. "label[4,-0.25;" .. fgettext("Select World:") .. "]" .. "checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" .. - dump(core.setting_getbool("creative_mode")) .. "]" .. + dump(core.settings:get_bool("creative_mode")) .. "]" .. "checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" .. - dump(core.setting_getbool("enable_damage")) .. "]" .. + dump(core.settings:get_bool("enable_damage")) .. "]" .. "checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";" .. - dump(core.setting_getbool("server_announce")) .. "]" .. + dump(core.settings:get_bool("server_announce")) .. "]" .. "label[0.25,2.2;" .. fgettext("Name/Password") .. "]" .. "field[0.55,3.2;3.5,0.5;te_playername;;" .. - core.formspec_escape(core.setting_get("name")) .. "]" .. + core.formspec_escape(core.settings:get("name")) .. "]" .. "pwdfield[0.55,4;3.5,0.5;te_passwd;]" - local bind_addr = core.setting_get("bind_address") + local bind_addr = core.settings:get("bind_address") if bind_addr ~= nil and bind_addr ~= "" then retval = retval .. "field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" .. - core.formspec_escape(core.setting_get("bind_address")) .. "]" .. + core.formspec_escape(core.settings:get("bind_address")) .. "]" .. "field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" .. - core.formspec_escape(core.setting_get("port")) .. "]" + core.formspec_escape(core.settings:get("port")) .. "]" else retval = retval .. "field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" .. - core.formspec_escape(core.setting_get("port")) .. "]" + core.formspec_escape(core.settings:get("port")) .. "]" end - + retval = retval .. "textlist[4,0.25;7.5,3.7;srv_worlds;" .. menu_render_worldlist() .. @@ -75,7 +75,7 @@ local function main_button_handler(this, fields, name, tabdata) world_doubleclick = true end if event.type == "CHG" then - core.setting_set("mainmenu_last_selected_world", + core.settings:set("mainmenu_last_selected_world", menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds"))) return true end @@ -86,7 +86,7 @@ local function main_button_handler(this, fields, name, tabdata) end if fields["cb_creative_mode"] then - core.setting_set("creative_mode", fields["cb_creative_mode"]) + core.settings:set("creative_mode", fields["cb_creative_mode"]) local selected = core.get_textlist_index("srv_worlds") menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"]) @@ -94,7 +94,7 @@ local function main_button_handler(this, fields, name, tabdata) end if fields["cb_enable_damage"] then - core.setting_set("enable_damage", fields["cb_enable_damage"]) + core.settings:set("enable_damage", fields["cb_enable_damage"]) local selected = core.get_textlist_index("srv_worlds") menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"]) @@ -102,7 +102,7 @@ local function main_button_handler(this, fields, name, tabdata) end if fields["cb_server_announce"] then - core.setting_set("server_announce", fields["cb_server_announce"]) + core.settings:set("server_announce", fields["cb_server_announce"]) local selected = core.get_textlist_index("srv_worlds") menu_worldmt(selected, "server_announce", fields["cb_server_announce"]) @@ -120,16 +120,16 @@ local function main_button_handler(this, fields, name, tabdata) gamedata.port = fields["te_serverport"] gamedata.address = "" - core.setting_set("port",gamedata.port) + core.settings:set("port",gamedata.port) if fields["te_serveraddr"] ~= nil then - core.setting_set("bind_address",fields["te_serveraddr"]) + core.settings:set("bind_address",fields["te_serveraddr"]) end --update last game local world = menudata.worldlist:get_raw_element(gamedata.selected_world) if world then local game, index = gamemgr.find_by_gameid(world.gameid) - core.setting_set("menu_last_game", game.id) + core.settings:set("menu_last_game", game.id) end core.start() diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index 8a97d8334..69683eaa3 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -70,39 +70,39 @@ local dd_options = { local getSettingIndex = { Leaves = function() - local style = core.setting_get("leaves_style") + local style = core.settings:get("leaves_style") for idx, name in pairs(dd_options.leaves[2]) do if style == name then return idx end end return 1 end, NodeHighlighting = function() - local style = core.setting_get("node_highlighting") + local style = core.settings:get("node_highlighting") for idx, name in pairs(dd_options.node_highlighting[2]) do if style == name then return idx end end return 1 end, Filter = function() - if core.setting_get(dd_options.filters[2][3]) == "true" then + if core.settings:get(dd_options.filters[2][3]) == "true" then return 3 - elseif core.setting_get(dd_options.filters[2][3]) == "false" and - core.setting_get(dd_options.filters[2][2]) == "true" then + elseif core.settings:get(dd_options.filters[2][3]) == "false" and + core.settings:get(dd_options.filters[2][2]) == "true" then return 2 end return 1 end, Mipmap = function() - if core.setting_get(dd_options.mipmap[2][3]) == "true" then + if core.settings:get(dd_options.mipmap[2][3]) == "true" then return 3 - elseif core.setting_get(dd_options.mipmap[2][3]) == "false" and - core.setting_get(dd_options.mipmap[2][2]) == "true" then + elseif core.settings:get(dd_options.mipmap[2][3]) == "false" and + core.settings:get(dd_options.mipmap[2][2]) == "true" then return 2 end return 1 end, Antialiasing = function() - local antialiasing_setting = core.setting_get("fsaa") + local antialiasing_setting = core.settings:get("fsaa") for i = 1, #dd_options.antialiasing[2] do if antialiasing_setting == dd_options.antialiasing[2][i] then return i @@ -177,15 +177,15 @@ local function formspec(tabview, name, tabdata) local tab_string = "box[0,0;3.5,4.5;#999999]" .. "checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";" - .. dump(core.setting_getbool("smooth_lighting")) .. "]" .. + .. dump(core.settings:get_bool("smooth_lighting")) .. "]" .. "checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";" - .. dump(core.setting_getbool("enable_particles")) .. "]" .. + .. dump(core.settings:get_bool("enable_particles")) .. "]" .. "checkbox[0.25,1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";" - .. dump(core.setting_getbool("enable_3d_clouds")) .. "]" .. + .. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" .. "checkbox[0.25,1.5;cb_opaque_water;" .. fgettext("Opaque Water") .. ";" - .. dump(core.setting_getbool("opaque_water")) .. "]" .. + .. dump(core.settings:get_bool("opaque_water")) .. "]" .. "checkbox[0.25,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";" - .. dump(core.setting_getbool("connected_glass")) .. "]" .. + .. dump(core.settings:get_bool("connected_glass")) .. "]" .. "dropdown[0.25,2.8;3.3;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";" .. getSettingIndex.NodeHighlighting() .. "]" .. "dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";" @@ -201,10 +201,10 @@ local function formspec(tabview, name, tabdata) .. getSettingIndex.Antialiasing() .. "]" .. "label[3.85,3.45;" .. fgettext("Screen:") .. "]" .. "checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";" - .. dump(core.setting_getbool("autosave_screensize")) .. "]" .. + .. dump(core.settings:get_bool("autosave_screensize")) .. "]" .. "box[7.75,0;4,4.4;#999999]" .. "checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";" - .. dump(core.setting_getbool("enable_shaders")) .. "]" + .. dump(core.settings:get_bool("enable_shaders")) .. "]" if PLATFORM == "Android" then tab_string = tab_string .. @@ -221,29 +221,29 @@ local function formspec(tabview, name, tabdata) .. fgettext("Advanced Settings") .. "]" - if core.setting_get("touchscreen_threshold") ~= nil then + if core.settings:get("touchscreen_threshold") ~= nil then tab_string = tab_string .. "label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" .. "dropdown[3.85,4.55;3.85;dd_touchthreshold;0,10,20,30,40,50;" .. - ((tonumber(core.setting_get("touchscreen_threshold")) / 10) + 1) .. "]" + ((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) .. "]" end - if core.setting_getbool("enable_shaders") then + if core.settings:get_bool("enable_shaders") then tab_string = tab_string .. "checkbox[8,0.5;cb_bumpmapping;" .. fgettext("Bump Mapping") .. ";" - .. dump(core.setting_getbool("enable_bumpmapping")) .. "]" .. + .. dump(core.settings:get_bool("enable_bumpmapping")) .. "]" .. "checkbox[8,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";" - .. dump(core.setting_getbool("tone_mapping")) .. "]" .. + .. dump(core.settings:get_bool("tone_mapping")) .. "]" .. "checkbox[8,1.5;cb_generate_normalmaps;" .. fgettext("Normal Mapping") .. ";" - .. dump(core.setting_getbool("generate_normalmaps")) .. "]" .. + .. dump(core.settings:get_bool("generate_normalmaps")) .. "]" .. "checkbox[8,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";" - .. dump(core.setting_getbool("enable_parallax_occlusion")) .. "]" .. + .. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" .. "checkbox[8,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";" - .. dump(core.setting_getbool("enable_waving_water")) .. "]" .. + .. dump(core.settings:get_bool("enable_waving_water")) .. "]" .. "checkbox[8,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";" - .. dump(core.setting_getbool("enable_waving_leaves")) .. "]" .. + .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" .. "checkbox[8,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";" - .. dump(core.setting_getbool("enable_waving_plants")) .. "]" + .. dump(core.settings:get_bool("enable_waving_plants")) .. "]" else tab_string = tab_string .. "tablecolumns[color;text]" .. @@ -274,64 +274,64 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) return true end if fields["cb_smooth_lighting"] then - core.setting_set("smooth_lighting", fields["cb_smooth_lighting"]) + core.settings:set("smooth_lighting", fields["cb_smooth_lighting"]) return true end if fields["cb_particles"] then - core.setting_set("enable_particles", fields["cb_particles"]) + core.settings:set("enable_particles", fields["cb_particles"]) return true end if fields["cb_3d_clouds"] then - core.setting_set("enable_3d_clouds", fields["cb_3d_clouds"]) + core.settings:set("enable_3d_clouds", fields["cb_3d_clouds"]) return true end if fields["cb_opaque_water"] then - core.setting_set("opaque_water", fields["cb_opaque_water"]) + core.settings:set("opaque_water", fields["cb_opaque_water"]) return true end if fields["cb_connected_glass"] then - core.setting_set("connected_glass", fields["cb_connected_glass"]) + core.settings:set("connected_glass", fields["cb_connected_glass"]) return true end if fields["cb_autosave_screensize"] then - core.setting_set("autosave_screensize", fields["cb_autosave_screensize"]) + core.settings:set("autosave_screensize", fields["cb_autosave_screensize"]) return true end if fields["cb_shaders"] then - if (core.setting_get("video_driver") == "direct3d8" or - core.setting_get("video_driver") == "direct3d9") then - core.setting_set("enable_shaders", "false") + if (core.settings:get("video_driver") == "direct3d8" or + core.settings:get("video_driver") == "direct3d9") then + core.settings:set("enable_shaders", "false") gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.") else - core.setting_set("enable_shaders", fields["cb_shaders"]) + core.settings:set("enable_shaders", fields["cb_shaders"]) end return true end if fields["cb_bumpmapping"] then - core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"]) + core.settings:set("enable_bumpmapping", fields["cb_bumpmapping"]) return true end if fields["cb_tonemapping"] then - core.setting_set("tone_mapping", fields["cb_tonemapping"]) + core.settings:set("tone_mapping", fields["cb_tonemapping"]) return true end if fields["cb_generate_normalmaps"] then - core.setting_set("generate_normalmaps", fields["cb_generate_normalmaps"]) + core.settings:set("generate_normalmaps", fields["cb_generate_normalmaps"]) return true end if fields["cb_parallax"] then - core.setting_set("enable_parallax_occlusion", fields["cb_parallax"]) + core.settings:set("enable_parallax_occlusion", fields["cb_parallax"]) return true end if fields["cb_waving_water"] then - core.setting_set("enable_waving_water", fields["cb_waving_water"]) + core.settings:set("enable_waving_water", fields["cb_waving_water"]) return true end if fields["cb_waving_leaves"] then - core.setting_set("enable_waving_leaves", fields["cb_waving_leaves"]) + core.settings:set("enable_waving_leaves", fields["cb_waving_leaves"]) end if fields["cb_waving_plants"] then - core.setting_set("enable_waving_plants", fields["cb_waving_plants"]) + core.settings:set("enable_waving_plants", fields["cb_waving_plants"]) return true end if fields["btn_change_keys"] then @@ -339,7 +339,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) return true end if fields["cb_touchscreen_target"] then - core.setting_set("touchtarget", fields["cb_touchscreen_target"]) + core.settings:set("touchtarget", fields["cb_touchscreen_target"]) return true end if fields["btn_reset_singleplayer"] then @@ -352,49 +352,49 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) for i = 1, #labels.leaves do if fields["dd_leaves_style"] == labels.leaves[i] then - core.setting_set("leaves_style", dd_options.leaves[2][i]) + core.settings:set("leaves_style", dd_options.leaves[2][i]) ddhandled = true end end for i = 1, #labels.node_highlighting do if fields["dd_node_highlighting"] == labels.node_highlighting[i] then - core.setting_set("node_highlighting", dd_options.node_highlighting[2][i]) + core.settings:set("node_highlighting", dd_options.node_highlighting[2][i]) ddhandled = true end end if fields["dd_filters"] == labels.filters[1] then - core.setting_set("bilinear_filter", "false") - core.setting_set("trilinear_filter", "false") + core.settings:set("bilinear_filter", "false") + core.settings:set("trilinear_filter", "false") ddhandled = true elseif fields["dd_filters"] == labels.filters[2] then - core.setting_set("bilinear_filter", "true") - core.setting_set("trilinear_filter", "false") + core.settings:set("bilinear_filter", "true") + core.settings:set("trilinear_filter", "false") ddhandled = true elseif fields["dd_filters"] == labels.filters[3] then - core.setting_set("bilinear_filter", "false") - core.setting_set("trilinear_filter", "true") + core.settings:set("bilinear_filter", "false") + core.settings:set("trilinear_filter", "true") ddhandled = true end if fields["dd_mipmap"] == labels.mipmap[1] then - core.setting_set("mip_map", "false") - core.setting_set("anisotropic_filter", "false") + core.settings:set("mip_map", "false") + core.settings:set("anisotropic_filter", "false") ddhandled = true elseif fields["dd_mipmap"] == labels.mipmap[2] then - core.setting_set("mip_map", "true") - core.setting_set("anisotropic_filter", "false") + core.settings:set("mip_map", "true") + core.settings:set("anisotropic_filter", "false") ddhandled = true elseif fields["dd_mipmap"] == labels.mipmap[3] then - core.setting_set("mip_map", "true") - core.setting_set("anisotropic_filter", "true") + core.settings:set("mip_map", "true") + core.settings:set("anisotropic_filter", "true") ddhandled = true end if fields["dd_antialiasing"] then - core.setting_set("fsaa", + core.settings:set("fsaa", antialiasing_fname_to_name(fields["dd_antialiasing"])) ddhandled = true end if fields["dd_touchthreshold"] then - core.setting_set("touchscreen_threshold", fields["dd_touchthreshold"]) + core.settings:set("touchscreen_threshold", fields["dd_touchthreshold"]) ddhandled = true end diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua index 23820aab7..90a743f68 100644 --- a/builtin/mainmenu/tab_simple_main.lua +++ b/builtin/mainmenu/tab_simple_main.lua @@ -25,12 +25,12 @@ local function get_formspec(tabview, name, tabdata) local retval = "label[9.5,0;".. fgettext("Name / Password") .. "]" .. "field[0.25,3.35;5.5,0.5;te_address;;" .. - core.formspec_escape(core.setting_get("address")) .."]" .. + core.formspec_escape(core.settings:get("address")) .."]" .. "field[5.75,3.35;2.25,0.5;te_port;;" .. - core.formspec_escape(core.setting_get("remote_port")) .."]" .. + core.formspec_escape(core.settings:get("remote_port")) .."]" .. "button[10,2.6;2,1.5;btn_mp_connect;".. fgettext("Connect") .. "]" .. "field[9.8,1;2.6,0.5;te_name;;" .. - core.formspec_escape(core.setting_get("name")) .."]" .. + core.formspec_escape(core.settings:get("name")) .."]" .. "pwdfield[9.8,2;2.6,0.5;te_pwd;]" @@ -89,9 +89,9 @@ local function get_formspec(tabview, name, tabdata) -- checkboxes retval = retval .. "checkbox[8.0,3.9;cb_creative;".. fgettext("Creative Mode") .. ";" .. - dump(core.setting_getbool("creative_mode")) .. "]".. + dump(core.settings:get_bool("creative_mode")) .. "]".. "checkbox[8.0,4.4;cb_damage;".. fgettext("Enable Damage") .. ";" .. - dump(core.setting_getbool("enable_damage")) .. "]" + dump(core.settings:get_bool("enable_damage")) .. "]" -- buttons retval = retval .. "button[0,3.7;8,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" .. @@ -128,8 +128,8 @@ local function main_button_handler(tabview, fields, name, tabdata) end if address and port then - core.setting_set("address", address) - core.setting_set("remote_port", port) + core.settings:set("address", address) + core.settings:set("remote_port", port) end tabdata.fav_selected = event.row end @@ -145,18 +145,18 @@ local function main_button_handler(tabview, fields, name, tabdata) asyncOnlineFavourites() tabdata.fav_selected = nil - core.setting_set("address", "") - core.setting_set("remote_port", "30000") + core.settings:set("address", "") + core.settings:set("remote_port", "30000") return true end if fields.cb_creative then - core.setting_set("creative_mode", fields.cb_creative) + core.settings:set("creative_mode", fields.cb_creative) return true end if fields.cb_damage then - core.setting_set("enable_damage", fields.cb_damage) + core.settings:set("enable_damage", fields.cb_damage) return true end @@ -186,12 +186,8 @@ local function main_button_handler(tabview, fields, name, tabdata) gamedata.selected_world = 0 - core.setting_set("address", fields.te_address) - core.setting_set("remote_port", fields.te_port) - - core.start() - return true - end + core.settings:set("address", fields.te_address) + core.settings:set("remote_port", fields.te_port) if fields.btn_config_sp_world then local configdialog = create_configure_world_dlg(1) diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua index 236de763c..c58ad4164 100644 --- a/builtin/mainmenu/tab_singleplayer.lua +++ b/builtin/mainmenu/tab_singleplayer.lua @@ -16,7 +16,7 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. local function current_game() - local last_game_id = core.setting_get("menu_last_game") + local last_game_id = core.settings:get("menu_last_game") local game, index = gamemgr.find_by_gameid(last_game_id) return game @@ -36,10 +36,10 @@ local function singleplayer_refresh_gamebar() if ("game_btnbar_" .. gamemgr.games[j].id == key) then mm_texture.update("singleplayer", gamemgr.games[j]) core.set_topleft_text(gamemgr.games[j].name) - core.setting_set("menu_last_game",gamemgr.games[j].id) + core.settings:set("menu_last_game",gamemgr.games[j].id) menudata.worldlist:set_filtercriteria(gamemgr.games[j].id) local index = filterlist.get_current_index(menudata.worldlist, - tonumber(core.setting_get("mainmenu_last_selected_world"))) + tonumber(core.settings:get("mainmenu_last_selected_world"))) if not index or index < 1 then local selected = core.get_textlist_index("sp_worlds") if selected ~= nil and selected < #menudata.worldlist:get_list() then @@ -89,7 +89,7 @@ local function get_formspec(tabview, name, tabdata) local retval = "" local index = filterlist.get_current_index(menudata.worldlist, - tonumber(core.setting_get("mainmenu_last_selected_world")) + tonumber(core.settings:get("mainmenu_last_selected_world")) ) retval = retval .. @@ -99,9 +99,9 @@ local function get_formspec(tabview, name, tabdata) "button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" .. "label[4,-0.25;".. fgettext("Select World:") .. "]".. "checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" .. - dump(core.setting_getbool("creative_mode")) .. "]".. + dump(core.settings:get_bool("creative_mode")) .. "]".. "checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" .. - dump(core.setting_getbool("enable_damage")) .. "]".. + dump(core.settings:get_bool("enable_damage")) .. "]".. "textlist[4,0.25;7.5,3.7;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" @@ -125,7 +125,7 @@ local function main_button_handler(this, fields, name, tabdata) end if event.type == "CHG" and selected ~= nil then - core.setting_set("mainmenu_last_selected_world", + core.settings:set("mainmenu_last_selected_world", menudata.worldlist:get_raw_index(selected)) return true end @@ -136,7 +136,7 @@ local function main_button_handler(this, fields, name, tabdata) end if fields["cb_creative_mode"] then - core.setting_set("creative_mode", fields["cb_creative_mode"]) + core.settings:set("creative_mode", fields["cb_creative_mode"]) local selected = core.get_textlist_index("sp_worlds") menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"]) @@ -144,7 +144,7 @@ local function main_button_handler(this, fields, name, tabdata) end if fields["cb_enable_damage"] then - core.setting_set("enable_damage", fields["cb_enable_damage"]) + core.settings:set("enable_damage", fields["cb_enable_damage"]) local selected = core.get_textlist_index("sp_worlds") menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"]) diff --git a/builtin/mainmenu/tab_texturepacks.lua b/builtin/mainmenu/tab_texturepacks.lua index 4638beaa1..2957481cf 100644 --- a/builtin/mainmenu/tab_texturepacks.lua +++ b/builtin/mainmenu/tab_texturepacks.lua @@ -54,9 +54,9 @@ local function get_formspec(tabview, name, tabdata) local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" .. "textlist[4,0.25;7.5,5.0;TPs;" - local current_texture_path = core.setting_get("texture_path") + local current_texture_path = core.settings:get("texture_path") local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true)) - local index = tonumber(core.setting_get("mainmenu_last_selected_TP")) + local index = tonumber(core.settings:get("mainmenu_last_selected_TP")) if not index then index = 1 end @@ -106,7 +106,7 @@ local function main_button_handler(tabview, fields, name, tabdata) local event = core.explode_textlist_event(fields["TPs"]) if event.type == "CHG" or event.type == "DCL" then local index = core.get_textlist_index("TPs") - core.setting_set("mainmenu_last_selected_TP", index) + core.settings:set("mainmenu_last_selected_TP", index) local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true)) local current_index = core.get_textlist_index("TPs") if current_index and #list >= current_index then @@ -114,7 +114,7 @@ local function main_button_handler(tabview, fields, name, tabdata) if list[current_index] == fgettext("None") then new_path = "" end - core.setting_set("texture_path", new_path) + core.settings:set("texture_path", new_path) end end return true diff --git a/builtin/mainmenu/textures.lua b/builtin/mainmenu/textures.lua index dadbb093e..9ba4ade7e 100644 --- a/builtin/mainmenu/textures.lua +++ b/builtin/mainmenu/textures.lua @@ -24,7 +24,7 @@ function mm_texture.init() DIR_DELIM .. "pack" .. DIR_DELIM mm_texture.basetexturedir = mm_texture.defaulttexturedir - mm_texture.texturepack = core.setting_get("texture_path") + mm_texture.texturepack = core.settings:get("texture_path") mm_texture.gameid = nil end @@ -61,7 +61,7 @@ function mm_texture.reset() mm_texture.set_generic("header") if not have_bg then - if core.setting_getbool("menu_clouds") then + if core.settings:get_bool("menu_clouds") then core.set_clouds(true) else mm_texture.set_dirt_bg() @@ -88,7 +88,7 @@ function mm_texture.update_game(gamedetails) if not have_bg then - if core.setting_getbool("menu_clouds") then + if core.settings:get_bool("menu_clouds") then core.set_clouds(true) else mm_texture.set_dirt_bg() diff --git a/builtin/profiler/init.lua b/builtin/profiler/init.lua index c1597d280..874950364 100644 --- a/builtin/profiler/init.lua +++ b/builtin/profiler/init.lua @@ -15,10 +15,18 @@ --with this program; if not, write to the Free Software Foundation, Inc., --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +local function get_bool_default(name, default) + local val = core.settings:get_bool(name) + if val == nil then + return default + end + return val +end + local profiler_path = core.get_builtin_path()..DIR_DELIM.."profiler"..DIR_DELIM local profiler = {} local sampler = assert(loadfile(profiler_path .. "sampling.lua"))(profiler) -local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler) +local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler, get_bool_default) local reporter = dofile(profiler_path .. "reporter.lua") profiler.instrument = instrumentation.instrument @@ -27,7 +35,7 @@ profiler.instrument = instrumentation.instrument -- Is called later, after `core.register_chatcommand` was set up. -- function profiler.init_chatcommand() - local instrument_profiler = core.setting_getbool("instrument.profiler") or false + local instrument_profiler = get_bool_default("instrument.profiler", false) if instrument_profiler then instrumentation.init_chatcommand() end diff --git a/builtin/profiler/instrumentation.lua b/builtin/profiler/instrumentation.lua index 4311215b2..be3a460e5 100644 --- a/builtin/profiler/instrumentation.lua +++ b/builtin/profiler/instrumentation.lua @@ -17,8 +17,9 @@ local format, pairs, type = string.format, pairs, type local core, get_current_modname = core, core.get_current_modname -local profiler, sampler = ... -local instrument_builtin = core.setting_getbool("instrument.builtin") or false +local profiler, sampler, get_bool_default = ... + +local instrument_builtin = get_bool_default("instrument.builtin", false) local register_functions = { register_globalstep = 0, @@ -137,7 +138,7 @@ local function instrument_register(func, func_name) end local function init_chatcommand() - if core.setting_getbool("instrument.chatcommand") or true then + if get_bool_default("instrument.chatcommand", true) then local orig_register_chatcommand = core.register_chatcommand core.register_chatcommand = function(cmd, def) def.func = instrument { @@ -153,8 +154,7 @@ end -- Start instrumenting selected functions -- local function init() - local is_set = core.setting_getbool - if is_set("instrument.entity") or true then + if get_bool_default("instrument.entity", true) then -- Explicitly declare entity api-methods. -- Simple iteration would ignore lookup via __index. local entity_instrumentation = { @@ -180,7 +180,7 @@ local function init() end end - if is_set("instrument.abm") or true then + if get_bool_default("instrument.abm", true) then -- Wrap register_abm() to automatically instrument abms. local orig_register_abm = core.register_abm core.register_abm = function(spec) @@ -193,7 +193,7 @@ local function init() end end - if is_set("instrument.lbm") or true then + if get_bool_default("instrument.lbm", true) then -- Wrap register_lbm() to automatically instrument lbms. local orig_register_lbm = core.register_lbm core.register_lbm = function(spec) @@ -206,13 +206,13 @@ local function init() end end - if is_set("instrument.global_callback") or true then + if get_bool_default("instrument.global_callback", true) then for func_name, _ in pairs(register_functions) do core[func_name] = instrument_register(core[func_name], func_name) end end - if is_set("instrument.profiler") or false then + if get_bool_default("instrument.profiler", false) then -- Measure overhead of instrumentation, but keep it down for functions -- So keep the `return` for better optimization. profiler.empty_instrument = instrument { diff --git a/builtin/profiler/reporter.lua b/builtin/profiler/reporter.lua index 5b38ed4df..fed47a36b 100644 --- a/builtin/profiler/reporter.lua +++ b/builtin/profiler/reporter.lua @@ -18,7 +18,7 @@ local DIR_DELIM, LINE_DELIM = DIR_DELIM, "\n" local table, unpack, string, pairs, io, os = table, unpack, string, pairs, io, os local rep, sprintf, tonumber = string.rep, string.format, tonumber -local core, setting_get = core, core.setting_get +local core, settings = core, core.settings local reporter = {} --- @@ -229,7 +229,7 @@ end local worldpath = core.get_worldpath() local function get_save_path(format, filter) - local report_path = setting_get("profiler.report_path") or "" + local report_path = settings:get("profiler.report_path") or "" if report_path ~= "" then core.mkdir(sprintf("%s%s%s", worldpath, DIR_DELIM, report_path)) end @@ -249,7 +249,7 @@ end -- function reporter.save(profile, format, filter) if not format or format == "" then - format = setting_get("profiler.default_report_format") or "txt" + format = settings:get("profiler.default_report_format") or "txt" end if filter == "" then filter = nil diff --git a/builtin/profiler/sampling.lua b/builtin/profiler/sampling.lua index 1d1ef256d..4b53399a5 100644 --- a/builtin/profiler/sampling.lua +++ b/builtin/profiler/sampling.lua @@ -185,7 +185,7 @@ end function sampler.init() sampler.reset() - if core.setting_getbool("instrument.profiler") then + if core.settings:get_bool("instrument.profiler") then core.register_globalstep(function() if logged_time == 0 then return -- cgit v1.2.3 From a32a06e088df34efb82e3ec8633d331e3b177796 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Mon, 8 May 2017 23:56:57 -0700 Subject: Move Pilzadam to previous developers. (#5735) --- builtin/mainmenu/tab_credits.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index 80e03f84d..ff47dbb22 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -20,7 +20,6 @@ local core_developers = { "Perttu Ahola (celeron55) ", "Ryan Kwolek (kwolekr) ", - "PilzAdam ", "sfan5 ", "kahrl ", "sapier", @@ -54,6 +53,7 @@ local previous_core_developers = { "Lisa Milne (darkrose) ", "proller", "Ilya Zhuravlev (xyz) ", + "PilzAdam ", } local previous_contributors = { -- cgit v1.2.3 From 34c52d0ad76f627c719adc8806ca71c4968b8b39 Mon Sep 17 00:00:00 2001 From: red-001 Date: Tue, 9 May 2017 17:30:34 +0100 Subject: Android: Fix crash while loading main menu (#5736) Broken by 43d1f37 --- builtin/mainmenu/tab_simple_main.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua index 90a743f68..de4ae1751 100644 --- a/builtin/mainmenu/tab_simple_main.lua +++ b/builtin/mainmenu/tab_simple_main.lua @@ -188,6 +188,10 @@ local function main_button_handler(tabview, fields, name, tabdata) core.settings:set("address", fields.te_address) core.settings:set("remote_port", fields.te_port) + + core.start() + return true + end if fields.btn_config_sp_world then local configdialog = create_configure_world_dlg(1) -- cgit v1.2.3 From 6945f807abd789e0f522351e5e790ff2afced233 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Tue, 9 May 2017 23:11:20 +0200 Subject: minetest.deserialize: Throw error when argument not string (#5738) --- builtin/common/serialize.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'builtin') diff --git a/builtin/common/serialize.lua b/builtin/common/serialize.lua index b2165648e..692ddd5f0 100644 --- a/builtin/common/serialize.lua +++ b/builtin/common/serialize.lua @@ -186,6 +186,10 @@ local safe_env = { } function core.deserialize(str, safe) + if type(str) ~= "string" then + return nil, "Cannot deserialize type '"..type(str) + .."'. Argument must be a string." + end if str:byte(1) == 0x1B then return nil, "Bytecode prohibited" end -- cgit v1.2.3 From 441740e021f48a3c4f7595711777b7655fdd5778 Mon Sep 17 00:00:00 2001 From: red-001 Date: Wed, 10 May 2017 22:25:45 +0100 Subject: Menu: Fix starting a server if the server address is an empty string. (#5742) Minetest uses an empty string internal to signal that a server should be started. --- builtin/mainmenu/tab_multiplayer.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua index a9b2b35fe..f40b707ac 100644 --- a/builtin/mainmenu/tab_multiplayer.lua +++ b/builtin/mainmenu/tab_multiplayer.lua @@ -299,7 +299,8 @@ local function main_button_handler(tabview, fields, name, tabdata) return true end - if (fields.btn_mp_connect or fields.key_enter) and fields.te_address and fields.te_port then + if (fields.btn_mp_connect or fields.key_enter) + and fields.te_address ~= "" and fields.te_port then gamedata.playername = fields.te_name gamedata.password = fields.te_pwd gamedata.address = fields.te_address -- cgit v1.2.3 From 018217f6b2058db44b59a86e170614e1c6925f9f Mon Sep 17 00:00:00 2001 From: ezhh Date: Thu, 11 May 2017 23:18:36 +0100 Subject: Add option to use neither node highlighting nor outlining --- builtin/mainmenu/tab_settings.lua | 5 +++-- builtin/settingtypes.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index 69683eaa3..5a8cc19b8 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -25,7 +25,8 @@ local labels = { }, node_highlighting = { fgettext("Node Outlining"), - fgettext("Node Highlighting") + fgettext("Node Highlighting"), + fgettext("None") }, filters = { fgettext("No Filter"), @@ -52,7 +53,7 @@ local dd_options = { }, node_highlighting = { table.concat(labels.node_highlighting, ","), - {"box", "halo"} + {"box", "halo", "none"} }, filters = { table.concat(labels.filters, ","), diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 61c04e616..463ca0be9 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -344,7 +344,7 @@ enable_clouds (Clouds) bool true enable_3d_clouds (3D clouds) bool true # Method used to highlight selected object. -node_highlighting (Node highlighting) enum box box,halo +node_highlighting (Node highlighting) enum box box,halo,none # Adds particles when digging a node. enable_particles (Digging particles) bool true -- cgit v1.2.3 From 0120fe16a761f9e06c8c2877439db6a46d808143 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 13 May 2017 13:14:41 +0200 Subject: CSM: Document forgotten functions --- builtin/common/misc_helpers.lua | 2 +- builtin/mainmenu/common.lua | 2 +- builtin/mainmenu/tab_mods.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 1ca400688..68481f7c8 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -308,7 +308,7 @@ function core.formspec_escape(text) end -function core.splittext(text,charlimit) +function core.wrap_text(text, charlimit) local retval = {} local current_idx = 1 diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 294e1a621..fa7ae583b 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -250,7 +250,7 @@ end -------------------------------------------------------------------------------- function text2textlist(xpos, ypos, width, height, tl_name, textlen, text, transparency) - local textlines = core.splittext(text, textlen) + local textlines = core.wrap_text(text, textlen) local retval = "textlist[" .. xpos .. "," .. ypos .. ";" .. width .. "," .. height .. ";" .. tl_name .. ";" diff --git a/builtin/mainmenu/tab_mods.lua b/builtin/mainmenu/tab_mods.lua index 29afd8a4e..9510a9e18 100644 --- a/builtin/mainmenu/tab_mods.lua +++ b/builtin/mainmenu/tab_mods.lua @@ -75,7 +75,7 @@ local function get_formspec(tabview, name, tabdata) if error == nil then local descriptiontext = descriptionfile:read("*all") - descriptionlines = core.splittext(descriptiontext,42) + descriptionlines = core.wrap_text(descriptiontext, 42) descriptionfile:close() else descriptionlines = {} -- cgit v1.2.3 From 9b5effffbb0599f85014b53c3fd025b6a8222e02 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 17 May 2017 19:31:57 +0200 Subject: Builtin: Fix subgame mod selection (#5367) --- builtin/common/filterlist.lua | 3 +++ builtin/mainmenu/modmgr.lua | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'builtin') diff --git a/builtin/common/filterlist.lua b/builtin/common/filterlist.lua index 2a62362e3..562231192 100644 --- a/builtin/common/filterlist.lua +++ b/builtin/common/filterlist.lua @@ -289,6 +289,9 @@ function sort_mod_list(self) table.sort(self.m_processed_list, function(a, b) -- Show game mods at bottom if a.typ ~= b.typ then + if b.typ == "game" then + return a.typ ~= "game_mod" + end return b.typ == "game_mod" end -- If in same or no modpack, sort by name diff --git a/builtin/mainmenu/modmgr.lua b/builtin/mainmenu/modmgr.lua index 0fbfa3e6b..14d29272e 100644 --- a/builtin/mainmenu/modmgr.lua +++ b/builtin/mainmenu/modmgr.lua @@ -238,15 +238,7 @@ function modmgr.render_modlist(render_list) local list = render_list:get_list() local last_modpack = nil local retval = {} - local in_game_mods = false for i, v in ipairs(list) do - if v.typ == "game_mod" and not in_game_mods then - in_game_mods = true - retval[#retval + 1] = mt_color_blue - retval[#retval + 1] = "0" - retval[#retval + 1] = fgettext("Subgame Mods") - end - local color = "" if v.is_modpack then local rawlist = render_list:get_raw_list() @@ -260,7 +252,7 @@ function modmgr.render_modlist(render_list) break end end - elseif v.typ == "game_mod" then + elseif v.typ == "game_mod" or v.typ == "game" then color = mt_color_blue elseif v.enabled then color = mt_color_green @@ -421,6 +413,14 @@ function modmgr.preparemodlist(data) local gamespec = gamemgr.find_by_gameid(data.gameid) gamemgr.get_game_mods(gamespec, game_mods) + if #game_mods > 0 then + -- Add title + retval[#retval + 1] = { + typ = "game", + name = fgettext("Subgame Mods") + } + end + for i=1,#game_mods,1 do game_mods[i].typ = "game_mod" retval[#retval + 1] = game_mods[i] -- cgit v1.2.3 From 674400523e10624ae8320b0d18a05dbfd6dcac42 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Fri, 19 May 2017 07:45:47 +0200 Subject: Mainmenu: Fix issues while trying to enable all mods (#5770) --- builtin/mainmenu/dlg_config_world.lua | 24 +++++++++++++----------- builtin/mainmenu/modmgr.lua | 4 +++- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index 3e5ba16eb..fcedadea8 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -49,7 +49,7 @@ local function get_formspec(data) "button[3.25,7;2.5,0.5;btn_config_world_save;" .. fgettext("Save") .. "]" .. "button[5.75,7;2.5,0.5;btn_config_world_cancel;" .. fgettext("Cancel") .. "]" - if mod and mod.name ~= "" and mod.typ ~= "game_mod" then + if mod and mod.name ~= "" and not mod.is_game_content then if mod.is_modpack then local rawlist = data.list:get_raw_list() @@ -97,7 +97,7 @@ end local function enable_mod(this, toset) local mod = this.data.list:get_list()[this.data.selected_mod] - if mod.typ == "game_mod" then + if mod.is_game_content then -- game mods can't be enabled or disabled elseif not mod.is_modpack then if toset == nil then @@ -162,7 +162,7 @@ local function handle_buttons(this, fields) local i,mod for i,mod in ipairs(rawlist) do if not mod.is_modpack and - mod.typ ~= "game_mod" then + not mod.is_game_content then if modname_valid(mod.name) then worldfile:set("load_mod_"..mod.name, tostring(mod.enabled)) else @@ -198,7 +198,8 @@ local function handle_buttons(this, fields) local list = this.data.list:get_raw_list() for i = 1, #list do - if list[i].typ ~= "game_mod" and not list[i].is_modpack then + if not list[i].is_game_content + and not list[i].is_modpack then list[i].enabled = true end end @@ -210,7 +211,8 @@ local function handle_buttons(this, fields) local list = this.data.list:get_raw_list() for i = 1, #list do - if list[i].typ ~= "game_mod" and not list[i].is_modpack then + if not list[i].is_game_content + and not list[i].is_modpack then list[i].enabled = false end end @@ -252,16 +254,16 @@ function create_configure_world_dlg(worldidx) return true end end, - function(element,criteria) + function(element, criteria) if criteria.hide_game and - element.typ == "game_mod" then - return false + element.is_game_content then + return false end if criteria.hide_modpackcontents and - element.modpack ~= nil then - return false - end + element.modpack ~= nil then + return false + end return true end, --filter { worldpath= dlg.data.worldspec.path, diff --git a/builtin/mainmenu/modmgr.lua b/builtin/mainmenu/modmgr.lua index 14d29272e..dee048982 100644 --- a/builtin/mainmenu/modmgr.lua +++ b/builtin/mainmenu/modmgr.lua @@ -252,7 +252,7 @@ function modmgr.render_modlist(render_list) break end end - elseif v.typ == "game_mod" or v.typ == "game" then + elseif v.is_game_content then color = mt_color_blue elseif v.enabled then color = mt_color_green @@ -417,12 +417,14 @@ function modmgr.preparemodlist(data) -- Add title retval[#retval + 1] = { typ = "game", + is_game_content = true, name = fgettext("Subgame Mods") } end for i=1,#game_mods,1 do game_mods[i].typ = "game_mod" + game_mods[i].is_game_content = true retval[#retval + 1] = game_mods[i] end -- cgit v1.2.3 From dada983ff44298a5e38c9ba6ee46e1f4a25d1420 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Sat, 20 May 2017 03:56:17 -0700 Subject: Add /clearinv chat command (#4994) Allow players to clear their own inventory or that of another player with /clearinv command. server privilege is required to clear another player's inventory, no privileges are required to clear your own inventory.' --- builtin/game/chatcommands.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index b792a01cd..3f5f044b4 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -938,3 +938,31 @@ core.register_chatcommand("last-login", { return false, "Last login time is unknown" end, }) + +core.register_chatcommand("clearinv", { + params = "[name]", + description = "Clear the inventory of yourself or another player", + func = function(name, param) + local player + if param and param ~= "" and param ~= name then + if not core.check_player_privs(name, {server=true}) then + return false, "You don't have permission" + .. " to run this command (missing privilege: server)" + end + player = core.get_player_by_name(param) + core.chat_send_player(param, name.." cleared your inventory.") + else + player = core.get_player_by_name(name) + end + + if player then + player:get_inventory():set_list("main", {}) + player:get_inventory():set_list("craft", {}) + player:get_inventory():set_list("craftpreview", {}) + core.log("action", name.." clears "..player:get_player_name().."'s inventory") + return true, "Cleared "..player:get_player_name().."'s inventory." + else + return false, "Player must be online to clear inventory!" + end + end, +}) -- cgit v1.2.3 From 4dc97eb99fdbeec186cce5b03c64fb1df319d19d Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Sun, 21 May 2017 01:07:05 -0700 Subject: Menu: Merge singleplayer and server tabs (#5627) Rename "Singleplayer" tab to "Play" and remove "Server" tab placing server functionality under a "Host Game" checkbox in "Play." --- builtin/mainmenu/init.lua | 11 +- builtin/mainmenu/tab_local.lua | 317 ++++++++++++++++++++++++++++++ builtin/mainmenu/tab_multiplayer.lua | 350 ---------------------------------- builtin/mainmenu/tab_online.lua | 350 ++++++++++++++++++++++++++++++++++ builtin/mainmenu/tab_server.lua | 195 ------------------- builtin/mainmenu/tab_singleplayer.lua | 250 ------------------------ 6 files changed, 671 insertions(+), 802 deletions(-) create mode 100644 builtin/mainmenu/tab_local.lua delete mode 100644 builtin/mainmenu/tab_multiplayer.lua create mode 100644 builtin/mainmenu/tab_online.lua delete mode 100644 builtin/mainmenu/tab_server.lua delete mode 100644 builtin/mainmenu/tab_singleplayer.lua (limited to 'builtin') diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 492bb22d6..7c6af7d27 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -56,9 +56,8 @@ tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua") if PLATFORM == "Android" then tabs.simple_main = dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua") else - tabs.singleplayer = dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua") - tabs.multiplayer = dofile(menupath .. DIR_DELIM .. "tab_multiplayer.lua") - tabs.server = dofile(menupath .. DIR_DELIM .. "tab_server.lua") + tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua") + tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua") tabs.texturepacks = dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua") end @@ -135,9 +134,8 @@ local function init_globals() tv_main:add(tabs.settings) else tv_main:set_autosave_tab(true) - tv_main:add(tabs.singleplayer) - tv_main:add(tabs.multiplayer) - tv_main:add(tabs.server) + tv_main:add(tabs.local_game) + tv_main:add(tabs.play_online) tv_main:add(tabs.settings) tv_main:add(tabs.texturepacks) end @@ -167,4 +165,3 @@ local function init_globals() end init_globals() - diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua new file mode 100644 index 000000000..3e62078ce --- /dev/null +++ b/builtin/mainmenu/tab_local.lua @@ -0,0 +1,317 @@ +--Minetest +--Copyright (C) 2014 sapier +-- +--This program is free software; you can redistribute it and/or modify +--it under the terms of the GNU Lesser General Public License as published by +--the Free Software Foundation; either version 2.1 of the License, or +--(at your option) any later version. +-- +--This program is distributed in the hope that it will be useful, +--but WITHOUT ANY WARRANTY; without even the implied warranty of +--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +--GNU Lesser General Public License for more details. +-- +--You should have received a copy of the GNU Lesser General Public License along +--with this program; if not, write to the Free Software Foundation, Inc., +--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +local function current_game() + local last_game_id = core.settings:get("menu_last_game") + local game, index = gamemgr.find_by_gameid(last_game_id) + + return game +end + +local function singleplayer_refresh_gamebar() + + local old_bar = ui.find_by_name("game_button_bar") + + if old_bar ~= nil then + old_bar:delete() + end + + local function game_buttonbar_button_handler(fields) + for key,value in pairs(fields) do + for j=1,#gamemgr.games,1 do + if ("game_btnbar_" .. gamemgr.games[j].id == key) then + mm_texture.update("singleplayer", gamemgr.games[j]) + core.set_topleft_text(gamemgr.games[j].name) + core.settings:set("menu_last_game",gamemgr.games[j].id) + menudata.worldlist:set_filtercriteria(gamemgr.games[j].id) + local index = filterlist.get_current_index(menudata.worldlist, + tonumber(core.settings:get("mainmenu_last_selected_world"))) + if not index or index < 1 then + local selected = core.get_textlist_index("sp_worlds") + if selected ~= nil and selected < #menudata.worldlist:get_list() then + index = selected + else + index = #menudata.worldlist:get_list() + end + end + menu_worldmt_legacy(index) + return true + end + end + end + end + + local btnbar = buttonbar_create("game_button_bar", + game_buttonbar_button_handler, + {x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15}) + + for i=1,#gamemgr.games,1 do + local btn_name = "game_btnbar_" .. gamemgr.games[i].id + + local image = nil + local text = nil + local tooltip = core.formspec_escape(gamemgr.games[i].name) + + if gamemgr.games[i].menuicon_path ~= nil and + gamemgr.games[i].menuicon_path ~= "" then + image = core.formspec_escape(gamemgr.games[i].menuicon_path) + else + + local part1 = gamemgr.games[i].id:sub(1,5) + local part2 = gamemgr.games[i].id:sub(6,10) + local part3 = gamemgr.games[i].id:sub(11) + + text = part1 .. "\n" .. part2 + if part3 ~= nil and + part3 ~= "" then + text = text .. "\n" .. part3 + end + end + btnbar:add_button(btn_name, text, image, tooltip) + end +end + +local function get_formspec(tabview, name, tabdata) + local retval = "" + + local index = filterlist.get_current_index(menudata.worldlist, + tonumber(core.settings:get("mainmenu_last_selected_world")) + ) + + retval = retval .. + "button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" .. + "button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" .. + "button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" .. + "label[4,-0.25;".. fgettext("Select World:") .. "]".. + "checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" .. + dump(core.settings:get_bool("creative_mode")) .. "]".. + "checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" .. + dump(core.settings:get_bool("enable_damage")) .. "]".. + "checkbox[0.25,1.15;cb_server;".. fgettext("Host Server") ..";" .. + dump(core.settings:get_bool("enable_server")) .. "]" .. + "textlist[4,0.25;7.5,3.7;sp_worlds;" .. + menu_render_worldlist() .. + ";" .. index .. "]" + + if core.settings:get_bool("enable_server") then + retval = retval .. + "button[8.5,5;3.25,0.5;play;".. fgettext("Host Game") .. "]" .. + "checkbox[0.25,1.6;cb_server_announce;" .. fgettext("Announce Server") .. ";" .. + dump(core.settings:get_bool("server_announce")) .. "]" .. + "label[0.25,2.2;" .. fgettext("Name/Password") .. "]" .. + "field[0.55,3.2;3.5,0.5;te_playername;;" .. + core.formspec_escape(core.settings:get("name")) .. "]" .. + "pwdfield[0.55,4;3.5,0.5;te_passwd;]" + + local bind_addr = core.settings:get("bind_address") + if bind_addr ~= nil and bind_addr ~= "" then + retval = retval .. + "field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" .. + core.formspec_escape(core.settings:get("bind_address")) .. "]" .. + "field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" .. + core.formspec_escape(core.settings:get("port")) .. "]" + else + retval = retval .. + "field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" .. + core.formspec_escape(core.settings:get("port")) .. "]" + end + else + retval = retval .. + "button[8.5,5;3.25,0.5;play;".. fgettext("Play Game") .. "]" + end + + return retval +end + +local function main_button_handler(this, fields, name, tabdata) + + assert(name == "local") + + local world_doubleclick = false + + if fields["sp_worlds"] ~= nil then + local event = core.explode_textlist_event(fields["sp_worlds"]) + local selected = core.get_textlist_index("sp_worlds") + + menu_worldmt_legacy(selected) + + if event.type == "DCL" then + world_doubleclick = true + end + + if event.type == "CHG" and selected ~= nil then + core.settings:set("mainmenu_last_selected_world", + menudata.worldlist:get_raw_index(selected)) + return true + end + end + + if menu_handle_key_up_down(fields,"sp_worlds","mainmenu_last_selected_world") then + return true + end + + if fields["cb_creative_mode"] then + core.settings:set("creative_mode", fields["cb_creative_mode"]) + local selected = core.get_textlist_index("sp_worlds") + menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"]) + + return true + end + + if fields["cb_enable_damage"] then + core.settings:set("enable_damage", fields["cb_enable_damage"]) + local selected = core.get_textlist_index("sp_worlds") + menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"]) + + return true + end + + if fields["cb_server"] then + core.settings:set("enable_server", fields["cb_server"]) + + return true + end + + if fields["cb_server_announce"] then + core.settings:set("server_announce", fields["cb_server_announce"]) + local selected = core.get_textlist_index("srv_worlds") + menu_worldmt(selected, "server_announce", fields["cb_server_announce"]) + + return true + end + + if fields["play"] ~= nil or world_doubleclick or fields["key_enter"] then + local selected = core.get_textlist_index("sp_worlds") + gamedata.selected_world = menudata.worldlist:get_raw_index(selected) + + if core.settings:get_bool("enable_server") then + if selected ~= nil and gamedata.selected_world ~= 0 then + gamedata.playername = fields["te_playername"] + gamedata.password = fields["te_passwd"] + gamedata.port = fields["te_serverport"] + gamedata.address = "" + + core.settings:set("port",gamedata.port) + if fields["te_serveraddr"] ~= nil then + core.settings:set("bind_address",fields["te_serveraddr"]) + end + + --update last game + local world = menudata.worldlist:get_raw_element(gamedata.selected_world) + if world then + local game, index = gamemgr.find_by_gameid(world.gameid) + core.settings:set("menu_last_game", game.id) + end + + core.start() + else + gamedata.errormessage = + fgettext("No world created or selected!") + end + else + if selected ~= nil and gamedata.selected_world ~= 0 then + gamedata.singleplayer = true + core.start() + else + gamedata.errormessage = + fgettext("No world created or selected!") + end + return true + end + end + + if fields["world_create"] ~= nil then + local create_world_dlg = create_create_world_dlg(true) + create_world_dlg:set_parent(this) + this:hide() + create_world_dlg:show() + mm_texture.update("singleplayer",current_game()) + return true + end + + if fields["world_delete"] ~= nil then + local selected = core.get_textlist_index("sp_worlds") + if selected ~= nil and + selected <= menudata.worldlist:size() then + local world = menudata.worldlist:get_list()[selected] + if world ~= nil and + world.name ~= nil and + world.name ~= "" then + local index = menudata.worldlist:get_raw_index(selected) + local delete_world_dlg = create_delete_world_dlg(world.name,index) + delete_world_dlg:set_parent(this) + this:hide() + delete_world_dlg:show() + mm_texture.update("singleplayer",current_game()) + end + end + + return true + end + + if fields["world_configure"] ~= nil then + local selected = core.get_textlist_index("sp_worlds") + if selected ~= nil then + local configdialog = + create_configure_world_dlg( + menudata.worldlist:get_raw_index(selected)) + + if (configdialog ~= nil) then + configdialog:set_parent(this) + this:hide() + configdialog:show() + mm_texture.update("singleplayer",current_game()) + end + end + + return true + end +end + +local function on_change(type, old_tab, new_tab) + local buttonbar = ui.find_by_name("game_button_bar") + + if ( buttonbar == nil ) then + singleplayer_refresh_gamebar() + buttonbar = ui.find_by_name("game_button_bar") + end + + if (type == "ENTER") then + local game = current_game() + + if game then + menudata.worldlist:set_filtercriteria(game.id) + core.set_topleft_text(game.name) + mm_texture.update("singleplayer",game) + end + buttonbar:show() + else + menudata.worldlist:set_filtercriteria(nil) + buttonbar:hide() + core.set_topleft_text("") + mm_texture.update(new_tab,nil) + end +end + +-------------------------------------------------------------------------------- +return { + name = "local", + caption = fgettext("Local Game"), + cbf_formspec = get_formspec, + cbf_button_handler = main_button_handler, + on_change = on_change +} diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua deleted file mode 100644 index f40b707ac..000000000 --- a/builtin/mainmenu/tab_multiplayer.lua +++ /dev/null @@ -1,350 +0,0 @@ ---Minetest ---Copyright (C) 2014 sapier --- ---This program is free software; you can redistribute it and/or modify ---it under the terms of the GNU Lesser General Public License as published by ---the Free Software Foundation; either version 2.1 of the License, or ---(at your option) any later version. --- ---This program is distributed in the hope that it will be useful, ---but WITHOUT ANY WARRANTY; without even the implied warranty of ---MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ---GNU Lesser General Public License for more details. --- ---You should have received a copy of the GNU Lesser General Public License along ---with this program; if not, write to the Free Software Foundation, Inc., ---51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - --------------------------------------------------------------------------------- -local function get_formspec(tabview, name, tabdata) - -- Update the cached supported proto info, - -- it may have changed after a change by the settings menu. - common_update_cached_supp_proto() - local fav_selected = nil - if menudata.search_result then - fav_selected = menudata.search_result[tabdata.fav_selected] - else - fav_selected = menudata.favorites[tabdata.fav_selected] - end - - if not tabdata.search_for then - tabdata.search_for = "" - end - - local retval = - -- Search - "field[0.15,0.35;6.05,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]".. - "button[5.8,0.1;2,0.1;btn_mp_search;" .. fgettext("Search") .. "]" .. - - -- Address / Port - "label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" .. - "field[8,0.65;3.25,0.5;te_address;;" .. - core.formspec_escape(core.settings:get("address")) .. "]" .. - "field[11.1,0.65;1.4,0.5;te_port;;" .. - core.formspec_escape(core.settings:get("remote_port")) .. "]" .. - - -- Name / Password - "label[7.75,0.95;" .. fgettext("Name / Password") .. "]" .. - "field[8,1.85;2.9,0.5;te_name;;" .. - core.formspec_escape(core.settings:get("name")) .. "]" .. - "pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" .. - - -- Description Background - "box[7.73,2.25;4.25,2.6;#999999]".. - - -- Connect - "button[10.1,5.15;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]" - - if tabdata.fav_selected and fav_selected then - if gamedata.fav then - retval = retval .. "button[7.75,5.15;2.3,0.5;btn_delete_favorite;" .. - fgettext("Del. Favorite") .. "]" - end - if fav_selected.description then - retval = retval .. "textarea[8.1,2.3;4.23,2.9;;" .. - core.formspec_escape((gamedata.serverdescription or ""), true) .. ";]" - end - end - - --favourites - retval = retval .. "tablecolumns[" .. - image_column(fgettext("Favorite"), "favorite") .. ";" .. - image_column(fgettext("Ping")) .. ",padding=0.25;" .. - "color,span=3;" .. - "text,align=right;" .. -- clients - "text,align=center,padding=0.25;" .. -- "/" - "text,align=right,padding=0.25;" .. -- clients_max - image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" .. - image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" .. - image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" .. - "color,span=1;" .. - "text,padding=1]" .. - "table[-0.15,0.6;7.75,5.15;favourites;" - - if menudata.search_result then - for i = 1, #menudata.search_result do - local favs = core.get_favorites("local") - local server = menudata.search_result[i] - - for fav_id = 1, #favs do - if server.address == favs[fav_id].address and - server.port == favs[fav_id].port then - server.is_favorite = true - end - end - - if i ~= 1 then - retval = retval .. "," - end - - retval = retval .. render_serverlist_row(server, server.is_favorite) - end - elseif #menudata.favorites > 0 then - local favs = core.get_favorites("local") - if #favs > 0 then - for i = 1, #favs do - for j = 1, #menudata.favorites do - if menudata.favorites[j].address == favs[i].address and - menudata.favorites[j].port == favs[i].port then - table.insert(menudata.favorites, i, table.remove(menudata.favorites, j)) - end - end - if favs[i].address ~= menudata.favorites[i].address then - table.insert(menudata.favorites, i, favs[i]) - end - end - end - retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0)) - for i = 2, #menudata.favorites do - retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs)) - end - end - - if tabdata.fav_selected then - retval = retval .. ";" .. tabdata.fav_selected .. "]" - else - retval = retval .. ";0]" - end - - return retval -end - --------------------------------------------------------------------------------- -local function main_button_handler(tabview, fields, name, tabdata) - local serverlist = menudata.search_result or menudata.favorites - - if fields.te_name then - gamedata.playername = fields.te_name - core.settings:set("name", fields.te_name) - end - - if fields.favourites then - local event = core.explode_table_event(fields.favourites) - local fav = serverlist[event.row] - - if event.type == "DCL" then - if event.row <= #serverlist then - if menudata.favorites_is_public and - not is_server_protocol_compat_or_error( - fav.proto_min, fav.proto_max) then - return true - end - - gamedata.address = fav.address - gamedata.port = fav.port - gamedata.playername = fields.te_name - gamedata.selected_world = 0 - - if fields.te_pwd then - gamedata.password = fields.te_pwd - end - - gamedata.servername = fav.name - gamedata.serverdescription = fav.description - - if gamedata.address and gamedata.port then - core.settings:set("address", gamedata.address) - core.settings:set("remote_port", gamedata.port) - core.start() - end - end - return true - end - - if event.type == "CHG" then - if event.row <= #serverlist then - gamedata.fav = false - local favs = core.get_favorites("local") - local address = fav.address - local port = fav.port - gamedata.serverdescription = fav.description - - for i = 1, #favs do - if fav.address == favs[i].address and - fav.port == favs[i].port then - gamedata.fav = true - end - end - - if address and port then - core.settings:set("address", address) - core.settings:set("remote_port", port) - end - tabdata.fav_selected = event.row - end - return true - end - end - - if fields.key_up or fields.key_down then - local fav_idx = core.get_table_index("favourites") - local fav = serverlist[fav_idx] - - if fav_idx then - if fields.key_up and fav_idx > 1 then - fav_idx = fav_idx - 1 - elseif fields.key_down and fav_idx < #menudata.favorites then - fav_idx = fav_idx + 1 - end - else - fav_idx = 1 - end - - if not menudata.favorites or not fav then - tabdata.fav_selected = 0 - return true - end - - local address = fav.address - local port = fav.port - gamedata.serverdescription = fav.description - if address and port then - core.settings:set("address", address) - core.settings:set("remote_port", port) - end - - tabdata.fav_selected = fav_idx - return true - end - - if fields.btn_delete_favorite then - local current_favourite = core.get_table_index("favourites") - if not current_favourite then return end - - core.delete_favorite(current_favourite) - asyncOnlineFavourites() - tabdata.fav_selected = nil - - core.settings:set("address", "") - core.settings:set("remote_port", "30000") - return true - end - - if fields.btn_mp_search or fields.key_enter_field == "te_search" then - tabdata.fav_selected = 1 - local input = fields.te_search:lower() - tabdata.search_for = fields.te_search - - if #menudata.favorites < 2 then - return true - end - - menudata.search_result = {} - - -- setup the keyword list - local keywords = {} - for word in input:gmatch("%S+") do - table.insert(keywords, word) - end - - if #keywords == 0 then - menudata.search_result = nil - return true - end - - -- Search the serverlist - local search_result = {} - for i = 1, #menudata.favorites do - local server = menudata.favorites[i] - local found = 0 - for k = 1, #keywords do - local keyword = keywords[k] - if server.name then - local name = server.name:lower() - local _, count = name:gsub(keyword, keyword) - found = found + count * 4 - end - - if server.description then - local desc = server.description:lower() - local _, count = desc:gsub(keyword, keyword) - found = found + count * 2 - end - end - if found > 0 then - local points = (#menudata.favorites - i) / 5 + found - server.points = points - table.insert(search_result, server) - end - end - if #search_result > 0 then - table.sort(search_result, function(a, b) - return a.points > b.points - end) - menudata.search_result = search_result - local first_server = search_result[1] - core.settings:set("address", first_server.address) - core.settings:set("remote_port", first_server.port) - end - return true - end - - if (fields.btn_mp_connect or fields.key_enter) - and fields.te_address ~= "" and fields.te_port then - gamedata.playername = fields.te_name - gamedata.password = fields.te_pwd - gamedata.address = fields.te_address - gamedata.port = fields.te_port - gamedata.selected_world = 0 - local fav_idx = core.get_table_index("favourites") - local fav = serverlist[fav_idx] - - if fav_idx and fav_idx <= #serverlist and - fav.address == fields.te_address and - fav.port == fields.te_port then - - gamedata.servername = fav.name - gamedata.serverdescription = fav.description - - if menudata.favorites_is_public and - not is_server_protocol_compat_or_error( - fav.proto_min, fav.proto_max) then - return true - end - else - gamedata.servername = "" - gamedata.serverdescription = "" - end - - core.settings:set("address", fields.te_address) - core.settings:set("remote_port", fields.te_port) - - core.start() - return true - end - return false -end - -local function on_change(type, old_tab, new_tab) - if type == "LEAVE" then return end - asyncOnlineFavourites() -end - --------------------------------------------------------------------------------- -return { - name = "multiplayer", - caption = fgettext("Client"), - cbf_formspec = get_formspec, - cbf_button_handler = main_button_handler, - on_change = on_change -} diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua new file mode 100644 index 000000000..ab23a4b7c --- /dev/null +++ b/builtin/mainmenu/tab_online.lua @@ -0,0 +1,350 @@ +--Minetest +--Copyright (C) 2014 sapier +-- +--This program is free software; you can redistribute it and/or modify +--it under the terms of the GNU Lesser General Public License as published by +--the Free Software Foundation; either version 2.1 of the License, or +--(at your option) any later version. +-- +--This program is distributed in the hope that it will be useful, +--but WITHOUT ANY WARRANTY; without even the implied warranty of +--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +--GNU Lesser General Public License for more details. +-- +--You should have received a copy of the GNU Lesser General Public License along +--with this program; if not, write to the Free Software Foundation, Inc., +--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +-------------------------------------------------------------------------------- +local function get_formspec(tabview, name, tabdata) + -- Update the cached supported proto info, + -- it may have changed after a change by the settings menu. + common_update_cached_supp_proto() + local fav_selected = nil + if menudata.search_result then + fav_selected = menudata.search_result[tabdata.fav_selected] + else + fav_selected = menudata.favorites[tabdata.fav_selected] + end + + if not tabdata.search_for then + tabdata.search_for = "" + end + + local retval = + -- Search + "field[0.15,0.35;6.05,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]".. + "button[5.8,0.1;2,0.1;btn_mp_search;" .. fgettext("Search") .. "]" .. + + -- Address / Port + "label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" .. + "field[8,0.65;3.25,0.5;te_address;;" .. + core.formspec_escape(core.settings:get("address")) .. "]" .. + "field[11.1,0.65;1.4,0.5;te_port;;" .. + core.formspec_escape(core.settings:get("remote_port")) .. "]" .. + + -- Name / Password + "label[7.75,0.95;" .. fgettext("Name / Password") .. "]" .. + "field[8,1.85;2.9,0.5;te_name;;" .. + core.formspec_escape(core.settings:get("name")) .. "]" .. + "pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" .. + + -- Description Background + "box[7.73,2.25;4.25,2.6;#999999]".. + + -- Connect + "button[10.1,5.15;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]" + + if tabdata.fav_selected and fav_selected then + if gamedata.fav then + retval = retval .. "button[7.75,5.15;2.3,0.5;btn_delete_favorite;" .. + fgettext("Del. Favorite") .. "]" + end + if fav_selected.description then + retval = retval .. "textarea[8.1,2.3;4.23,2.9;;" .. + core.formspec_escape((gamedata.serverdescription or ""), true) .. ";]" + end + end + + --favourites + retval = retval .. "tablecolumns[" .. + image_column(fgettext("Favorite"), "favorite") .. ";" .. + image_column(fgettext("Ping")) .. ",padding=0.25;" .. + "color,span=3;" .. + "text,align=right;" .. -- clients + "text,align=center,padding=0.25;" .. -- "/" + "text,align=right,padding=0.25;" .. -- clients_max + image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" .. + image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" .. + image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" .. + "color,span=1;" .. + "text,padding=1]" .. + "table[-0.15,0.6;7.75,5.15;favourites;" + + if menudata.search_result then + for i = 1, #menudata.search_result do + local favs = core.get_favorites("local") + local server = menudata.search_result[i] + + for fav_id = 1, #favs do + if server.address == favs[fav_id].address and + server.port == favs[fav_id].port then + server.is_favorite = true + end + end + + if i ~= 1 then + retval = retval .. "," + end + + retval = retval .. render_serverlist_row(server, server.is_favorite) + end + elseif #menudata.favorites > 0 then + local favs = core.get_favorites("local") + if #favs > 0 then + for i = 1, #favs do + for j = 1, #menudata.favorites do + if menudata.favorites[j].address == favs[i].address and + menudata.favorites[j].port == favs[i].port then + table.insert(menudata.favorites, i, table.remove(menudata.favorites, j)) + end + end + if favs[i].address ~= menudata.favorites[i].address then + table.insert(menudata.favorites, i, favs[i]) + end + end + end + retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0)) + for i = 2, #menudata.favorites do + retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs)) + end + end + + if tabdata.fav_selected then + retval = retval .. ";" .. tabdata.fav_selected .. "]" + else + retval = retval .. ";0]" + end + + return retval +end + +-------------------------------------------------------------------------------- +local function main_button_handler(tabview, fields, name, tabdata) + local serverlist = menudata.search_result or menudata.favorites + + if fields.te_name then + gamedata.playername = fields.te_name + core.settings:set("name", fields.te_name) + end + + if fields.favourites then + local event = core.explode_table_event(fields.favourites) + local fav = serverlist[event.row] + + if event.type == "DCL" then + if event.row <= #serverlist then + if menudata.favorites_is_public and + not is_server_protocol_compat_or_error( + fav.proto_min, fav.proto_max) then + return true + end + + gamedata.address = fav.address + gamedata.port = fav.port + gamedata.playername = fields.te_name + gamedata.selected_world = 0 + + if fields.te_pwd then + gamedata.password = fields.te_pwd + end + + gamedata.servername = fav.name + gamedata.serverdescription = fav.description + + if gamedata.address and gamedata.port then + core.settings:set("address", gamedata.address) + core.settings:set("remote_port", gamedata.port) + core.start() + end + end + return true + end + + if event.type == "CHG" then + if event.row <= #serverlist then + gamedata.fav = false + local favs = core.get_favorites("local") + local address = fav.address + local port = fav.port + gamedata.serverdescription = fav.description + + for i = 1, #favs do + if fav.address == favs[i].address and + fav.port == favs[i].port then + gamedata.fav = true + end + end + + if address and port then + core.settings:set("address", address) + core.settings:set("remote_port", port) + end + tabdata.fav_selected = event.row + end + return true + end + end + + if fields.key_up or fields.key_down then + local fav_idx = core.get_table_index("favourites") + local fav = serverlist[fav_idx] + + if fav_idx then + if fields.key_up and fav_idx > 1 then + fav_idx = fav_idx - 1 + elseif fields.key_down and fav_idx < #menudata.favorites then + fav_idx = fav_idx + 1 + end + else + fav_idx = 1 + end + + if not menudata.favorites or not fav then + tabdata.fav_selected = 0 + return true + end + + local address = fav.address + local port = fav.port + gamedata.serverdescription = fav.description + if address and port then + core.settings:set("address", address) + core.settings:set("remote_port", port) + end + + tabdata.fav_selected = fav_idx + return true + end + + if fields.btn_delete_favorite then + local current_favourite = core.get_table_index("favourites") + if not current_favourite then return end + + core.delete_favorite(current_favourite) + asyncOnlineFavourites() + tabdata.fav_selected = nil + + core.settings:set("address", "") + core.settings:set("remote_port", "30000") + return true + end + + if fields.btn_mp_search or fields.key_enter_field == "te_search" then + tabdata.fav_selected = 1 + local input = fields.te_search:lower() + tabdata.search_for = fields.te_search + + if #menudata.favorites < 2 then + return true + end + + menudata.search_result = {} + + -- setup the keyword list + local keywords = {} + for word in input:gmatch("%S+") do + table.insert(keywords, word) + end + + if #keywords == 0 then + menudata.search_result = nil + return true + end + + -- Search the serverlist + local search_result = {} + for i = 1, #menudata.favorites do + local server = menudata.favorites[i] + local found = 0 + for k = 1, #keywords do + local keyword = keywords[k] + if server.name then + local name = server.name:lower() + local _, count = name:gsub(keyword, keyword) + found = found + count * 4 + end + + if server.description then + local desc = server.description:lower() + local _, count = desc:gsub(keyword, keyword) + found = found + count * 2 + end + end + if found > 0 then + local points = (#menudata.favorites - i) / 5 + found + server.points = points + table.insert(search_result, server) + end + end + if #search_result > 0 then + table.sort(search_result, function(a, b) + return a.points > b.points + end) + menudata.search_result = search_result + local first_server = search_result[1] + core.settings:set("address", first_server.address) + core.settings:set("remote_port", first_server.port) + end + return true + end + + if (fields.btn_mp_connect or fields.key_enter) + and fields.te_address ~= "" and fields.te_port then + gamedata.playername = fields.te_name + gamedata.password = fields.te_pwd + gamedata.address = fields.te_address + gamedata.port = fields.te_port + gamedata.selected_world = 0 + local fav_idx = core.get_table_index("favourites") + local fav = serverlist[fav_idx] + + if fav_idx and fav_idx <= #serverlist and + fav.address == fields.te_address and + fav.port == fields.te_port then + + gamedata.servername = fav.name + gamedata.serverdescription = fav.description + + if menudata.favorites_is_public and + not is_server_protocol_compat_or_error( + fav.proto_min, fav.proto_max) then + return true + end + else + gamedata.servername = "" + gamedata.serverdescription = "" + end + + core.settings:set("address", fields.te_address) + core.settings:set("remote_port", fields.te_port) + + core.start() + return true + end + return false +end + +local function on_change(type, old_tab, new_tab) + if type == "LEAVE" then return end + asyncOnlineFavourites() +end + +-------------------------------------------------------------------------------- +return { + name = "online", + caption = fgettext("Play Online"), + cbf_formspec = get_formspec, + cbf_button_handler = main_button_handler, + on_change = on_change +} diff --git a/builtin/mainmenu/tab_server.lua b/builtin/mainmenu/tab_server.lua deleted file mode 100644 index 8f25ce871..000000000 --- a/builtin/mainmenu/tab_server.lua +++ /dev/null @@ -1,195 +0,0 @@ ---Minetest ---Copyright (C) 2014 sapier --- ---This program is free software; you can redistribute it and/or modify ---it under the terms of the GNU Lesser General Public License as published by ---the Free Software Foundation; either version 2.1 of the License, or ---(at your option) any later version. --- ---This program is distributed in the hope that it will be useful, ---but WITHOUT ANY WARRANTY; without even the implied warranty of ---MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ---GNU Lesser General Public License for more details. --- ---You should have received a copy of the GNU Lesser General Public License along ---with this program; if not, write to the Free Software Foundation, Inc., ---51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - --------------------------------------------------------------------------------- -local function get_formspec(tabview, name, tabdata) - - local index = menudata.worldlist:get_current_index( - tonumber(core.settings:get("mainmenu_last_selected_world")) - ) - - local retval = - "button[4,4.15;2.6,0.5;world_delete;" .. fgettext("Delete") .. "]" .. - "button[6.5,4.15;2.8,0.5;world_create;" .. fgettext("New") .. "]" .. - "button[9.2,4.15;2.55,0.5;world_configure;" .. fgettext("Configure") .. "]" .. - "button[8.5,5;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" .. - "label[4,-0.25;" .. fgettext("Select World:") .. "]" .. - "checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" .. - dump(core.settings:get_bool("creative_mode")) .. "]" .. - "checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" .. - dump(core.settings:get_bool("enable_damage")) .. "]" .. - "checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";" .. - dump(core.settings:get_bool("server_announce")) .. "]" .. - "label[0.25,2.2;" .. fgettext("Name/Password") .. "]" .. - "field[0.55,3.2;3.5,0.5;te_playername;;" .. - core.formspec_escape(core.settings:get("name")) .. "]" .. - "pwdfield[0.55,4;3.5,0.5;te_passwd;]" - - local bind_addr = core.settings:get("bind_address") - if bind_addr ~= nil and bind_addr ~= "" then - retval = retval .. - "field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" .. - core.formspec_escape(core.settings:get("bind_address")) .. "]" .. - "field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" .. - core.formspec_escape(core.settings:get("port")) .. "]" - else - retval = retval .. - "field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" .. - core.formspec_escape(core.settings:get("port")) .. "]" - end - - retval = retval .. - "textlist[4,0.25;7.5,3.7;srv_worlds;" .. - menu_render_worldlist() .. - ";" .. index .. "]" - - return retval -end - --------------------------------------------------------------------------------- -local function main_button_handler(this, fields, name, tabdata) - - local world_doubleclick = false - - if fields["srv_worlds"] ~= nil then - local event = core.explode_textlist_event(fields["srv_worlds"]) - local selected = core.get_textlist_index("srv_worlds") - - menu_worldmt_legacy(selected) - - if event.type == "DCL" then - world_doubleclick = true - end - if event.type == "CHG" then - core.settings:set("mainmenu_last_selected_world", - menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds"))) - return true - end - end - - if menu_handle_key_up_down(fields,"srv_worlds","mainmenu_last_selected_world") then - return true - end - - if fields["cb_creative_mode"] then - core.settings:set("creative_mode", fields["cb_creative_mode"]) - local selected = core.get_textlist_index("srv_worlds") - menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"]) - - return true - end - - if fields["cb_enable_damage"] then - core.settings:set("enable_damage", fields["cb_enable_damage"]) - local selected = core.get_textlist_index("srv_worlds") - menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"]) - - return true - end - - if fields["cb_server_announce"] then - core.settings:set("server_announce", fields["cb_server_announce"]) - local selected = core.get_textlist_index("srv_worlds") - menu_worldmt(selected, "server_announce", fields["cb_server_announce"]) - - return true - end - - if fields["start_server"] ~= nil or - world_doubleclick or - fields["key_enter"] then - local selected = core.get_textlist_index("srv_worlds") - gamedata.selected_world = menudata.worldlist:get_raw_index(selected) - if selected ~= nil and gamedata.selected_world ~= 0 then - gamedata.playername = fields["te_playername"] - gamedata.password = fields["te_passwd"] - gamedata.port = fields["te_serverport"] - gamedata.address = "" - - core.settings:set("port",gamedata.port) - if fields["te_serveraddr"] ~= nil then - core.settings:set("bind_address",fields["te_serveraddr"]) - end - - --update last game - local world = menudata.worldlist:get_raw_element(gamedata.selected_world) - if world then - local game, index = gamemgr.find_by_gameid(world.gameid) - core.settings:set("menu_last_game", game.id) - end - - core.start() - else - gamedata.errormessage = - fgettext("No world created or selected!") - end - return true - end - - if fields["world_create"] ~= nil then - local create_world_dlg = create_create_world_dlg(true) - create_world_dlg:set_parent(this) - create_world_dlg:show() - this:hide() - return true - end - - if fields["world_delete"] ~= nil then - local selected = core.get_textlist_index("srv_worlds") - if selected ~= nil and - selected <= menudata.worldlist:size() then - local world = menudata.worldlist:get_list()[selected] - if world ~= nil and - world.name ~= nil and - world.name ~= "" then - local index = menudata.worldlist:get_raw_index(selected) - local delete_world_dlg = create_delete_world_dlg(world.name,index) - delete_world_dlg:set_parent(this) - delete_world_dlg:show() - this:hide() - end - end - - return true - end - - if fields["world_configure"] ~= nil then - local selected = core.get_textlist_index("srv_worlds") - if selected ~= nil then - local configdialog = - create_configure_world_dlg( - menudata.worldlist:get_raw_index(selected)) - - if (configdialog ~= nil) then - configdialog:set_parent(this) - configdialog:show() - this:hide() - end - end - return true - end - return false -end - --------------------------------------------------------------------------------- -return { - name = "server", - caption = fgettext("Server"), - cbf_formspec = get_formspec, - cbf_button_handler = main_button_handler, - on_change = nil -} diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua deleted file mode 100644 index c58ad4164..000000000 --- a/builtin/mainmenu/tab_singleplayer.lua +++ /dev/null @@ -1,250 +0,0 @@ ---Minetest ---Copyright (C) 2014 sapier --- ---This program is free software; you can redistribute it and/or modify ---it under the terms of the GNU Lesser General Public License as published by ---the Free Software Foundation; either version 2.1 of the License, or ---(at your option) any later version. --- ---This program is distributed in the hope that it will be useful, ---but WITHOUT ANY WARRANTY; without even the implied warranty of ---MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ---GNU Lesser General Public License for more details. --- ---You should have received a copy of the GNU Lesser General Public License along ---with this program; if not, write to the Free Software Foundation, Inc., ---51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -local function current_game() - local last_game_id = core.settings:get("menu_last_game") - local game, index = gamemgr.find_by_gameid(last_game_id) - - return game -end - -local function singleplayer_refresh_gamebar() - - local old_bar = ui.find_by_name("game_button_bar") - - if old_bar ~= nil then - old_bar:delete() - end - - local function game_buttonbar_button_handler(fields) - for key,value in pairs(fields) do - for j=1,#gamemgr.games,1 do - if ("game_btnbar_" .. gamemgr.games[j].id == key) then - mm_texture.update("singleplayer", gamemgr.games[j]) - core.set_topleft_text(gamemgr.games[j].name) - core.settings:set("menu_last_game",gamemgr.games[j].id) - menudata.worldlist:set_filtercriteria(gamemgr.games[j].id) - local index = filterlist.get_current_index(menudata.worldlist, - tonumber(core.settings:get("mainmenu_last_selected_world"))) - if not index or index < 1 then - local selected = core.get_textlist_index("sp_worlds") - if selected ~= nil and selected < #menudata.worldlist:get_list() then - index = selected - else - index = #menudata.worldlist:get_list() - end - end - menu_worldmt_legacy(index) - return true - end - end - end - end - - local btnbar = buttonbar_create("game_button_bar", - game_buttonbar_button_handler, - {x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15}) - - for i=1,#gamemgr.games,1 do - local btn_name = "game_btnbar_" .. gamemgr.games[i].id - - local image = nil - local text = nil - local tooltip = core.formspec_escape(gamemgr.games[i].name) - - if gamemgr.games[i].menuicon_path ~= nil and - gamemgr.games[i].menuicon_path ~= "" then - image = core.formspec_escape(gamemgr.games[i].menuicon_path) - else - - local part1 = gamemgr.games[i].id:sub(1,5) - local part2 = gamemgr.games[i].id:sub(6,10) - local part3 = gamemgr.games[i].id:sub(11) - - text = part1 .. "\n" .. part2 - if part3 ~= nil and - part3 ~= "" then - text = text .. "\n" .. part3 - end - end - btnbar:add_button(btn_name, text, image, tooltip) - end -end - -local function get_formspec(tabview, name, tabdata) - local retval = "" - - local index = filterlist.get_current_index(menudata.worldlist, - tonumber(core.settings:get("mainmenu_last_selected_world")) - ) - - retval = retval .. - "button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" .. - "button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" .. - "button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" .. - "button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" .. - "label[4,-0.25;".. fgettext("Select World:") .. "]".. - "checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" .. - dump(core.settings:get_bool("creative_mode")) .. "]".. - "checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" .. - dump(core.settings:get_bool("enable_damage")) .. "]".. - "textlist[4,0.25;7.5,3.7;sp_worlds;" .. - menu_render_worldlist() .. - ";" .. index .. "]" - return retval -end - -local function main_button_handler(this, fields, name, tabdata) - - assert(name == "singleplayer") - - local world_doubleclick = false - - if fields["sp_worlds"] ~= nil then - local event = core.explode_textlist_event(fields["sp_worlds"]) - local selected = core.get_textlist_index("sp_worlds") - - menu_worldmt_legacy(selected) - - if event.type == "DCL" then - world_doubleclick = true - end - - if event.type == "CHG" and selected ~= nil then - core.settings:set("mainmenu_last_selected_world", - menudata.worldlist:get_raw_index(selected)) - return true - end - end - - if menu_handle_key_up_down(fields,"sp_worlds","mainmenu_last_selected_world") then - return true - end - - if fields["cb_creative_mode"] then - core.settings:set("creative_mode", fields["cb_creative_mode"]) - local selected = core.get_textlist_index("sp_worlds") - menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"]) - - return true - end - - if fields["cb_enable_damage"] then - core.settings:set("enable_damage", fields["cb_enable_damage"]) - local selected = core.get_textlist_index("sp_worlds") - menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"]) - - return true - end - - if fields["play"] ~= nil or - world_doubleclick or - fields["key_enter"] then - local selected = core.get_textlist_index("sp_worlds") - gamedata.selected_world = menudata.worldlist:get_raw_index(selected) - - if selected ~= nil and gamedata.selected_world ~= 0 then - gamedata.singleplayer = true - core.start() - else - gamedata.errormessage = - fgettext("No world created or selected!") - end - return true - end - - if fields["world_create"] ~= nil then - local create_world_dlg = create_create_world_dlg(true) - create_world_dlg:set_parent(this) - this:hide() - create_world_dlg:show() - mm_texture.update("singleplayer",current_game()) - return true - end - - if fields["world_delete"] ~= nil then - local selected = core.get_textlist_index("sp_worlds") - if selected ~= nil and - selected <= menudata.worldlist:size() then - local world = menudata.worldlist:get_list()[selected] - if world ~= nil and - world.name ~= nil and - world.name ~= "" then - local index = menudata.worldlist:get_raw_index(selected) - local delete_world_dlg = create_delete_world_dlg(world.name,index) - delete_world_dlg:set_parent(this) - this:hide() - delete_world_dlg:show() - mm_texture.update("singleplayer",current_game()) - end - end - - return true - end - - if fields["world_configure"] ~= nil then - local selected = core.get_textlist_index("sp_worlds") - if selected ~= nil then - local configdialog = - create_configure_world_dlg( - menudata.worldlist:get_raw_index(selected)) - - if (configdialog ~= nil) then - configdialog:set_parent(this) - this:hide() - configdialog:show() - mm_texture.update("singleplayer",current_game()) - end - end - - return true - end -end - -local function on_change(type, old_tab, new_tab) - local buttonbar = ui.find_by_name("game_button_bar") - - if ( buttonbar == nil ) then - singleplayer_refresh_gamebar() - buttonbar = ui.find_by_name("game_button_bar") - end - - if (type == "ENTER") then - local game = current_game() - - if game then - menudata.worldlist:set_filtercriteria(game.id) - core.set_topleft_text(game.name) - mm_texture.update("singleplayer",game) - end - buttonbar:show() - else - menudata.worldlist:set_filtercriteria(nil) - buttonbar:hide() - core.set_topleft_text("") - mm_texture.update(new_tab,nil) - end -end - --------------------------------------------------------------------------------- -return { - name = "singleplayer", - caption = fgettext("Singleplayer"), - cbf_formspec = get_formspec, - cbf_button_handler = main_button_handler, - on_change = on_change -} -- cgit v1.2.3 From 39f4a2f607d44738d60db84eba4b30e3d7450204 Mon Sep 17 00:00:00 2001 From: Pierre-Adrien Langrognet Date: Sun, 21 May 2017 23:06:51 +0200 Subject: [CSM] Add send_chat_message and run_server_chatcommand API functions (#5747) * [CSM] Add send_chat_message and run_server_chatcommand API functions * Add client-side chat message rate limiting * Limit out chat queue size * [CSM] Add minetest.clear_out_chat_queue API function and .clear_chat_queue chatcommand * Last fixes/cleanups before merge --- builtin/client/chatcommands.lua | 12 ++++++++++++ builtin/settingtypes.txt | 3 +++ 2 files changed, 15 insertions(+) (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index f425216f5..2b8cc4acd 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -51,3 +51,15 @@ core.register_chatcommand("disconnect", { core.disconnect() end, }) + +core.register_chatcommand("clear_chat_queue", { + description = core.gettext("Clear the out chat queue"), + func = function(param) + core.clear_out_chat_queue() + return true, core.gettext("The out chat queue is now empty") + end, +}) + +function core.run_server_chatcommand(cmd, param) + core.send_chat_message("/" .. cmd .. " " .. param) +end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 463ca0be9..0ec33c628 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -312,6 +312,9 @@ serverlist_url (Serverlist URL) string servers.minetest.net # File in client/serverlist/ that contains your favorite servers displayed in the Multiplayer Tab. serverlist_file (Serverlist file) string favoriteservers.txt +# Maximum size of the out chat queue. 0 to disable queueing and -1 to make the queue size unlimited +max_out_chat_queue_size (Maximum size of the out chat queue) int 20 + [*Graphics] [**In-Game] -- cgit v1.2.3 From e8fb1f79bcd4261e2ed58f2f4286994d947572e2 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 24 May 2017 06:45:23 +0100 Subject: Add formspec escaping to subgame list in create world dialog (#5808) --- builtin/mainmenu/gamemgr.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/gamemgr.lua b/builtin/mainmenu/gamemgr.lua index b6faa71d9..fd6025fcd 100644 --- a/builtin/mainmenu/gamemgr.lua +++ b/builtin/mainmenu/gamemgr.lua @@ -68,10 +68,10 @@ end function gamemgr.gamelist() local retval = "" if #gamemgr.games > 0 then - retval = retval .. gamemgr.games[1].name + retval = retval .. core.formspec_escape(gamemgr.games[1].name) for i=2,#gamemgr.games,1 do - retval = retval .. "," .. gamemgr.games[i].name + retval = retval .. "," .. core.formspec_escape(gamemgr.games[i].name) end end return retval -- cgit v1.2.3 From c09e16ff5bd65a82aa231a286308f3415fe9159e Mon Sep 17 00:00:00 2001 From: Nathan Salapat Date: Sun, 28 May 2017 02:23:06 -0500 Subject: Added missing levels to logging menu (#5836) * Added missing levels to logging menu Added none and error options to the debug_log_level in the advance settings. --- builtin/settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0ec33c628..3758097bc 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -1468,7 +1468,7 @@ language (Language) enum ,be,ca,cs,da,de,en,eo,es,et,fr,he,hu,id,it,ja,jbo,ko, # - action # - info # - verbose -debug_log_level (Debug log level) enum action ,warning,action,info,verbose +debug_log_level (Debug log level) enum action ,none,error,warning,action,info,verbose # IPv6 support. enable_ipv6 (IPv6) bool true -- cgit v1.2.3 From 80fe516e4e9139503afec234d81555468803b118 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 2 Jun 2017 17:16:30 +0200 Subject: =?UTF-8?q?Remove=20=E2=80=9Cinf=E2=80=9D=20argument=20from=20shut?= =?UTF-8?q?down=20command=20help=20(#5880)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- builtin/game/chatcommands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 3f5f044b4..3dfc29ffa 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -807,7 +807,7 @@ core.register_chatcommand("days", { core.register_chatcommand("shutdown", { description = "Shutdown server", - params = "[delay_in_seconds(0..inf) or -1 for cancel] [reconnect] [message]", + params = "[delay_in_seconds (non-negative number, or -1 to cancel)] [reconnect] [message]", privs = {server=true}, func = function(name, param) local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)") -- cgit v1.2.3 From 994802a77496202a1d71aae54e9606ee6f55def6 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 3 Jun 2017 13:44:04 +0100 Subject: Remove unimplemented setting `movement_speed_descend` (#5892) --- builtin/settingtypes.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 3758097bc..ba3339d32 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -886,7 +886,6 @@ movement_speed_crouch (Crouch speed) float 1.35 movement_speed_fast (Fast mode speed) float 20 movement_speed_climb (Climbing speed) float 3 movement_speed_jump (Jumping speed) float 6.5 -movement_speed_descend (Descending speed) float 6 movement_liquid_fluidity (Liquid fluidity) float 1 movement_liquid_fluidity_smooth (Liquid fluidity smoothing) float 0.5 movement_liquid_sink (Liquid sink) float 10 -- cgit v1.2.3 From fe046fab8aa0bde610f8828fb1c3fc014cf7e193 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 28 May 2017 20:37:44 +0100 Subject: Update credits The following algorithm was used when selecting contributors: * Every non-trivial contributor from the current release, Non-trivial meaning more than X non-trivial commits, not counting documentation/translation changes * The top Y contributors from the last 4 years. * Previous contributor means no contributions since a few months before the last release. In the future this should be automated --- builtin/mainmenu/tab_credits.lua | 81 ++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index ff47dbb22..0774433b6 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -19,61 +19,68 @@ local core_developers = { "Perttu Ahola (celeron55) ", - "Ryan Kwolek (kwolekr) ", "sfan5 ", - "kahrl ", - "sapier", "ShadowNinja ", "Nathanaël Courant (Nore/Ekdohibs) ", "Loic Blot (nerzhul/nrz) ", - "Matt Gregory (paramat)", - "est31 ", + "paramat", "Craig Robbins (Zeno) ", "Auke Kok (sofar) ", - "Andrew Ward (rubenwardy) ", + "rubenwardy ", + "Krock/SmallJoker ", } local active_contributors = { - "Duane Robertson ", - "SmallJoker ", - "Lars Hofhansl ", - "Jeija ", - "Gregory Currie (gregorycu)", - "Sokomine ", - "TeTpaAka", - "Jean-Patrick G (kilbith) ", - "Diego Martínez (kaeza) ", - "Dániel Juhász (juhdanad) ", - "Rogier ", + "red-001 [CSM & Menu fixes]", + "Dániel Juhász (juhdanad) [Audiovisuals: lighting]", + "numberZero [Audiovisuals: meshgen]", + "Lars Hofhansl [Occulusion culling, fixes]", + "Jean-Patrick G (kilbith) [Audiovisuals]", + "Vincent Glize (Dumbeldor) [CSM]", + "bigfoot547 [CSM]", + "Rogier [Fixes]", + "Wuzzy [Audiovisuals]", + "Shara/Ezhh [Settings]", } local previous_core_developers = { "BlockMen", - "Maciej Kasatkin (RealBadAngel) ", + "Maciej Kasatkin (RealBadAngel) [RIP]", "Lisa Milne (darkrose) ", "proller", "Ilya Zhuravlev (xyz) ", "PilzAdam ", + "est31 ", + "kahrl ", + "Ryan Kwolek (kwolekr) ", + "sapier", } local previous_contributors = { - "Vanessa Ezekowitz (VanessaE) ", - "Jurgen Doser (doserj) ", - "MirceaKitsune ", - "dannydark ", - "0gb.us <0gb.us@0gb.us>", - "Guiseppe Bilotta (Oblomov) ", - "Jonathan Neuschafer ", - "Nils Dagsson Moskopp (erlehmann) ", - "Břetislav Štec (t0suj4/TBC_x)", - "Aaron Suen ", - "Constantin Wenger (SpeedProg) ", - "matttpt ", - "JacobF ", - "TriBlade9 ", - "Zefram ", + "Gregory Currie (gregorycu) [optimisation]", + "Diego Martínez (kaeza) ", + "T4im [Profiler]", + "TeTpaAka [Hand overriding, nametag colors]", + "HybridDog [Fixes]", + "Duane Robertson [MGValleys]", + "neoascetic [OS X Fixes]", + "TriBlade9 [Audiovisuals]", + "Jurgen Doser (doserj) [Fixes]", + "MirceaKitsune [Audiovisuals]", + "Guiseppe Bilotta (Oblomov) [Fixes]", + "matttpt [Fixes]", + "Nils Dagsson Moskopp (erlehmann) [Minetest Logo]", + "Jeija [HTTP, particles]", } +local function buildCreditList(source) + ret = {} + for i = 1, #source do + ret[i] = core.formspec_escape(source[i]) + end + return table.concat(ret, ",,") +end + return { name = "credits", caption = fgettext("Credits"), @@ -87,13 +94,13 @@ return { "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. "table[3.5,-0.25;8.5,6.05;list_credits;" .. "#FFFF00," .. fgettext("Core Developers") .. ",," .. - table.concat(core_developers, ",,") .. ",,," .. + buildCreditList(core_developers) .. ",,," .. "#FFFF00," .. fgettext("Active Contributors") .. ",," .. - table.concat(active_contributors, ",,") .. ",,," .. + buildCreditList(active_contributors) .. ",,," .. "#FFFF00," .. fgettext("Previous Core Developers") ..",," .. - table.concat(previous_core_developers, ",,") .. ",,," .. + buildCreditList(previous_core_developers) .. ",,," .. "#FFFF00," .. fgettext("Previous Contributors") .. ",," .. - table.concat(previous_contributors, ",,") .. "," .. + buildCreditList(previous_contributors) .. "," .. ";1]" end } -- cgit v1.2.3