From ce25d7c04be4763bcfcd6021638100ca0320c626 Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Mon, 3 Jun 2019 20:55:18 +0200 Subject: [PATCH] Backport minor builtin changes and fix shutdown delay command --- builtin/client/init.lua | 2 +- builtin/game/chatcommands.lua | 46 ++++++++++++++++++----------------- builtin/game/item.lua | 4 +-- builtin/game/register.lua | 8 ------ builtin/game/static_spawn.lua | 12 ++++----- 5 files changed, 32 insertions(+), 40 deletions(-) diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 3ac34d845..9bd0ce691 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -12,7 +12,7 @@ dofile(commonpath .. "vector.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") .."]" + "label[5,2;" .. fgettext("You died.") .. "]button_exit[3.5,3;4,0.5;btn_respawn;".. fgettext("Respawn") .."]" core.show_formspec("bultin:death", formspec) end) diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 91feedd40..f209afadc 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -92,7 +92,7 @@ core.register_chatcommand("admin", { }) core.register_chatcommand("privs", { - params = "", + params = "[]", description = "Print privileges of player", func = function(caller, param) param = param:trim() @@ -145,7 +145,7 @@ local function handle_grant_command(caller, grantname, grantprivstr) end core.register_chatcommand("grant", { - params = " |all", + params = " ( | all)", description = "Give privilege to player", func = function(name, param) local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)") @@ -168,7 +168,7 @@ core.register_chatcommand("grantme", { }) core.register_chatcommand("revoke", { - params = " |all", + params = " ( | all)", description = "Remove privilege from player", privs = {}, func = function(name, param) @@ -305,7 +305,7 @@ core.register_chatcommand("remove_player", { }) core.register_chatcommand("teleport", { - params = ",, | | ,, | ", + params = ",, | | ( ,,) | ( )", description = "Teleport to player or position", privs = {teleport=true}, func = function(name, param) @@ -413,7 +413,7 @@ core.register_chatcommand("teleport", { }) core.register_chatcommand("set", { - params = "[-n] | ", + params = "([-n] ) | ", description = "Set or read server configuration setting", privs = {server=true}, func = function(name, param) @@ -468,9 +468,9 @@ local function emergeblocks_progress_update(ctx) end core.register_chatcommand("emergeblocks", { - params = "(here [radius]) | ( )", + params = "(here []) | ( )", description = "Load (or, if nonexistent, generate) map blocks " - .. "contained in area pos1 to pos2", + .. "contained in area pos1 to pos2 ( and must be in parentheses)", privs = {server=true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -494,8 +494,9 @@ core.register_chatcommand("emergeblocks", { }) core.register_chatcommand("deleteblocks", { - params = "(here [radius]) | ( )", - description = "Delete map blocks contained in area pos1 to pos2", + params = "(here []) | ( )", + description = "Delete map blocks contained in area pos1 to pos2 " + .. "( and must be in parentheses)", privs = {server=true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -513,8 +514,9 @@ core.register_chatcommand("deleteblocks", { }) core.register_chatcommand("fixlight", { - params = "(here [radius]) | ( )", - description = "Resets lighting in the area between pos1 and pos2", + params = "(here []) | ( )", + description = "Resets lighting in the area between pos1 and pos2 " + .. "( and must be in parentheses)", privs = {server = true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -653,15 +655,15 @@ core.register_chatcommand("pulverize", { core.rollback_punch_callbacks = {} core.register_on_punchnode(function(pos, node, puncher) - local name = puncher and puncher:get_player_name() - if name and core.rollback_punch_callbacks[name] then + local name = puncher:get_player_name() + if core.rollback_punch_callbacks[name] then core.rollback_punch_callbacks[name](pos, node, puncher) core.rollback_punch_callbacks[name] = nil end end) core.register_chatcommand("rollback_check", { - params = "[] [] [limit]", + params = "[] [] []", 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", @@ -714,7 +716,7 @@ core.register_chatcommand("rollback_check", { }) core.register_chatcommand("rollback", { - params = " [] | : []", + params = "( []) | (: [])", description = "Revert actions of a player. Default for is 60", privs = {rollback=true}, func = function(name, param) @@ -806,15 +808,15 @@ core.register_chatcommand("days", { }) core.register_chatcommand("shutdown", { - description = "Shutdown server", - params = "[delay_in_seconds (non-negative number, or -1 to cancel)] [reconnect] [message]", + params = "[ | -1] [reconnect] []", + description = "Shutdown server (-1 cancels a delayed shutdown)", privs = {server=true}, func = function(name, param) local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)") message = message or "" if delay ~= "" then - delay = tonumber(delay) or 0 + delay = tonumber(param) or 0 else delay = 0 core.log("action", name .. " shuts down server") @@ -845,7 +847,7 @@ core.register_chatcommand("ban", { }) core.register_chatcommand("unban", { - params = "", + params = " | ", description = "Remove IP ban", privs = {ban=true}, func = function(name, param) @@ -858,7 +860,7 @@ core.register_chatcommand("unban", { }) core.register_chatcommand("kick", { - params = " [reason]", + params = " []", description = "Kick a player", privs = {kick=true}, func = function(name, param) @@ -923,7 +925,7 @@ core.register_chatcommand("msg", { }) core.register_chatcommand("last-login", { - params = "[name]", + params = "[]", description = "Get the last login time of a player", func = function(name, param) if param == "" then @@ -940,7 +942,7 @@ core.register_chatcommand("last-login", { }) core.register_chatcommand("clearinv", { - params = "[name]", + params = "[]", description = "Clear the inventory of yourself or another player", func = function(name, param) local player diff --git a/builtin/game/item.lua b/builtin/game/item.lua index d6760f0c9..1b6e6346a 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -197,7 +197,7 @@ function core.get_node_drops(node, toolname) return {nodename} elseif type(drop) == "string" then -- itemstring drop - return {drop} + return drop ~= "" and {drop} or {} elseif drop.items == nil then -- drop = {} to disable default drop return {} @@ -715,7 +715,7 @@ core.nodedef_default = { liquid_alternative_flowing = "", liquid_alternative_source = "", liquid_viscosity = 0, - drowning = 4, + drowning = 0, light_source = 0, damage_per_second = 0, selection_box = {type="regular"}, diff --git a/builtin/game/register.lua b/builtin/game/register.lua index a7347d9fe..09a15f243 100644 --- a/builtin/game/register.lua +++ b/builtin/game/register.lua @@ -116,8 +116,6 @@ function core.register_item(name, itemdef) end itemdef.name = name - local is_overriding = core.registered_items[name] - -- Apply defaults and add to registered_* table if itemdef.type == "node" then -- Use the nodebox as selection box if it's not set manually @@ -179,13 +177,7 @@ function core.register_item(name, itemdef) --core.log("Registering item: " .. itemdef.name) core.registered_items[itemdef.name] = itemdef core.registered_aliases[itemdef.name] = nil - - -- Used to allow builtin to register ignore to registered_items - if name ~= "ignore" then register_item_raw(itemdef) - elseif is_overriding then - core.log("warning", "Attempted redefinition of \"ignore\"") - end end function core.unregister_item(name) diff --git a/builtin/game/static_spawn.lua b/builtin/game/static_spawn.lua index 3f2c38677..06cd36a3e 100644 --- a/builtin/game/static_spawn.lua +++ b/builtin/game/static_spawn.lua @@ -1,14 +1,12 @@ -- Minetest: builtin/static_spawn.lua -local function warn_invalid_static_spawnpoint() - if core.settings:get("static_spawnpoint") and +local static_spawnpoint_string = core.settings:get("static_spawnpoint") + if static_spawnpoint_string and + static_spawnpoint_string ~= "" and not core.setting_get_pos("static_spawnpoint") then - core.log("error", "The static_spawnpoint setting is invalid: \"".. - core.settings:get("static_spawnpoint").."\"") + error('The static_spawnpoint setting is invalid: "' .. + static_spawnpoint_string .. '"') end -end - -warn_invalid_static_spawnpoint() local function put_player_in_spawn(player_obj) local static_spawnpoint = core.setting_get_pos("static_spawnpoint")