fixed resizing bug and prevent cells within cells

This commit is contained in:
theFox6 2023-09-02 13:29:10 +02:00
parent 8279436cde
commit f5aee436d0
No known key found for this signature in database
GPG Key ID: 810803FF29A86CCC
2 changed files with 17 additions and 7 deletions

@ -208,6 +208,9 @@ local function create_inventory(net)
allow_put = function(inv, listname, index, stack)
local inside_stack = inv:get_stack(listname, index)
local stack_name = stack:get_name()
if minetest.get_item_group(stack_name, "microexpansion_cell") > 0 then
return 0
end
-- improve performance by skipping unnessecary calls
if inside_stack:get_name() ~= stack_name or inside_stack:get_count() >= inside_stack:get_stack_max() then
if inv:get_stack(listname, index+1):get_name() ~= "" then
@ -239,7 +242,8 @@ local function create_inventory(net)
return math.min(stack:get_count(),stack:get_stack_max())
end,
on_take = function()
net:set_storage_space(true)
--update the inventory size in the next step as it is not allowed in on_take
minetest.after(0, function() net:set_storage_space(true) end)
end
})
end

@ -311,7 +311,10 @@ microexpansion.register_node("drive", {
inv:set_size("main", 10)
me.send_event(pos,"connect")
end,
can_dig = function(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player) then
return false
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
@ -320,10 +323,10 @@ microexpansion.register_node("drive", {
me.send_event(pos,"disconnect")
end,
allow_metadata_inventory_put = function(_, _, _, stack)
if minetest.get_item_group(stack:get_name(), "microexpansion_cell") ~= 0 then
return 1
else
if minetest.is_protected(pos, player) or minetest.get_item_group(stack:get_name(), "microexpansion_cell") == 0 then
return 0
else
return 1
end
end,
on_metadata_inventory_put = function(pos, _, _, stack)
@ -345,8 +348,11 @@ microexpansion.register_node("drive", {
end
me.send_event(pos,"items",{net=network})
end,
allow_metadata_inventory_take = function(pos,_,_,stack) --args: pos, listname, index, stack, player
local network = me.get_connected_network(pos)
allow_metadata_inventory_take = function(pos,_,_,stack, player) --args: pos, listname, index, stack, player
if minetest.is_protected(pos, player) then
return 0
end
local network = me.get_connected_network(pos)
write_drive_cells(pos,network)
return stack:get_count()
end,