From 178cb9340dcd1ec0d6430df26208b70db1e1de29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikita=20Wi=C5=9Bniewski?= Date: Mon, 16 Sep 2024 12:12:55 +0200 Subject: [PATCH] Clean-up `set_string(..., nil)` usage (fixes #4639) (#4641) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4641 Reviewed-by: kno10 Co-authored-by: Mikita Wiśniewski Co-committed-by: Mikita Wiśniewski --- mods/ENTITIES/mobs_mc/villager.lua | 12 ++++++------ mods/ITEMS/mcl_campfires/api.lua | 12 ++++++------ mods/ITEMS/mcl_stonecutter/init.lua | 1 - mods/PLAYER/mcl_spawn/init.lua | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index b1e291037..47b4cb470 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -818,7 +818,7 @@ local function find_closest_bed (self) if (owned_by and owned_by == self._id) then mcl_log("Clear as already owned by me.") - bed_meta:set_string("villager", nil) + bed_meta:set_string("villager", "") owned_by = nil end @@ -1279,7 +1279,7 @@ local function validate_jobsite(self) mcl_log("Jobsite far, so resettle: " .. tostring(resettle)) if resettle then local m = minetest.get_meta(self._jobsite) - m:set_string("villager", nil) + m:set_string("villager", "") remove_job (self) return false end @@ -1421,7 +1421,7 @@ local function validate_bed(self) mcl_log("Bed far, so resettle: " .. tostring(resettle)) if resettle then mcl_log("Resettled. Ditch bed.") - m:set_string("villager", nil) + m:set_string("villager", "") self._bed = nil bed_valid = false return false @@ -1431,7 +1431,7 @@ local function validate_bed(self) mcl_log("Player owner: " .. owned_by_player) if owned_by_player ~= "" then mcl_log("Player owns this. Villager won't take this.") - m:set_string("villager", nil) + m:set_string("villager", "") self._bed = nil bed_valid = false return false @@ -2300,13 +2300,13 @@ mcl_mobs.register_mob("mobs_mc:villager", { local bed = self._bed if bed then local bed_meta = minetest.get_meta(bed) - bed_meta:set_string("villager", nil) + bed_meta:set_string("villager", "") mcl_log("Died, so bye bye bed") end local jobsite = self._jobsite if jobsite then local jobsite_meta = minetest.get_meta(jobsite) - jobsite_meta:set_string("villager", nil) + jobsite_meta:set_string("villager", "") mcl_log("Died, so bye bye jobsite") end diff --git a/mods/ITEMS/mcl_campfires/api.lua b/mods/ITEMS/mcl_campfires/api.lua index 98318f3f1..bacbdeccc 100644 --- a/mods/ITEMS/mcl_campfires/api.lua +++ b/mods/ITEMS/mcl_campfires/api.lua @@ -39,9 +39,9 @@ local function drop_items(pos, node, oldmeta) if food_entity:get_luaentity().name == "mcl_campfires:food_entity" then food_entity:remove() for i = 1, 4 do - meta:set_string("food_x_"..tostring(i), nil) - meta:set_string("food_y_"..tostring(i), nil) - meta:set_string("food_z_"..tostring(i), nil) + meta:set_string("food_x_"..tostring(i), "") + meta:set_string("food_y_"..tostring(i), "") + meta:set_string("food_z_"..tostring(i), "") end end end @@ -135,9 +135,9 @@ function mcl_campfires.cook_item(pos, elapsed) if cooked then if food_entity then food_entity:remove() -- Remove visual food entity - meta:set_string("food_x_"..tostring(i), nil) - meta:set_string("food_y_"..tostring(i), nil) - meta:set_string("food_z_"..tostring(i), nil) + meta:set_string("food_x_"..tostring(i), "") + meta:set_string("food_y_"..tostring(i), "") + meta:set_string("food_z_"..tostring(i), "") minetest.add_item(pos, cooked.item) -- Drop Cooked Item -- Throw some Experience Points because why not? -- Food is cooked, xp is deserved for using this unique cooking method. Take that Minecraft ;) diff --git a/mods/ITEMS/mcl_stonecutter/init.lua b/mods/ITEMS/mcl_stonecutter/init.lua index 0b2f6f166..2bba9528a 100644 --- a/mods/ITEMS/mcl_stonecutter/init.lua +++ b/mods/ITEMS/mcl_stonecutter/init.lua @@ -279,7 +279,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) for field_name, value in pairs(fields) do if field_name ~= "scroll" then local itemname = fieldname_to_itemname(field_name) - player:get_meta():set_string("mcl_stonecutter:selected", itemname) set_selected_item(player, itemname) update_stonecutter_slots(player) mcl_stonecutter.show_stonecutter_form(player) diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index 89ededeed..7bf27b0f9 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -453,7 +453,7 @@ function mcl_spawn.set_spawn_pos(player, pos, message) -- Pass in villager as arg. Shouldn't know about villagers if bed_bottom_meta then mcl_log("Removing villager from bed bottom meta") - bed_bottom_meta:set_string("villager", nil) + bed_bottom_meta:set_string("villager", "") else mcl_log("Cannot remove villager from bed bottom meta") end