milan2018_v2 #27

Closed
milan wants to merge 66 commits from milan2018_v2 into master
Showing only changes of commit 4fc0b0cad6 - Show all commits

View file

@ -71,7 +71,7 @@ minetest.register_node("digilines:chest", {
return return
end end
if fields.channel ~= nil then if fields.channel ~= nil then
minetest.get_meta(pos):set_string("channel",fields.channel) minetest.get_meta(pos):set_string("channel", fields.channel)
end end
end, end,
digiline = { digiline = {
@ -81,70 +81,32 @@ minetest.register_node("digilines:chest", {
} }
}, },
tube = { 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}, 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", 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) on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
minetest.log("action", player:get_player_name().." moves stuff in chest at "..minetest.pos_to_string(pos)) minetest.log("action", player:get_player_name().." moves stuff in chest at "..minetest.pos_to_string(pos))
end, end,
on_metadata_inventory_put = function(pos, _, _, stack, player) on_metadata_inventory_put = function(pos, _, _, stack, player)
local channel = minetest.get_meta(pos):get_string("channel") local channel = minetest.get_meta(pos):get_string("channel")
local send = function(msg) sendMessage(pos, "uput "..maybeString(stack), channel)
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
minetest.log("action", player:get_player_name().." puts stuff into chest at "..minetest.pos_to_string(pos)) minetest.log("action", player:get_player_name().." puts stuff into chest at "..minetest.pos_to_string(pos))
end, end,
on_metadata_inventory_take = function(pos, listname, _, stack, player) on_metadata_inventory_take = function(pos, listname, _, stack, player)
local meta = minetest.get_meta(pos) local channel = minetest.get_meta(pos):get_string("channel")
local channel = meta:get_string("channel") sendMessage(pos, "utake "..maybeString(stack), channel)
local inv = meta:get_inventory()
if inv:is_empty(listname) then
sendMessage(pos, "empty", channel)
end
sendMessage(pos,"utake "..maybeString(stack))
minetest.log("action", player:get_player_name().." takes stuff from chest at "..minetest.pos_to_string(pos)) minetest.log("action", player:get_player_name().." takes stuff from chest at "..minetest.pos_to_string(pos))
end end,
}) })
minetest.register_craft({ minetest.register_craft({