Clean-up set_string(..., nil) usage (fixes #4639) (#4641)

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4641
Reviewed-by: kno10 <kno10@noreply.git.minetest.land>
Co-authored-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-committed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
This commit is contained in:
Mikita Wiśniewski 2024-09-16 12:12:55 +02:00 committed by the-real-herowl
parent f219e5f4ae
commit 178cb9340d
4 changed files with 13 additions and 14 deletions

View file

@ -818,7 +818,7 @@ local function find_closest_bed (self)
if (owned_by and owned_by == self._id) then if (owned_by and owned_by == self._id) then
mcl_log("Clear as already owned by me.") mcl_log("Clear as already owned by me.")
bed_meta:set_string("villager", nil) bed_meta:set_string("villager", "")
owned_by = nil owned_by = nil
end end
@ -1279,7 +1279,7 @@ local function validate_jobsite(self)
mcl_log("Jobsite far, so resettle: " .. tostring(resettle)) mcl_log("Jobsite far, so resettle: " .. tostring(resettle))
if resettle then if resettle then
local m = minetest.get_meta(self._jobsite) local m = minetest.get_meta(self._jobsite)
m:set_string("villager", nil) m:set_string("villager", "")
remove_job (self) remove_job (self)
return false return false
end end
@ -1421,7 +1421,7 @@ local function validate_bed(self)
mcl_log("Bed far, so resettle: " .. tostring(resettle)) mcl_log("Bed far, so resettle: " .. tostring(resettle))
if resettle then if resettle then
mcl_log("Resettled. Ditch bed.") mcl_log("Resettled. Ditch bed.")
m:set_string("villager", nil) m:set_string("villager", "")
self._bed = nil self._bed = nil
bed_valid = false bed_valid = false
return false return false
@ -1431,7 +1431,7 @@ local function validate_bed(self)
mcl_log("Player owner: " .. owned_by_player) mcl_log("Player owner: " .. owned_by_player)
if owned_by_player ~= "" then if owned_by_player ~= "" then
mcl_log("Player owns this. Villager won't take this.") mcl_log("Player owns this. Villager won't take this.")
m:set_string("villager", nil) m:set_string("villager", "")
self._bed = nil self._bed = nil
bed_valid = false bed_valid = false
return false return false
@ -2300,13 +2300,13 @@ mcl_mobs.register_mob("mobs_mc:villager", {
local bed = self._bed local bed = self._bed
if bed then if bed then
local bed_meta = minetest.get_meta(bed) 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") mcl_log("Died, so bye bye bed")
end end
local jobsite = self._jobsite local jobsite = self._jobsite
if jobsite then if jobsite then
local jobsite_meta = minetest.get_meta(jobsite) 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") mcl_log("Died, so bye bye jobsite")
end end

View file

@ -39,9 +39,9 @@ local function drop_items(pos, node, oldmeta)
if food_entity:get_luaentity().name == "mcl_campfires:food_entity" then if food_entity:get_luaentity().name == "mcl_campfires:food_entity" then
food_entity:remove() food_entity:remove()
for i = 1, 4 do for i = 1, 4 do
meta:set_string("food_x_"..tostring(i), nil) meta:set_string("food_x_"..tostring(i), "")
meta:set_string("food_y_"..tostring(i), nil) meta:set_string("food_y_"..tostring(i), "")
meta:set_string("food_z_"..tostring(i), nil) meta:set_string("food_z_"..tostring(i), "")
end end
end end
end end
@ -135,9 +135,9 @@ function mcl_campfires.cook_item(pos, elapsed)
if cooked then if cooked then
if food_entity then if food_entity then
food_entity:remove() -- Remove visual food entity food_entity:remove() -- Remove visual food entity
meta:set_string("food_x_"..tostring(i), nil) meta:set_string("food_x_"..tostring(i), "")
meta:set_string("food_y_"..tostring(i), nil) meta:set_string("food_y_"..tostring(i), "")
meta:set_string("food_z_"..tostring(i), nil) meta:set_string("food_z_"..tostring(i), "")
minetest.add_item(pos, cooked.item) -- Drop Cooked Item minetest.add_item(pos, cooked.item) -- Drop Cooked Item
-- Throw some Experience Points because why not? -- Throw some Experience Points because why not?
-- Food is cooked, xp is deserved for using this unique cooking method. Take that Minecraft ;) -- Food is cooked, xp is deserved for using this unique cooking method. Take that Minecraft ;)

View file

@ -279,7 +279,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
for field_name, value in pairs(fields) do for field_name, value in pairs(fields) do
if field_name ~= "scroll" then if field_name ~= "scroll" then
local itemname = fieldname_to_itemname(field_name) local itemname = fieldname_to_itemname(field_name)
player:get_meta():set_string("mcl_stonecutter:selected", itemname)
set_selected_item(player, itemname) set_selected_item(player, itemname)
update_stonecutter_slots(player) update_stonecutter_slots(player)
mcl_stonecutter.show_stonecutter_form(player) mcl_stonecutter.show_stonecutter_form(player)

View file

@ -453,7 +453,7 @@ function mcl_spawn.set_spawn_pos(player, pos, message)
-- Pass in villager as arg. Shouldn't know about villagers -- Pass in villager as arg. Shouldn't know about villagers
if bed_bottom_meta then if bed_bottom_meta then
mcl_log("Removing villager from bed bottom meta") mcl_log("Removing villager from bed bottom meta")
bed_bottom_meta:set_string("villager", nil) bed_bottom_meta:set_string("villager", "")
else else
mcl_log("Cannot remove villager from bed bottom meta") mcl_log("Cannot remove villager from bed bottom meta")
end end