mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-22 15:13:51 +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)
|
allow_put = function(inv, listname, index, stack)
|
||||||
local inside_stack = inv:get_stack(listname, index)
|
local inside_stack = inv:get_stack(listname, index)
|
||||||
local stack_name = stack:get_name()
|
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
|
-- 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 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
|
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())
|
return math.min(stack:get_count(),stack:get_stack_max())
|
||||||
end,
|
end,
|
||||||
on_take = function()
|
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
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -311,7 +311,10 @@ microexpansion.register_node("drive", {
|
|||||||
inv:set_size("main", 10)
|
inv:set_size("main", 10)
|
||||||
me.send_event(pos,"connect")
|
me.send_event(pos,"connect")
|
||||||
end,
|
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 meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main")
|
return inv:is_empty("main")
|
||||||
@ -320,10 +323,10 @@ microexpansion.register_node("drive", {
|
|||||||
me.send_event(pos,"disconnect")
|
me.send_event(pos,"disconnect")
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(_, _, _, stack)
|
allow_metadata_inventory_put = function(_, _, _, stack)
|
||||||
if minetest.get_item_group(stack:get_name(), "microexpansion_cell") ~= 0 then
|
if minetest.is_protected(pos, player) or minetest.get_item_group(stack:get_name(), "microexpansion_cell") == 0 then
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_put = function(pos, _, _, stack)
|
on_metadata_inventory_put = function(pos, _, _, stack)
|
||||||
@ -345,8 +348,11 @@ microexpansion.register_node("drive", {
|
|||||||
end
|
end
|
||||||
me.send_event(pos,"items",{net=network})
|
me.send_event(pos,"items",{net=network})
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_take = function(pos,_,_,stack) --args: pos, listname, index, stack, player
|
allow_metadata_inventory_take = function(pos,_,_,stack, player) --args: pos, listname, index, stack, player
|
||||||
local network = me.get_connected_network(pos)
|
if minetest.is_protected(pos, player) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
local network = me.get_connected_network(pos)
|
||||||
write_drive_cells(pos,network)
|
write_drive_cells(pos,network)
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user