fix:capture regression; silk wheel improvements

master
root 2022-07-01 22:37:44 +02:00
parent 6632e9d841
commit 096d2d4cd8
6 changed files with 30 additions and 16 deletions

View File

@ -142,7 +142,7 @@ minetest.register_node("petz:beehive", {
end,
on_timer = function(pos)
local meta, honey_count, bee_count, owner = petz.get_beehive_stats(pos)
local meta, honey_count, bee_count = petz.get_beehive_stats(pos)
if bee_count > 0 then --if bee inside
local tpos = {
x = pos. x,
@ -186,7 +186,7 @@ minetest.register_node("petz:beehive", {
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local wielded_item = player:get_wielded_item()
local wielded_item_name = wielded_item:get_name()
local meta, honey_count, bee_count, owner = petz.get_beehive_stats(pos)
local meta, honey_count, bee_count = petz.get_beehive_stats(pos)
local player_name = player:get_player_name()
if petz.settings.protect_beehive then
local owner_name = meta:get_string("owner")

View File

@ -129,7 +129,7 @@ petz.capture = function(self, clicker, put_in_inventory)
end
if self.type == "bee" and self.beehive then
petz.decrease_total_bee_count(self.beehive)
local meta, honey_count, bee_count, owner = petz.get_beehive_stats(self.beehive)
local meta, honey_count, bee_count = petz.get_beehive_stats(self.beehive)
petz.set_infotext_beehive(meta, honey_count, bee_count)
end
petz.remove_tamed_by_owner(self, false)

View File

@ -163,8 +163,9 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
local static_data_table = minetest.deserialize(staticdata)
local captured_mob = false
local baby_born = false
if static_data_table and static_data_table[static_table_name] and static_data_table[static_table_name]["captured"] then
captured_mob = true
if static_data_table and static_data_table["memory"]
and static_data_table["memory"]["captured"] then
captured_mob = true
elseif static_data_table and static_data_table["baby_born"] then
baby_born = true
end
@ -279,13 +280,13 @@ function petz.set_initial_properties(self, staticdata, dtime_s)
for key, value in pairs(petz.dyn_prop) do
local prop_value
if value["type"] == "string" then
prop_value = static_data_table[static_table_name][key]
prop_value = static_data_table["memory"][key]
elseif value["type"] == "int" then
prop_value = tonumber(static_data_table[static_table_name][key])
prop_value = tonumber(static_data_table["memory"][key])
elseif value["type"] == "boolean" then
prop_value = minetest.is_yes(static_data_table[static_table_name][key])
prop_value = minetest.is_yes(static_data_table["memory"][key])
elseif value["type"] == "table" then
prop_value = static_data_table[static_table_name][key]
prop_value = static_data_table["memory"][key]
elseif value["type"] == "player" then
prop_value = nil
end

View File

@ -105,9 +105,22 @@ minetest.register_node("petz:spinning_wheel", {
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta_itemstack = itemstack:get_meta()
local silk_count
if meta_itemstack:contains("silk_count") then
silk_count = meta_itemstack:get_int("silk_count")
else
silk_count = 1
end
local meta = minetest.get_meta(pos)
meta:set_int("silk_count", 1)
meta:set_string("infotext", S("Silk Count").." = "..meta:get_int("silk_count"))
meta:set_int("silk_count", silk_count)
meta:set_string("infotext", S("Silk Count").." = "..silk_count)
end,
preserve_metadata = function(pos, oldnode, oldmeta, drops)
if oldmeta then
drops[1]:get_meta():set_int("silk_count", minetest.get_meta(pos):get_int("silk_count"))
end
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
@ -131,7 +144,7 @@ minetest.register_node("petz:spinning_wheel", {
meta:set_string("infotext", S("Silk Count").." = "..tostring(silk_count))
itemstack:take_item()
minetest.chat_send_player(player_name, S("There are still").." "
..tostring(petz.settings.silk_to_bobbin - silk_count).." "..S("more to create the bobbin."))
..tostring(petz.settings.silk_to_bobbin - silk_count).." "..S("more to create the bobbin."))
return itemstack
end
elseif silk_count == petz.settings.silk_to_bobbin then --get the bobbin
@ -145,8 +158,8 @@ minetest.register_node("petz:spinning_wheel", {
else
inv:add_item("main", stack)
end
meta:set_int("silk_count", 1) --reset the silk count
meta:set_string("infotext", S("Silk Count").." = 1")
meta:set_int("silk_count", 0) --reset the silk count
meta:set_string("infotext", S("Silk Count").." = 0")
minetest.chat_send_player(player_name, S("You got the bobbin!"))
return itemstack
else

View File

@ -91,7 +91,7 @@ function petz.lq_search_beehive(self)
if kitz.drive_to_pos(self, tpos, 1.5, 6.28, 1.01) then
if petz.beehive_exists(self) then
kitz.remove_mob(self)
local meta, honey_count, bee_count, owner = petz.get_beehive_stats(self.beehive)
local meta, honey_count, bee_count = petz.get_beehive_stats(self.beehive)
bee_count = bee_count + 1
meta:set_int("bee_count", bee_count)
honey_count = honey_count + 1

View File

@ -12,7 +12,7 @@ function petz.bee_brain(self)
local beehive_exists = petz.beehive_exists(self)
local meta, honey_count, bee_count
if beehive_exists then
meta, honey_count, bee_count, owner = petz.get_beehive_stats(self.beehive)
meta, honey_count, bee_count = petz.get_beehive_stats(self.beehive)
end
if (self.hp <= 0) or (not(self.queen) and not(petz.beehive_exists(self))) then