mirror of
https://github.com/minetest-mods/technic.git
synced 2024-11-04 22:43:52 +01:00
only reject part of itemtack from chest/machine/etc., if possible
(e.g. if there's room for 50 of some item, and you send a stack of 99, 50 are added to the chest and a stack of 49 is rejected and sent on to the next destination)
This commit is contained in:
parent
72c536c04e
commit
af39221df9
@ -103,7 +103,8 @@ minetest.register_node("technic:tool_workshop", {
|
|||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
tube = {
|
tube = {
|
||||||
can_insert = function (pos, node, stack, direction)
|
can_insert = function (pos, node, stack, direction)
|
||||||
return minetest.get_meta(pos):get_inventory():room_for_item("src", stack)
|
local onestack = stack:peek_item(1)
|
||||||
|
return minetest.get_meta(pos):get_inventory():room_for_item("src", onestack)
|
||||||
end,
|
end,
|
||||||
insert_object = function (pos, node, stack, direction)
|
insert_object = function (pos, node, stack, direction)
|
||||||
return minetest.get_meta(pos):get_inventory():add_item("src", stack)
|
return minetest.get_meta(pos):get_inventory():add_item("src", stack)
|
||||||
|
@ -69,7 +69,8 @@ minetest.register_node("technic:injector", {
|
|||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1},
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1},
|
||||||
tube = {
|
tube = {
|
||||||
can_insert = function(pos, node, stack, direction)
|
can_insert = function(pos, node, stack, direction)
|
||||||
return minetest.get_meta(pos):get_inventory():room_for_item("main",stack)
|
local onestack = stack:peek_item(1)
|
||||||
|
return minetest.get_meta(pos):get_inventory():room_for_item("main", onestack)
|
||||||
end,
|
end,
|
||||||
insert_object = function(pos, node, stack, direction)
|
insert_object = function(pos, node, stack, direction)
|
||||||
return minetest.get_meta(pos):get_inventory():add_item("main", stack)
|
return minetest.get_meta(pos):get_inventory():add_item("main", stack)
|
||||||
|
@ -50,10 +50,11 @@ local tube = {
|
|||||||
end
|
end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
local onestack = stack:peek_item(1)
|
||||||
if direction.y > 0 then
|
if direction.y > 0 then
|
||||||
return inv:room_for_item("src", stack)
|
return inv:room_for_item("src", onestack)
|
||||||
else
|
else
|
||||||
return inv:room_for_item("dst", stack)
|
return inv:room_for_item("dst", onestack)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||||
|
@ -9,7 +9,8 @@ local tube = {
|
|||||||
can_insert = function(pos, node, stack, direction)
|
can_insert = function(pos, node, stack, direction)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:room_for_item("src", stack)
|
local onestack = stack:peek_item(1)
|
||||||
|
return inv:room_for_item("src", onestack)
|
||||||
end,
|
end,
|
||||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ local tube = {
|
|||||||
can_insert = function(pos, node, stack, direction)
|
can_insert = function(pos, node, stack, direction)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:room_for_item("src", stack)
|
local onestack = stack:peek_item(1)
|
||||||
|
return inv:room_for_item("src", onestack)
|
||||||
end,
|
end,
|
||||||
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ technic.chests.tube = {
|
|||||||
can_insert = function(pos, node, stack, direction)
|
can_insert = function(pos, node, stack, direction)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:room_for_item("main",stack)
|
local onestack = stack:peek_item(1)
|
||||||
|
return inv:room_for_item("main", onestack)
|
||||||
end,
|
end,
|
||||||
input_inventory = "main",
|
input_inventory = "main",
|
||||||
connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
|
connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
|
||||||
|
Loading…
Reference in New Issue
Block a user