forked from mtcontrib/connected_chests
Merge branch 'master' into nalc-1.2
This commit is contained in:
commit
53d2009680
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.
|
This mod allows making bigger default chests.<br/>
|
||||||
Just hold shift and place a chest onto another one's side.
|
Hold shift and place a chest onto another one's side to get a big chest.<br/>
|
||||||
This is not the first mod which adds big chests.
|
This is not the first mod which adds big chests.
|
||||||
|
|
||||||
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/connected_chests/master/depends.txt)
|
**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)
|
**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/tarball/master)
|
**Download:** [zip](https://github.com/HybridDog/connected_chests/archive/master.zip), [tar.gz](https://github.com/HybridDog/connected_chests/archive/master.tar.gz)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -16,5 +16,5 @@ If you got ideas or found bugs, please tell them to me.
|
|||||||
|
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
* add abms when registering the chest instead of using chestdata
|
* Fix open big chest back side texture: The current .obj mesh model uses a side
|
||||||
* fix open big chest back side texture
|
texture for the back side, so the model needs change.
|
||||||
|
67
init.lua
67
init.lua
@ -47,6 +47,9 @@ local function return_add_next(right_name)
|
|||||||
-- if the left node is set with an unexpected rotation, put the chest
|
-- if the left node is set with an unexpected rotation, put the chest
|
||||||
-- with default rotation
|
-- with default rotation
|
||||||
if par > 3 then
|
if par > 3 then
|
||||||
|
minetest.log("action",
|
||||||
|
node.name .. " with invalid param2 found, pos: " ..
|
||||||
|
minetest.pos_to_string(pos) .. ", param2: " .. par)
|
||||||
node.param2 = 0
|
node.param2 = 0
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
return
|
return
|
||||||
@ -92,7 +95,7 @@ local chestdata = {}
|
|||||||
|
|
||||||
|
|
||||||
-- executed when connecting the chests
|
-- executed when connecting the chests
|
||||||
local function connect_chests(pu, pa, old_param2, name)
|
local function connect_chests(pu, pa, old_param2, data)
|
||||||
local metatable = minetest.get_meta(pu):to_table()
|
local metatable = minetest.get_meta(pu):to_table()
|
||||||
|
|
||||||
local par = param_tab[pu.x-pa.x.." "..pu.z-pa.z]
|
local par = param_tab[pu.x-pa.x.." "..pu.z-pa.z]
|
||||||
@ -102,7 +105,7 @@ local function connect_chests(pu, pa, old_param2, name)
|
|||||||
par = par_inverted
|
par = par_inverted
|
||||||
end
|
end
|
||||||
|
|
||||||
chestdata[name].on_connect(pu, pa, par, metatable)
|
data.on_connect(pu, pa, par, metatable)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ function connected_chests.register_chest(fromname, data)
|
|||||||
if minetest.is_protected(pa, placer:get_player_name()) then
|
if minetest.is_protected(pa, placer:get_player_name()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
connect_chests(pu, pa, par2, fromname)
|
connect_chests(pu, pa, par2, data)
|
||||||
if not creative_mode then
|
if not creative_mode then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
@ -389,6 +392,35 @@ inside_texture = "default_chest_inside.png^([combine:16x32:5,0=" ..
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(":" .. name_right, right_def)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -575,35 +607,6 @@ 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
|
-- legacy
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user