diff options
Diffstat (limited to 'builtin/client')
-rw-r--r-- | builtin/client/chatcommands.lua | 31 | ||||
-rw-r--r-- | builtin/client/death_formspec.lua | 16 | ||||
-rw-r--r-- | builtin/client/init.lua | 5 | ||||
-rw-r--r-- | builtin/client/register.lua | 20 | ||||
-rw-r--r-- | builtin/client/util.lua | 23 |
5 files changed, 48 insertions, 47 deletions
diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 5cb1b40bb..83b7f7b14 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -1,6 +1,5 @@ -- Minetest: builtin/client/chatcommands.lua - core.register_on_sending_chat_message(function(message) if message:sub(1,2) == ".." then return false @@ -37,34 +36,8 @@ core.register_on_sending_chat_message(function(message) return true end) -core.register_chatcommand("list_players", { - description = core.gettext("List online players"), - func = function(param) - local player_names = core.get_player_names() - if not player_names then - return false, core.gettext("This command is disabled by server.") - end - - local players = table.concat(player_names, ", ") - return true, core.gettext("Online players: ") .. players - end -}) - -core.register_chatcommand("disconnect", { - description = core.gettext("Exit to main menu"), - func = function(param) - 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/client/death_formspec.lua b/builtin/client/death_formspec.lua deleted file mode 100644 index e755ac5c1..000000000 --- a/builtin/client/death_formspec.lua +++ /dev/null @@ -1,16 +0,0 @@ --- CSM death formspec. Only used when clientside modding is enabled, otherwise --- handled by the engine. - -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/init.lua b/builtin/client/init.lua index 9633a7c71..ee344e7bc 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -6,6 +6,7 @@ local commonpath = scriptpath.."common"..DIR_DELIM dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "chatcommands.lua") -dofile(clientpath .. "chatcommands.lua") dofile(commonpath .. "vector.lua") -dofile(clientpath .. "death_formspec.lua") +dofile(clientpath .. "util.lua") +dofile(clientpath .. "chatcommands.lua") + diff --git a/builtin/client/register.lua b/builtin/client/register.lua index c1b4965c1..071220a43 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -40,6 +40,26 @@ function core.run_callbacks(callbacks, mode, ...) return ret end +function core.override_item(name, redefinition) + if redefinition.name ~= nil then + error("Attempt to redefine name of "..name.." to "..dump(redefinition.name), 2) + end + if redefinition.type ~= nil then + error("Attempt to redefine type of "..name.." to "..dump(redefinition.type), 2) + end + local itemdef = core.get_item_def(name) + if not itemdef then + error("Attempt to override non-existent item "..name, 2) + end + local nodedef = core.get_node_def(name) + table.combine(itemdef, nodedef) + + for k, v in pairs(redefinition) do + rawset(itemdef, k, v) + end + core.register_item_raw(itemdef) +end + -- -- Callback registration -- diff --git a/builtin/client/util.lua b/builtin/client/util.lua new file mode 100644 index 000000000..595922262 --- /dev/null +++ b/builtin/client/util.lua @@ -0,0 +1,23 @@ +function core.parse_pos(param) + local p = {} + p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$") + for k, v in pairs(p) do + if p[k] == "~" then + p[k] = 0 + else + p[k] = tonumber(v) + end + end + if p.x and p.y and p.z then + return true, p + end + return false, "Invalid position (" .. param .. ")" +end + +function core.parse_relative_pos(param) + local success, pos = core.parse_pos(param) + if success then pos = vector.round(vector.add(core.localplayer:get_pos(), pos)) end + return success, pos +end + +core.anticheat_protection = minetest.settings:get_bool("anticheat_protection") |