mirror of
https://github.com/HybridDog/connected_chests.git
synced 2024-12-28 06:00:17 +01:00
[connected_chests] Update
This commit is contained in:
parent
c9e632b1b8
commit
ba85584a68
67
init.lua
67
init.lua
@ -2,17 +2,19 @@ local load_time_start = os.clock()
|
|||||||
|
|
||||||
local creative_enabled = minetest.setting_getbool("creative_mode")
|
local creative_enabled = minetest.setting_getbool("creative_mode")
|
||||||
|
|
||||||
|
local big_formspec = "size[13,9]"..
|
||||||
|
"list[current_name;main;0,0;13,5;]"..
|
||||||
|
"list[current_player;main;2.5,5.2;8,4;]"..
|
||||||
|
"listring[current_name;main]"..
|
||||||
|
"listring[current_player;main]"
|
||||||
|
|
||||||
local chests = {
|
local chests = {
|
||||||
["default:chest"] = function(pu, pa, par, stuff)
|
["default:chest"] = function(pu, pa, par, stuff)
|
||||||
minetest.add_node(pu, {name="connected_chests:chest_left", param2=par})
|
minetest.add_node(pu, {name="connected_chests:chest_left", param2=par})
|
||||||
minetest.add_node(pa, {name="connected_chests:chest_right", param2=par})
|
minetest.add_node(pa, {name="connected_chests:chest_right", param2=par})
|
||||||
|
|
||||||
local meta = minetest.get_meta(pu)
|
local meta = minetest.get_meta(pu)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec", big_formspec)
|
||||||
"size[13,9]"..
|
|
||||||
"list[current_name;main;0,0;13,5;]"..
|
|
||||||
"list[current_player;main;2.5,5.2;8,4;]"
|
|
||||||
)
|
|
||||||
meta:set_string("infotext", "Big Chest")
|
meta:set_string("infotext", "Big Chest")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 65)
|
inv:set_size("main", 65)
|
||||||
@ -25,6 +27,7 @@ local chests = {
|
|||||||
|
|
||||||
local meta = minetest.get_meta(pu)
|
local meta = minetest.get_meta(pu)
|
||||||
meta:set_string("owner", owner)
|
meta:set_string("owner", owner)
|
||||||
|
meta:set_string("formspec", big_formspec)
|
||||||
meta:set_string("infotext", "Big Locked Chest (owned by "..
|
meta:set_string("infotext", "Big Locked Chest (owned by "..
|
||||||
meta:get_string("owner")..")")
|
meta:get_string("owner")..")")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -40,10 +43,9 @@ local function get_pointed_info(pointed_thing, name)
|
|||||||
end
|
end
|
||||||
local pu = minetest.get_pointed_thing_position(pointed_thing)
|
local pu = minetest.get_pointed_thing_position(pointed_thing)
|
||||||
local pa = minetest.get_pointed_thing_position(pointed_thing, true)
|
local pa = minetest.get_pointed_thing_position(pointed_thing, true)
|
||||||
if not (pu and pa) then
|
if not pu
|
||||||
return
|
or not pa
|
||||||
end
|
or pu.y ~= pa.y then
|
||||||
if pu.y ~= pa.y then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local nd_u = minetest.get_node(pu)
|
local nd_u = minetest.get_node(pu)
|
||||||
@ -90,11 +92,11 @@ for name,_ in pairs(chests) do
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pu, pa, par2 = get_pointed_info(pointed_thing, name)
|
local pu, pa, par2 = get_pointed_info(pointed_thing, name)
|
||||||
if not (pu and placer:get_player_control().sneak) then
|
if not pu
|
||||||
|
or not placer:get_player_control().sneak then
|
||||||
return place_chest(itemstack, placer, pointed_thing)
|
return place_chest(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
local protected = minetest.is_protected(pa, placer:get_player_name())
|
if minetest.is_protected(pa, placer:get_player_name()) then
|
||||||
if protected then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
connect_chests(pu, pa, par2, name)
|
connect_chests(pu, pa, par2, name)
|
||||||
@ -223,6 +225,30 @@ end
|
|||||||
minetest.register_node("connected_chests:chest_locked_left", chest_locked)
|
minetest.register_node("connected_chests:chest_locked_left", chest_locked)
|
||||||
|
|
||||||
|
|
||||||
|
local tube_to_left, tube_to_left_locked, tube_update, tube_groups
|
||||||
|
if minetest.global_exists("pipeworks") then
|
||||||
|
tube_to_left_locked = {
|
||||||
|
insert_object = function(pos, node, stack)
|
||||||
|
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
||||||
|
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():add_item("main", stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack)
|
||||||
|
local x, z = unpack(string.split(param_tab2[node.param2], " "))
|
||||||
|
return minetest.get_meta({x=pos.x+x, y=pos.y, z=pos.z+z}):get_inventory():room_for_item("main", stack)
|
||||||
|
end,
|
||||||
|
connect_sides = {right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
tube_to_left = table.copy(tube_to_left_locked)
|
||||||
|
tube_to_left.input_inventory = "main"
|
||||||
|
|
||||||
|
tube_update = pipeworks.scan_for_tube_objects
|
||||||
|
|
||||||
|
tube_groups = {tubedevice=1, tubedevice_receiver=1}
|
||||||
|
else
|
||||||
|
function tube_update() end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("connected_chests:chest_right", {
|
minetest.register_node("connected_chests:chest_right", {
|
||||||
tiles = {top_texture.."^[transformFX", top_texture.."^[transformFX", "default_chest_side.png",
|
tiles = {top_texture.."^[transformFX", top_texture.."^[transformFX", "default_chest_side.png",
|
||||||
"default_obsidian_glass.png", side_texture, side_texture.."^connected_chests_front.png^[transformFX"},
|
"default_obsidian_glass.png", side_texture, side_texture.."^connected_chests_front.png^[transformFX"},
|
||||||
@ -242,7 +268,9 @@ minetest.register_node("connected_chests:chest_right", {
|
|||||||
if node_left.name ~= "connected_chests:chest_left"
|
if node_left.name ~= "connected_chests:chest_left"
|
||||||
or node_left.param2 ~= node.param2 then
|
or node_left.param2 ~= node.param2 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
tube_update(pos)
|
||||||
end,
|
end,
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = function(pos, oldnode)
|
||||||
if oldnode.param2 > 3 then
|
if oldnode.param2 > 3 then
|
||||||
@ -254,8 +282,12 @@ minetest.register_node("connected_chests:chest_right", {
|
|||||||
and node_left.param2 == oldnode.param2
|
and node_left.param2 == oldnode.param2
|
||||||
and minetest.get_node(pos).name == "air" then
|
and minetest.get_node(pos).name == "air" then
|
||||||
minetest.set_node(pos, oldnode)
|
minetest.set_node(pos, oldnode)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
tube_update(pos)
|
||||||
|
end,
|
||||||
|
tube = tube_to_left,
|
||||||
|
groups = tube_groups,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("connected_chests:chest_locked_right", {
|
minetest.register_node("connected_chests:chest_locked_right", {
|
||||||
@ -269,6 +301,7 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.param2 > 3 then
|
if node.param2 > 3 then
|
||||||
node.param2 = node.param2%4
|
node.param2 = node.param2%4
|
||||||
|
-- ↓ calls the on_construct from the beginning again
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -277,7 +310,9 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||||||
if node_left.name ~= "connected_chests:chest_locked_left"
|
if node_left.name ~= "connected_chests:chest_locked_left"
|
||||||
or node_left.param2 ~= node.param2 then
|
or node_left.param2 ~= node.param2 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
tube_update(pos)
|
||||||
end,
|
end,
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = function(pos, oldnode)
|
||||||
if oldnode.param2 > 3 then
|
if oldnode.param2 > 3 then
|
||||||
@ -289,8 +324,12 @@ minetest.register_node("connected_chests:chest_locked_right", {
|
|||||||
and node_left.param2 == oldnode.param2
|
and node_left.param2 == oldnode.param2
|
||||||
and minetest.get_node(pos).name == "air" then
|
and minetest.get_node(pos).name == "air" then
|
||||||
minetest.set_node(pos, oldnode)
|
minetest.set_node(pos, oldnode)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
tube_update(pos)
|
||||||
|
end,
|
||||||
|
tube = tube_to_left_locked,
|
||||||
|
groups = tube_groups,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- abms to fix half chests
|
-- abms to fix half chests
|
||||||
|
Loading…
Reference in New Issue
Block a user