2020-02-08 19:53:11 +01:00
|
|
|
-- Translation support
|
|
|
|
local S = minetest.get_translator("technic_chests")
|
|
|
|
|
2013-12-18 01:15:20 +01:00
|
|
|
technic.chests.groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
|
|
|
tubedevice=1, tubedevice_receiver=1}
|
|
|
|
technic.chests.groups_noinv = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
|
|
|
tubedevice=1, tubedevice_receiver=1, not_in_creative_inventory=1}
|
|
|
|
|
|
|
|
technic.chests.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()
|
2017-04-11 10:41:26 +02:00
|
|
|
if meta:get_int("splitstacks") == 1 then
|
|
|
|
stack = stack:peek_item(1)
|
|
|
|
end
|
|
|
|
return inv:room_for_item("main",stack)
|
2013-12-18 01:15:20 +01:00
|
|
|
end,
|
|
|
|
input_inventory = "main",
|
|
|
|
connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
|
|
|
|
}
|
|
|
|
|
|
|
|
technic.chests.can_dig = function(pos, player)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
return inv:is_empty("main")
|
|
|
|
end
|
|
|
|
|
|
|
|
local function inv_change(pos, count, player)
|
2018-06-28 19:49:04 +02:00
|
|
|
-- Skip check for pipeworks (fake player)
|
|
|
|
if minetest.is_player(player) and
|
|
|
|
not default.can_interact_with_node(player, pos) then
|
2013-12-18 01:15:20 +01:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
return count
|
|
|
|
end
|
|
|
|
|
|
|
|
function technic.chests.inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
|
|
|
return inv_change(pos, count, player)
|
|
|
|
end
|
|
|
|
function technic.chests.inv_put(pos, listname, index, stack, player)
|
2013-12-18 23:10:25 +01:00
|
|
|
return inv_change(pos, stack:get_count(), player)
|
2013-12-18 01:15:20 +01:00
|
|
|
end
|
|
|
|
function technic.chests.inv_take(pos, listname, index, stack, player)
|
2013-12-18 23:10:25 +01:00
|
|
|
return inv_change(pos, stack:get_count(), player)
|
2013-12-18 01:15:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function technic.chests.on_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
2020-02-08 19:53:11 +01:00
|
|
|
minetest.log("action", S("@1 moves stuff in chest at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
2013-12-18 01:15:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function technic.chests.on_inv_put(pos, listname, index, stack, player)
|
2020-02-08 19:53:11 +01:00
|
|
|
minetest.log("action", S("@1 moves @2 to chest at @3", player:get_player_name(), stack:get_name(), minetest.pos_to_string(pos)))
|
2013-12-18 01:15:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function technic.chests.on_inv_take(pos, listname, index, stack, player)
|
2020-02-08 19:53:11 +01:00
|
|
|
minetest.log("action", S("@1 takes @2 from chest at @3", player:get_player_name(), stack:get_name(), minetest.pos_to_string(pos)))
|
2013-12-18 01:15:20 +01:00
|
|
|
end
|
|
|
|
|