mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-22 07:03:45 +01:00
fixed resizing bug and prevent cells within cells
This commit is contained in:
parent
8279436cde
commit
f5aee436d0
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user