mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-26 09:03:46 +01:00
commit
47616daf23
@ -143,6 +143,37 @@ local function formspec()
|
|||||||
"listring[current_player;main]"
|
"listring[current_player;main]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- necessary function for a quick bugfix, doubles some code from local function "aging"
|
||||||
|
local function defect(pos, meta)
|
||||||
|
minetest.get_node_timer(pos):stop()
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
node.name = "tubelib_addons3:pushing_chest_defect"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- code duplication of method "NodeStates:on_dig_node" (node_states.lua)
|
||||||
|
-- (in contrast to (all?) other tubelib nodes that can go defect class "NodeStates" isn't applied here)
|
||||||
|
function on_dig_node(pos, node, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local cnt = tonumber(meta:get_string("tubelib_aging"))
|
||||||
|
if (not cnt or cnt < 1) then
|
||||||
|
cnt = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_defect = (cnt > AGING_LEVEL1) and ( math.random(math.max(1, math.floor(AGING_LEVEL2 / cnt))) == 1 )
|
||||||
|
|
||||||
|
if is_defect then
|
||||||
|
defect(pos, meta) -- replace node with defect one
|
||||||
|
node = minetest.get_node(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.node_dig(pos, node, player) -- default behaviour (this function is called automatically if on_dig() callback isn't set)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("tubelib_addons3:pushing_chest", {
|
minetest.register_node("tubelib_addons3:pushing_chest", {
|
||||||
description = "HighPerf Pushing Chest",
|
description = "HighPerf Pushing Chest",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -190,8 +221,10 @@ minetest.register_node("tubelib_addons3:pushing_chest", {
|
|||||||
return inv:is_empty("main") and inv:is_empty("shift")
|
return inv:is_empty("main") and inv:is_empty("shift")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
on_dig = function(pos, node, player)
|
on_dig = function(pos, node, player)
|
||||||
State:on_dig_node(pos, node, player)
|
on_dig_node(pos, node, player)
|
||||||
tubelib.remove_node(pos)
|
tubelib.remove_node(pos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user