mirror of
https://github.com/HybridDog/connected_chests.git
synced 2025-07-16 23:20:23 +02:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
7f5b39c673 |
@ -1,2 +0,0 @@
|
||||
read_globals = {"minetest", "table", "default", "pipeworks"}
|
||||
globals = {"connected_chests"}
|
@ -1,2 +1,2 @@
|
||||
connected_chest_open from default
|
||||
Content which is not copied from minetest_game is licensed under MIT.
|
||||
rest WTFPL
|
||||
|
16
README.md
16
README.md
@ -1,12 +1,12 @@
|
||||
[Mod] Connected Chests [connected_chests]
|
||||
[Mod] connected chests [connected_chests]
|
||||
|
||||
This mod allows making bigger default chests.<br/>
|
||||
Hold shift and place a chest onto another one's side to get a big chest.<br/>
|
||||
This mod allows making bigger default chests.
|
||||
Just hold shift and place a chest onto another one's side.
|
||||
This is not the first mod which adds big chests.
|
||||
|
||||
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/connected_chests/master/depends.txt)<br/>
|
||||
**License:** see [LICENSE.txt](https://raw.githubusercontent.com/HybridDog/connected_chests/master/LICENSE.txt)<br/>
|
||||
**Download:** [zip](https://github.com/HybridDog/connected_chests/archive/master.zip), [tar.gz](https://github.com/HybridDog/connected_chests/archive/master.tar.gz)
|
||||
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/connected_chests/master/depends.txt)
|
||||
**License:** see [LICENSE.txt](https://raw.githubusercontent.com/HybridDog/connected_chests/master/LICENSE.txt)
|
||||
**Download:** [zip](https://github.com/HybridDog/connected_chests/archive/master.zip), [tar.gz](https://github.com/HybridDog/connected_chests/tarball/master)
|
||||
|
||||

|
||||
|
||||
@ -16,5 +16,5 @@ If you got ideas or found bugs, please tell them to me.
|
||||
|
||||
|
||||
TODO:
|
||||
* Fix open big chest back side texture: The current .obj mesh model uses a side
|
||||
texture for the back side, so the model needs change.
|
||||
* add abms when registering the chest instead of using chestdata
|
||||
* fix open big chest back side texture
|
||||
|
3
depends.txt
Normal file
3
depends.txt
Normal file
@ -0,0 +1,3 @@
|
||||
default
|
||||
pipeworks?
|
||||
technic?
|
96
init.lua
96
init.lua
@ -1,3 +1,6 @@
|
||||
local load_time_start = minetest.get_us_time()
|
||||
|
||||
|
||||
-- param_tab maps the x and z offset to a param2 value
|
||||
local param_tab = {
|
||||
["-1 0"] = 0,
|
||||
@ -44,9 +47,6 @@ local function return_add_next(right_name)
|
||||
-- if the left node is set with an unexpected rotation, put the chest
|
||||
-- with default rotation
|
||||
if par > 3 then
|
||||
minetest.log("action",
|
||||
node.name .. " with invalid param2 found, pos: " ..
|
||||
minetest.pos_to_string(pos) .. ", param2: " .. par)
|
||||
node.param2 = 0
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
@ -92,7 +92,7 @@ local chestdata = {}
|
||||
|
||||
|
||||
-- executed when connecting the chests
|
||||
local function connect_chests(pu, pa, old_param2, data)
|
||||
local function connect_chests(pu, pa, old_param2, name)
|
||||
local metatable = minetest.get_meta(pu):to_table()
|
||||
|
||||
local par = param_tab[pu.x-pa.x.." "..pu.z-pa.z]
|
||||
@ -102,7 +102,7 @@ local function connect_chests(pu, pa, old_param2, data)
|
||||
par = par_inverted
|
||||
end
|
||||
|
||||
data.on_connect(pu, pa, par, metatable)
|
||||
chestdata[name].on_connect(pu, pa, par, metatable)
|
||||
end
|
||||
|
||||
|
||||
@ -188,7 +188,7 @@ function connected_chests.register_chest(fromname, data)
|
||||
if minetest.is_protected(pa, placer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
connect_chests(pu, pa, par2, data)
|
||||
connect_chests(pu, pa, par2, fromname)
|
||||
if not creative_mode then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
@ -276,7 +276,7 @@ function connected_chests.register_chest(fromname, data)
|
||||
}
|
||||
def_opened.diggable = false
|
||||
def_opened.on_blast = function() end
|
||||
inside_texture = "default_chest_inside.png^([combine:16x32:5,0=" ..
|
||||
inside_texture = "default_chest_inside.png^([combine:16x32:5,0=" ..
|
||||
"default_chest_inside.png^connected_chests_inside_frame.png^[" ..
|
||||
"makealpha:255,126,126)"
|
||||
-- TODO, see right chest
|
||||
@ -389,35 +389,6 @@ function connected_chests.register_chest(fromname, data)
|
||||
end
|
||||
|
||||
minetest.register_node(":" .. name_right, right_def)
|
||||
|
||||
|
||||
-- LBMs to fix half chests if they occur for some reason
|
||||
minetest.register_lbm{
|
||||
label = "Connected Chest fixer " .. name_right,
|
||||
name = ":" .. name_right .. "_reconnect_lbm",
|
||||
nodenames = {name_right},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
if node.param2 > 3 then
|
||||
node.param2 = node.param2%4
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
end
|
||||
local x, z = unpack(param_tab2[node.param2])
|
||||
local left_node = minetest.get_node{x=pos.x+x, y=pos.y, z=pos.z+z}
|
||||
if left_node.name ~= name_left
|
||||
or left_node.param2 ~= node.param2 then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
}
|
||||
minetest.register_lbm{
|
||||
label = "Connected Chest fixer " .. name_left,
|
||||
name = ":" .. name_left .. "_reconnect_lbm",
|
||||
nodenames = {name_left},
|
||||
run_at_every_load = true,
|
||||
action = return_add_next(name_right),
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -472,7 +443,7 @@ local function close_chest(vi)
|
||||
pos.x = pos.x + x * 0.5
|
||||
pos.z = pos.z + z * 0.5
|
||||
minetest.sound_play("default_chest_close",
|
||||
{gain = 0.3, pos = pos, max_hear_distance = 10, pitch = 0.7}, true)
|
||||
{gain = 10.3, pos = pos, max_hear_distance = 10})
|
||||
end
|
||||
|
||||
-- close all remaining open chest on shutdown
|
||||
@ -518,7 +489,7 @@ connected_chests.register_chest("default:chest", {
|
||||
add_open_chest = true,
|
||||
on_rightclick = function(pos, _, player)
|
||||
minetest.sound_play("default_chest_open",
|
||||
{gain = 0.3, pos = pos, max_hear_distance = 10, pitch = 0.7}, true)
|
||||
{gain = 0.3, pos = pos, max_hear_distance = 10})
|
||||
|
||||
local vi = minetest.hash_node_position(pos)
|
||||
if not open_chests[vi]
|
||||
@ -560,12 +531,12 @@ connected_chests.register_chest("default:chest_locked", {
|
||||
add_open_chest = true,
|
||||
on_rightclick = function(pos, _, player)
|
||||
if not default.can_interact_with_node(player, pos) then
|
||||
minetest.sound_play("default_chest_locked", {pos = pos}, true)
|
||||
minetest.sound_play("default_chest_locked", {pos = pos})
|
||||
return
|
||||
end
|
||||
|
||||
minetest.sound_play("default_chest_open",
|
||||
{gain = 0.32, pos = pos, max_hear_distance = 10, pitch = 0.7}, true)
|
||||
{gain = 0.32, pos = pos, max_hear_distance = 10})
|
||||
|
||||
local vi = minetest.hash_node_position(pos)
|
||||
-- TODO: somehow avoid using the chest node names here
|
||||
@ -576,7 +547,7 @@ connected_chests.register_chest("default:chest_locked", {
|
||||
-- TODO: test for invalid param2 values
|
||||
local x, z = unpack(param_tab2[left_param2])
|
||||
local pos_right = {x=pos.x-x, y=pos.y, z=pos.z-z}
|
||||
local node = minetest.get_node(pos_right)
|
||||
node = minetest.get_node(pos_right)
|
||||
if node.name == "default:chest_locked_connected_right"
|
||||
and not chest_lid_obstructed(pos_right) then
|
||||
minetest.swap_node(pos_right, {
|
||||
@ -604,6 +575,35 @@ connected_chests.register_chest("default:chest_locked", {
|
||||
})
|
||||
|
||||
|
||||
-- abms to fix half chests
|
||||
for _,i in pairs(chestdata) do
|
||||
minetest.register_abm{
|
||||
nodenames = {i.right},
|
||||
interval = 10,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
if node.param2 > 3 then
|
||||
node.param2 = node.param2%4
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
end
|
||||
local x, z = unpack(param_tab2[node.param2])
|
||||
local left_node = minetest.get_node{x=pos.x+x, y=pos.y, z=pos.z+z}
|
||||
if left_node.name ~= i.left
|
||||
or left_node.param2 ~= node.param2 then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
}
|
||||
minetest.register_abm{
|
||||
nodenames = {i.left},
|
||||
interval = 3,
|
||||
chance = 1,
|
||||
action = return_add_next(i.right),
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- legacy
|
||||
|
||||
@ -635,3 +635,17 @@ minetest.register_alias("connected_chests:chest_left_locked", "default:chest_loc
|
||||
minetest.register_alias("connected_chests:chest_right_locked", "default:chest_locked_connected_right")
|
||||
minetest.register_alias("connected_chests:chest_locked_left", "default:chest_locked_connected_left")
|
||||
minetest.register_alias("connected_chests:chest_locked_right", "default:chest_locked_connected_right")
|
||||
|
||||
--~ local function log_access(pos, player, text)
|
||||
--~ minetest.log("action", player:get_player_name()..
|
||||
--~ " moves stuff "..text.." at "..minetest.pos_to_string(pos))
|
||||
--~ end
|
||||
|
||||
|
||||
local time = (minetest.get_us_time() - load_time_start) / 1000000
|
||||
local msg = "[connected_chests] loaded after ca. " .. time .. " seconds."
|
||||
if time > 0.01 then
|
||||
print(msg)
|
||||
else
|
||||
minetest.log("info", msg)
|
||||
end
|
||||
|
Reference in New Issue
Block a user