Maintenance: fix deprecation warnings

This commit is contained in:
SmallJoker 2024-08-16 22:28:33 +02:00
parent 950c525608
commit f925fd9568
2 changed files with 23 additions and 28 deletions

@ -11,26 +11,26 @@ minetest.register_abm({
end end
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
local posob if not inv then
return
end
for _,object in pairs(minetest.get_objects_inside_radius(pos, 1)) do for _,object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if not object:is_player() local entity = not object:is_player() and object:get_luaentity()
and object:get_luaentity()
and object:get_luaentity().name == "__builtin:item"
and inv
and inv:room_for_item("main",
ItemStack(object:get_luaentity().itemstring)) then
posob = object:getpos() if entity
and entity.name == "__builtin:item"
and inv:room_for_item("main", ItemStack(entity.itemstring)) then
local posob = object:get_pos()
if math.abs(posob.x - pos.x) <= 0.5 if math.abs(posob.x - pos.x) <= 0.5
and posob.y - pos.y <= 0.85 and posob.y - pos.y <= 0.85
and posob.y - pos.y >= 0.3 then and posob.y - pos.y >= 0.3 then
inv:add_item("main", inv:add_item("main", ItemStack(entity.itemstring))
ItemStack(object:get_luaentity().itemstring))
object:get_luaentity().itemstring = "" entity.itemstring = ""
object:remove() object:remove()
end end
end end

@ -30,25 +30,20 @@ dofile(MP.."/abms.lua")
-- Formspec handling -- Formspec handling
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
if "hopper_formspec:" == string.sub(formname, 1, 16) then if string.sub(formname, 1, 16) ~= "hopper_formspec:" then
local pos = minetest.string_to_pos(string.sub(formname, 17, -1)) return
local meta = minetest.get_meta(pos) end
local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
local meta = minetest.get_meta(pos)
if fields.eject then
local eject_setting = meta:get_string("eject") == "true" local eject_setting = meta:get_string("eject") == "true"
-- "" deletes the key
meta:set_string("eject", eject_setting and "" or "true")
end
if fields.filter_all then
local filter_all_setting = meta:get_string("filter_all") == "true" local filter_all_setting = meta:get_string("filter_all") == "true"
if fields.eject then meta:set_string("filter_all", filter_all_setting and "" or "true")
if eject_setting then
meta:set_string("eject", nil)
else
meta:set_string("eject", "true")
end
end
if fields.filter_all then
if filter_all_setting then
meta:set_string("filter_all", nil)
else
meta:set_string("filter_all", "true")
end
end
end end
end) end)