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
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
if not object:is_player()
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
local entity = not object:is_player() and object:get_luaentity()
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
and posob.y - pos.y <= 0.85
and posob.y - pos.y >= 0.3 then
inv:add_item("main",
ItemStack(object:get_luaentity().itemstring))
inv:add_item("main", ItemStack(entity.itemstring))
object:get_luaentity().itemstring = ""
entity.itemstring = ""
object:remove()
end
end

@ -30,25 +30,20 @@ dofile(MP.."/abms.lua")
-- Formspec handling
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
return
end
local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
local meta = minetest.get_meta(pos)
local eject_setting = meta:get_string("eject") == "true"
local filter_all_setting = meta:get_string("filter_all") == "true"
if fields.eject then
if eject_setting then
meta:set_string("eject", nil)
else
meta:set_string("eject", "true")
end
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
if filter_all_setting then
meta:set_string("filter_all", nil)
else
meta:set_string("filter_all", "true")
end
end
local filter_all_setting = meta:get_string("filter_all") == "true"
meta:set_string("filter_all", filter_all_setting and "" or "true")
end
end)