milan2018_v3 #28
1 changed files with 15 additions and 53 deletions
|
@ -81,70 +81,32 @@ minetest.register_node("digilines:chest", {
|
|||
}
|
||||
},
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, front=1, bottom=1, top=1},
|
||||
connects = function(i,param2)
|
||||
return not pipeworks.connects.facingFront(i,param2)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
can_insert = function(pos, _, stack)
|
||||
return can_insert(pos, stack)
|
||||
end,
|
||||
insert_object = function(pos, _, stack)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local leftover = inv:add_item("main", stack)
|
||||
local count = leftover:get_count()
|
||||
if count == 0 then
|
||||
local derpstack = stack:get_name()..' 1'
|
||||
if not inv:room_for_item("main", derpstack) then
|
||||
-- when you can't put a single more of whatever you just put,
|
||||
-- you'll get a put for it, then a full
|
||||
sendMessage(pos,"full "..maybeString(stack)..' '..tostring(count))
|
||||
end
|
||||
else
|
||||
-- this happens when the chest has received two stacks in a row and
|
||||
-- filled up exactly with the first one.
|
||||
-- You get a put for the first stack, a put for the second
|
||||
-- and then a overflow with the first in stack and the second in leftover
|
||||
-- and NO full?
|
||||
sendMessage(pos,"overflow "..maybeString(stack)..' '..tostring(count))
|
||||
end
|
||||
return leftover
|
||||
end,
|
||||
},
|
||||
allow_metadata_inventory_put = function(pos, _, _, stack)
|
||||
if not can_insert(pos, stack) then
|
||||
sendMessage(pos,"uoverflow "..maybeString(stack))
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
|
||||
minetest.log("action", player:get_player_name().." moves stuff in chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, _, _, stack, player)
|
||||
local channel = minetest.get_meta(pos):get_string("channel")
|
||||
local send = function(msg)
|
||||
sendMessage(pos,msg,channel)
|
||||
end
|
||||
-- direction is only for furnaces
|
||||
-- as the item has already been put, can_insert should return false if the chest is now full.
|
||||
local derpstack = stack:get_name()..' 1'
|
||||
if can_insert(pos,derpstack) then
|
||||
send("uput "..maybeString(stack))
|
||||
else
|
||||
send("ufull "..maybeString(stack))
|
||||
end
|
||||
sendMessage(pos, "uput "..maybeString(stack), channel)
|
||||
minetest.log("action", player:get_player_name().." puts stuff into chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, _, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local channel = meta:get_string("channel")
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty(listname) then
|
||||
sendMessage(pos, "empty", channel)
|
||||
end
|
||||
sendMessage(pos,"utake "..maybeString(stack))
|
||||
local channel = minetest.get_meta(pos):get_string("channel")
|
||||
sendMessage(pos, "utake "..maybeString(stack), channel)
|
||||
minetest.log("action", player:get_player_name().." takes stuff from chest at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
|
Loading…
Reference in a new issue