bug fixes in almost all item processing nodes

This commit is contained in:
Joachim Stolberg 2019-01-06 15:03:22 +01:00
parent 5fb6462231
commit d9b6a96941
25 changed files with 273 additions and 156 deletions

@ -135,6 +135,10 @@ minetest.register_node("smartline:button", {
end
end,
after_dig_node = function(pos)
tubelib.remove_node(pos)
end,
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -174,6 +178,10 @@ minetest.register_node("smartline:button_active", {
on_timer = switch_off,
after_dig_node = function(pos)
tubelib.remove_node(pos)
end,
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",

@ -64,6 +64,10 @@ minetest.register_node("smartline:display", {
lcdlib.update_entities(pos)
end,
after_dig_node = function(pos)
tubelib.remove_node(pos)
end,
on_timer = on_timer,
on_place = lcdlib.on_place,
on_construct = lcdlib.on_construct,

@ -44,8 +44,11 @@ minetest.register_node(NODE_NAME, {
on_timer = function(pos,elapsed)
return wh.on_timer(Box, pos,elapsed)
end,
on_dig = function(pos, node, puncher, pointed_thing)
wh.on_dig(Box, pos, node, puncher, pointed_thing)
can_dig = function(pos)
return wh.can_dig(Box, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
wh.after_dig_node(Box, pos, oldnode, oldmetadata, digger)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
@ -55,6 +58,7 @@ minetest.register_node(NODE_NAME, {
allow_metadata_inventory_move = wh.allow_metadata_inventory_move,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -100,8 +104,11 @@ minetest.register_node(NODE_NAME.."_defect", {
wh.after_place_node(Box, pos, placer, itemstack)
Box.State:defect(pos, M(pos))
end,
on_dig = function(pos, node, puncher, pointed_thing)
wh.on_dig(Box, pos, node, puncher, pointed_thing)
can_dig = function(pos)
return wh.can_dig(Box, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
wh.after_dig_node(Box, pos, oldnode, oldmetadata, digger)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
@ -125,10 +132,11 @@ tubelib.register_node(NODE_NAME,
local meta = M(pos)
meta:set_string("push_dir", side)
local num = wh.numbers_to_shift(Box, meta, item)
if num then
if num > 0 then
item:set_count(num)
return tubelib.put_item(meta, "shift", item)
end
return true
end,
on_pull_stack = function(pos, side)
return tubelib.get_stack(M(pos), "main")

@ -44,8 +44,11 @@ minetest.register_node(NODE_NAME, {
on_timer = function(pos,elapsed)
return wh.on_timer(Box, pos,elapsed)
end,
on_dig = function(pos, node, puncher, pointed_thing)
wh.on_dig(Box, pos, node, puncher, pointed_thing)
can_dig = function(pos)
return wh.can_dig(Box, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
wh.after_dig_node(Box, pos, oldnode, oldmetadata, digger)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
@ -55,6 +58,7 @@ minetest.register_node(NODE_NAME, {
allow_metadata_inventory_move = wh.allow_metadata_inventory_move,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -100,8 +104,11 @@ minetest.register_node(NODE_NAME.."_defect", {
wh.after_place_node(Box, pos, placer, itemstack)
Box.State:defect(pos, M(pos))
end,
on_dig = function(pos, node, puncher, pointed_thing)
wh.on_dig(Box, pos, node, puncher, pointed_thing)
can_dig = function(pos)
return wh.can_dig(Box, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
wh.after_dig_node(Box, pos, oldnode, oldmetadata, digger)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
@ -125,10 +132,11 @@ tubelib.register_node(NODE_NAME,
local meta = M(pos)
meta:set_string("push_dir", side)
local num = wh.numbers_to_shift(Box, meta, item)
if num then
if num > 0 then
item:set_count(num)
return tubelib.put_item(meta, "shift", item)
end
return true
end,
on_pull_stack = function(pos, side)
return tubelib.get_stack(M(pos), "main")

@ -44,8 +44,11 @@ minetest.register_node(NODE_NAME, {
on_timer = function(pos,elapsed)
return wh.on_timer(Box, pos,elapsed)
end,
on_dig = function(pos, node, puncher, pointed_thing)
wh.on_dig(Box, pos, node, puncher, pointed_thing)
can_dig = function(pos)
return wh.can_dig(Box, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
wh.after_dig_node(Box, pos, oldnode, oldmetadata, digger)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
@ -55,6 +58,7 @@ minetest.register_node(NODE_NAME, {
allow_metadata_inventory_move = wh.allow_metadata_inventory_move,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -100,8 +104,11 @@ minetest.register_node(NODE_NAME.."_defect", {
wh.after_place_node(Box, pos, placer, itemstack)
Box.State:defect(pos, M(pos))
end,
on_dig = function(pos, node, puncher, pointed_thing)
wh.on_dig(Box, pos, node, puncher, pointed_thing)
can_dig = function(pos)
return wh.can_dig(Box, pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
wh.after_dig_node(Box, pos, oldnode, oldmetadata, digger)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
@ -125,10 +132,11 @@ tubelib.register_node(NODE_NAME,
local meta = M(pos)
meta:set_string("push_dir", side)
local num = wh.numbers_to_shift(Box, meta, item)
if num then
if num > 0 then
item:set_count(num)
return tubelib.put_item(meta, "shift", item)
end
return true
end,
on_pull_stack = function(pos, side)
return tubelib.get_stack(M(pos), "main")

@ -147,7 +147,7 @@ end
function techpack_warehouse.numbers_to_shift(self, meta, item)
-- check cache
local number = meta:get_string("number")
local number = meta:get_string("tubelib_number")
local item_name = item:get_name()
if not Cache[number] then
local inv = meta:get_inventory()
@ -191,7 +191,7 @@ function techpack_warehouse.allow_metadata_inventory_put(self, pos, listname, in
if listname == "input" and item_name == stack:get_name() then
return math.min(stack:get_count(), self.inv_size - main_stack:get_count())
elseif listname == "filter" and item_name == main_stack:get_name() then
local number = M(pos):get_string("number")
local number = M(pos):get_string("tubelib_number")
Cache[number] = nil
return 1
elseif listname == "shift" then
@ -202,7 +202,7 @@ end
function techpack_warehouse.on_metadata_inventory_put(pos, listname, index, stack, player)
if listname == "input" then
local number = M(pos):get_string("number")
local number = M(pos):get_string("tubelib_number")
Cache[number] = nil
minetest.after(0.5, move_to_main, pos, index)
end
@ -213,7 +213,7 @@ function techpack_warehouse.allow_metadata_inventory_take(pos, listname, index,
return 0
end
if listname == "main" then
local number = M(pos):get_string("number")
local number = M(pos):get_string("tubelib_number")
Cache[number] = nil
local inv = M(pos):get_inventory()
local list = inv:get_list("main")
@ -224,11 +224,11 @@ function techpack_warehouse.allow_metadata_inventory_take(pos, listname, index,
return num
end
elseif listname == "filter" then
local number = M(pos):get_string("number")
local number = M(pos):get_string("tubelib_number")
Cache[number] = nil
return 1
elseif listname == "shift" then
local number = M(pos):get_string("number")
local number = M(pos):get_string("tubelib_number")
Cache[number] = nil
return stack:get_count()
end
@ -243,7 +243,7 @@ function techpack_warehouse.on_receive_fields(self, pos, formname, fields, playe
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local number = M(pos):get_string("number")
local number = M(pos):get_string("tubelib_number")
Cache[number] = nil
self.State:state_button_event(pos, fields)
end
@ -264,7 +264,7 @@ function techpack_warehouse.on_timer(self, pos, elapsed)
local meta = M(pos)
local inv = meta:get_inventory()
if not inv:is_empty("shift") then
local number = meta:get_string("number")
--local number = meta:get_string("tubelib_number")
local player_name = meta:get_string("player_name")
local offs = meta:get_int("offs")
local push_dir = meta:get_string("push_dir")
@ -295,10 +295,14 @@ function techpack_warehouse.on_timer(self, pos, elapsed)
return self.State:is_active(meta)
end
function techpack_warehouse.on_dig(self, pos, node, puncher, pointed_thing)
function techpack_warehouse.can_dig(self, pos)
local inv = M(pos):get_inventory()
if inv:is_empty("main") and inv:is_empty("shift") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
return inv:is_empty("main") and inv:is_empty("shift")
end
function techpack_warehouse.after_dig_node(self, pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
if oldnode.name == self.node_name then -- not for defect nodes
self.State:after_dig_node(pos, oldnode, oldmetadata, digger)
end
end

@ -88,6 +88,7 @@ tubelib.register_node("tubelib:blackhole", {}, {
on_recv_message = function(pos, topic, payload)
local node = minetest.get_node(pos)
if topic == "state" then
local meta = minetest.get_meta(pos)
return meta:get_int("disappeared")
else
return "not supported"

@ -151,6 +151,13 @@ local function get_dest_node(pos, side)
return spos, in_side, Name2Name[node.name] or node.name
end
local function item_handling_node(name)
local node_def = name and tubelib_NodeDef[name]
if node_def then
return node_def.on_pull_item or node_def.on_push_item or node_def.is_pusher
end
end
-------------------------------------------------------------------
-- API helper functions
-------------------------------------------------------------------
@ -219,6 +226,11 @@ end
-- Function determines and returns the node position number,
-- needed for message communication.
function tubelib.add_node(pos, name)
print("tubelib.add_node", S(pos))
if item_handling_node(name) then
print("Tube:after_place_node")
Tube:after_place_node(pos)
end
-- store position
local number = get_number(pos)
Number2Pos[number] = {
@ -230,14 +242,21 @@ end
-- Function removes the node from the tubelib lists.
function tubelib.remove_node(pos)
print("tubelib.remove_node", S(pos))
local number = get_number(pos)
local name
if Number2Pos[number] then
name = Number2Pos[number].name
Number2Pos[number] = {
pos = pos,
name = nil,
time = minetest.get_day_count() -- used for reservation timeout
}
end
if item_handling_node(name) then
print("Tube:after_dig_node")
Tube:after_dig_node(pos)
end
end

@ -345,19 +345,16 @@ minetest.register_node("tubelib:distributor", {
on_receive_fields = on_receive_fields,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos) -- <<=== tubelib
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos) -- <<=== tubelib
State:after_dig_node(pos, oldnode, oldmetadata, digger)
end,
@ -448,6 +445,18 @@ minetest.register_node("tubelib:distributor_defect", {
on_receive_fields = on_receive_fields,
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos) -- <<=== tubelib
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
allow_metadata_inventory_move = allow_metadata_inventory_move,

@ -46,6 +46,7 @@ local function read_state(itemstack, user, pointed_thing)
local counter = tubelib.send_request(number, "counter", nil)
local aging = tubelib.send_request(number, "aging", nil)
if state and counter and aging then
if type(counter) ~= "number" then counter = "unknown" end
minetest.chat_send_player(user:get_player_name(), "[Tubelib] state ="..state..", counter = "..counter..", aging = "..aging)
end
end

@ -301,16 +301,17 @@ minetest.register_node("tubelib_addons1:autocrafter", {
inv:set_size("output", 1)
end,
on_dig = function(pos, node, puncher, pointed_thing)
local inv = M(pos):get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
autocrafterCache[minetest.hash_node_position(pos)] = nil
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
autocrafterCache[minetest.hash_node_position(pos)] = nil
tubelib.remove_node(pos)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
end,
@ -385,13 +386,17 @@ minetest.register_node("tubelib_addons1:autocrafter_defect", {
State:defect(pos, meta)
end,
on_dig = function(pos, node, puncher, pointed_thing)
local inv = M(pos):get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
autocrafterCache[minetest.hash_node_position(pos)] = nil
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
autocrafterCache[minetest.hash_node_position(pos)] = nil
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,

@ -100,20 +100,18 @@ minetest.register_node("tubelib_addons1:chest", {
meta:set_string("infotext", "Tubelib Protected Chest "..number)
end,
can_dig = function(pos,player)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local inv = minetest.get_meta(pos):get_inventory()
return inv:is_empty("main")
end,
on_dig = function(pos, node, puncher, pointed_thing)
minetest.node_dig(pos, node, puncher, pointed_thing)
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,

@ -72,6 +72,10 @@ minetest.register_node("tubelib_addons1:detector", {
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
paramtype = "light",
sunlight_propagates = true,
@ -97,6 +101,10 @@ minetest.register_node("tubelib_addons1:detector_active", {
on_timer = switch_off,
on_rotate = screwdriver.disallow,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
paramtype = "light",
light_source = 2,
sunlight_propagates = true,

@ -188,17 +188,18 @@ minetest.register_node("tubelib_addons1:fermenter", {
State:node_init(pos, number)
end,
-- the fermenter needs 'on_dig' to be able to remove the upper node
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
tubelib.remove_node(pos)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
end,
@ -219,7 +220,7 @@ minetest.register_node("tubelib_addons1:fermenter", {
})
minetest.register_node("tubelib_addons1:fermenter_defect", {
description = "Tubelib Fermenter",
description = "Tubelib Fermenter defect",
inventory_image = "tubelib_addons1_fermenter_inventory.png",
tiles = {
-- up, down, right, left, back, front
@ -254,15 +255,19 @@ minetest.register_node("tubelib_addons1:fermenter_defect", {
State:defect(pos, M(pos))
end,
-- the fermenter needs 'on_dig' to be able to remove the upper node
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
tubelib.remove_node(pos)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,

@ -100,7 +100,7 @@ minetest.register_node("tubelib_addons1:funnel", {
on_timer = scan_for_objects,
on_rotate = screwdriver.disallow,
can_dig = function(pos,player)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
@ -109,11 +109,10 @@ minetest.register_node("tubelib_addons1:funnel", {
return inv:is_empty("main")
end,
on_dig = function(pos, node, puncher, pointed_thing)
minetest.node_dig(pos, node, puncher, pointed_thing)
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,

@ -136,17 +136,17 @@ minetest.register_node("tubelib_addons1:grinder", {
inv:set_size('dst', 9)
end,
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -225,15 +225,18 @@ minetest.register_node("tubelib_addons1:grinder_defect", {
State:defect(pos, meta)
end,
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,

@ -325,20 +325,17 @@ minetest.register_node("tubelib_addons1:harvester_base", {
State:node_init(pos, number)
end,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("main") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("main")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -389,16 +386,16 @@ minetest.register_node("tubelib_addons1:harvester_defect", {
State:defect(pos, meta)
end,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("main") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("main")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,

@ -137,7 +137,7 @@ minetest.register_node("tubelib_addons1:liquidsampler", {
},
after_place_node = function(pos, placer)
local number = tubelib.add_node(pos, "ttubelib_addons1:liquidsampler")
local number = tubelib.add_node(pos, "tubelib_addons1:liquidsampler")
State:node_init(pos, number)
local meta = M(pos)
local node = minetest.get_node(pos)
@ -148,17 +148,17 @@ minetest.register_node("tubelib_addons1:liquidsampler", {
inv:set_size("dst", 28)
end,
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
@ -238,13 +238,16 @@ minetest.register_node("tubelib_addons1:liquidsampler_defect", {
State:defect(pos, meta)
end,
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,

@ -304,19 +304,16 @@ minetest.register_node("tubelib_addons1:quarry", {
State:node_init(pos, number)
end,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("main") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("main")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
end,
@ -401,16 +398,16 @@ minetest.register_node("tubelib_addons1:quarry_defect", {
State:defect(pos, M(pos))
end,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("main") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("main")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,

@ -171,18 +171,19 @@ minetest.register_node("tubelib_addons1:reformer", {
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
State:node_init(pos, number)
end,
-- the reformer needs 'on_dig' to be able to remove the upper node
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
tubelib.remove_node(pos)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
end,
@ -203,7 +204,7 @@ minetest.register_node("tubelib_addons1:reformer", {
})
minetest.register_node("tubelib_addons1:reformer_defect", {
description = "Tubelib Reformer",
description = "Tubelib Reformer defect",
inventory_image = "tubelib_addons1_reformer_inventory.png",
tiles = {
-- up, down, right, left, back, front
@ -238,16 +239,20 @@ minetest.register_node("tubelib_addons1:reformer_defect", {
State:defect(pos, M(pos))
end,
-- the reformer needs 'on_dig' to be able to remove the upper node
on_dig = function(pos, node, puncher, pointed_thing)
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
tubelib.remove_node(pos)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
on_rotate = screwdriver.disallow,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,

@ -115,6 +115,10 @@ for idx,color in ipairs(tColors) do
switch_node(pos, "", clicker)
end,
after_dig_node = function(pos)
tubelib.remove_node(pos)
end,
paramtype = 'light',
light_source = minetest.LIGHT_MAX,
groups = {choppy=2, cracky=1, not_in_creative_inventory=1},

@ -83,6 +83,10 @@ local function register_lamp(tbl)
end
end,
after_dig_node = function(pos)
tubelib.remove_node(pos)
end,
paramtype = "light",
light_source = minetest.LIGHT_MAX,
sunlight_propagates = true,

@ -13,7 +13,7 @@
]]--
local function join_to_string(tbl)
t = {}
local t = {}
for key,_ in pairs(tbl) do
t[#t + 1] = key .. " "
end

@ -26,7 +26,7 @@ local STANDBY_TICKS = 4
local CYCLE_TIME = 2
local function formspec(self, pos, meta)
local filter = minetest.deserialize(meta:get_string("filter"))
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
return "size[10.5,8.5]"..
default.gui_bg..
default.gui_bg_img..
@ -329,20 +329,17 @@ minetest.register_node("tubelib_addons3:distributor", {
on_receive_fields = on_receive_fields,
on_dig = function(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then
return
end
local meta = M(pos)
local inv = meta:get_inventory()
if inv:is_empty("src") then
minetest.node_dig(pos, node, puncher, pointed_thing)
tubelib.remove_node(pos)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State:after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -415,11 +412,11 @@ minetest.register_node("tubelib_addons3:distributor_defect", {
after_place_node = function(pos, placer)
local meta = M(pos)
local number = tubelib.add_node(pos, "tubelib_addons3:distributor")
local filter = {false,false,false,false}
meta:set_string("filter", minetest.serialize(filter))
State:node_init(pos, number)
meta:set_string("player_name", placer:get_player_name())
local filter = {false,false,false,false}
meta:set_string("filter", minetest.serialize(filter))
local inv = meta:get_inventory()
inv:set_size('src', 8)
inv:set_size('yellow', 6)
@ -432,6 +429,18 @@ minetest.register_node("tubelib_addons3:distributor_defect", {
on_receive_fields = on_receive_fields,
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("src")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
allow_metadata_inventory_move = allow_metadata_inventory_move,

@ -59,6 +59,17 @@ local function aging(pos, meta)
end
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
local cnt = oldmetadata.fields.tubelib_aging and tonumber(oldmetadata.fields.tubelib_aging) or 0
local is_defect = cnt > AGING_LEVEL1 and math.random(AGING_LEVEL2 / cnt) == 1
if is_defect then
inv:add_item("main", ItemStack("tubelib_addons3:pushing_chest_defect"))
else
inv:add_item("main", ItemStack("tubelib_addons3:pushing_chest"))
end
end
local function set_state(meta, state)
local number = meta:get_string("number")
meta:set_string("infotext", "HighPerf Pushing Chest "..number..": "..state)
@ -161,17 +172,18 @@ minetest.register_node("tubelib_addons3:pushing_chest", {
minetest.get_node_timer(pos):start(2)
end,
can_dig = function(pos,player)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local meta = minetest.get_meta(pos);
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main") and inv:is_empty("shift")
end,
on_dig = function(pos, node, puncher, pointed_thing)
minetest.node_dig(pos, node, puncher, pointed_thing)
after_dig_node = function(pos, oldnode, oldmetadata, digger)
after_dig_node(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -181,6 +193,7 @@ minetest.register_node("tubelib_addons3:pushing_chest", {
on_timer = shift_items,
on_rotate = screwdriver.disallow,
drop = "",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -217,17 +230,16 @@ minetest.register_node("tubelib_addons3:pushing_chest_defect", {
set_state(meta, "empty")
end,
can_dig = function(pos,player)
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
local inv = minetest.get_meta(pos):get_inventory()
return inv:is_empty("main") and inv:is_empty("shift")
end,
on_dig = function(pos, node, puncher, pointed_thing)
minetest.node_dig(pos, node, puncher, pointed_thing)
after_dig_node = function(pos, oldnode, oldmetadata, digger)
tubelib.remove_node(pos)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -265,6 +277,8 @@ tubelib.register_node("tubelib_addons3:pushing_chest",
return "empty"
end
return meta:get_string("state")
elseif topic == "aging" then
return minetest.get_meta(pos):get_int("tubelib_aging")
else
return "not supported"
end
@ -298,10 +312,6 @@ tubelib.register_node("tubelib_addons3:pushing_chest",
local meta = minetest.get_meta(pos)
return tubelib.put_item(meta, "main", item)
end,
on_recv_message = function(pos, topic, payload)
return "unsupported"
end,
on_node_load = function(pos)
minetest.get_node_timer(pos):start(2)
end,