From e91813755cd374881063a852f80dfb6fc043cefa Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Thu, 21 Oct 2021 00:28:35 +0200 Subject: [PATCH] Builtin: minor fixes --- builtin/game/chat.lua | 3 ++- builtin/game/falling.lua | 1 + builtin/game/hunger.lua | 2 +- builtin/game/item_entity.lua | 3 ++- builtin/game/misc.lua | 4 ---- builtin/game/register.lua | 14 +++----------- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/builtin/game/chat.lua b/builtin/game/chat.lua index 5343b07a5..bda39bb27 100644 --- a/builtin/game/chat.lua +++ b/builtin/game/chat.lua @@ -1089,7 +1089,7 @@ core.register_chatcommand("msg", { end core.log("action", "PM from " .. name .. " to " .. sendto .. ": " .. message) - core.chat_send_player(sendto, minetest.colorize("green", + core.chat_send_player(sendto, core.colorize("green", "PM from " .. name .. ": " .. message)) return true, "Message sent." end, @@ -1200,6 +1200,7 @@ core.register_chatcommand("setspawn", { end local pos = core.pos_to_string(player:get_pos(), 1) core.settings:set("static_spawnpoint", pos) + core.settings:write() return true, "The spawn point are set to " .. pos end }) diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index bd1fe8c89..acd0f1eee 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -442,6 +442,7 @@ function core.spawn_falling_node(pos) return convert_to_falling_node(pos, node) end +-- Declared as local function above function drop_attached_node(p) local n = core.get_node(p) local drops = core.get_node_drops(n, "") diff --git a/builtin/game/hunger.lua b/builtin/game/hunger.lua index 99f9ee908..6f02bda90 100644 --- a/builtin/game/hunger.lua +++ b/builtin/game/hunger.lua @@ -139,7 +139,7 @@ function hunger.set_poisoned(player, poisoned) end local function poison_tick(name, ticks, interval, elapsed) - local player = minetest.get_player_by_name(name) + local player = core.get_player_by_name(name) if not player or not hunger.is_poisoned(player) then return elseif elapsed > ticks then diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index 5eefb5985..9c11789d8 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -2,6 +2,7 @@ local abs, min, floor, random, pi = math.abs, math.min, math.floor, math.random, math.pi local vnormalize = vector.normalize + function core.spawn_item(pos, item) -- Take item in any format local stack = ItemStack(item) @@ -213,7 +214,6 @@ core.register_entity(":__builtin:item", { y = pos.y + self.object:get_properties().collisionbox[2] - 0.05, z = pos.z }) - local node_inside = core.get_node_or_nil(pos) -- Delete in 'ignore' nodes if node and node.name == "ignore" then self.itemstring = "" @@ -315,6 +315,7 @@ core.register_entity(":__builtin:item", { local vel = self.object:get_velocity() local def = node and core.registered_nodes[node.name] + local node_inside = core.get_node_or_nil(pos) local def_inside = node_inside and core.registered_nodes[node_inside.name] -- local is_moving = (def and not def.walkable) or -- vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0 diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index acf3608d2..5871b102b 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -179,10 +179,6 @@ function core.is_protected(pos, name) return false end -function core.is_protected_action() - return false -end - function core.record_protection_violation(pos, name) for _, func in pairs(core.registered_on_protection_violation) do func(pos, name) diff --git a/builtin/game/register.lua b/builtin/game/register.lua index c2a686806..418dc06ec 100644 --- a/builtin/game/register.lua +++ b/builtin/game/register.lua @@ -107,9 +107,6 @@ function core.register_entity(name, prototype) prototype.mod_origin = core.get_current_modname() or "??" end --- Intllib -Sl = intllib.make_gettext_pair("locales") - function core.register_item(name, itemdef) -- Check name if name == nil then @@ -159,12 +156,6 @@ function core.register_item(name, itemdef) itemdef.paramtype2 = "flowingliquid" end - -- Intllib - if itemdef.description and itemdef.description ~= "" then - itemdef.description = Sl(itemdef.description:gsub("@", "\001")) - :gsub("\001", "@") - end - -- BEGIN Legacy stuff if itemdef.cookresult_itemstring ~= nil and itemdef.cookresult_itemstring ~= "" then core.register_craft({ @@ -390,12 +381,13 @@ core.register_node(":ignore", { }) -- The hand (bare definition) +local creative_mode = core.settings:get_bool("creative_mode") core.register_item(":", { type = "none", - wield_image = "blank.png", + wield_image = "wieldhand.png", tool_capabilities = { full_punch_interval = 0.5, - damage_groups = {fleshy = core.settings:get_bool("creative_mode") and 5 or 1} + damage_groups = {fleshy = creative_mode and 5 or 1} }, groups = {not_in_creative_inventory=1}, })