mirror of
https://github.com/minetest-mods/hopper.git
synced 2024-12-22 21:32:29 +01:00
Maintenance: fix deprecation warnings
This commit is contained in:
parent
950c525608
commit
f925fd9568
22
abms.lua
22
abms.lua
@ -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
|
||||||
|
23
init.lua
23
init.lua
@ -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
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
|
local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
|
||||||
local meta = minetest.get_meta(pos)
|
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 fields.eject then
|
||||||
if eject_setting then
|
local eject_setting = meta:get_string("eject") == "true"
|
||||||
meta:set_string("eject", nil)
|
-- "" deletes the key
|
||||||
else
|
meta:set_string("eject", eject_setting and "" or "true")
|
||||||
meta:set_string("eject", "true")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if fields.filter_all then
|
if fields.filter_all then
|
||||||
if filter_all_setting then
|
local filter_all_setting = meta:get_string("filter_all") == "true"
|
||||||
meta:set_string("filter_all", nil)
|
meta:set_string("filter_all", filter_all_setting and "" or "true")
|
||||||
else
|
|
||||||
meta:set_string("filter_all", "true")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user