V2.03, Piston/WorldEdit/replacer detection added, farming and grinder recipes added

This commit is contained in:
Joachim Stolberg 2019-04-23 21:46:08 +02:00
parent a5e18c3d79
commit a7a6b50492
39 changed files with 692 additions and 442 deletions

@ -150,6 +150,7 @@ tubelib_addons1 optional: unified_inventory
- 2019-01-12 V2.00 * release
- 2019-01-27 V2.01 * SaferLua Controller Terminal added
- 2019-01-28 V2.02 * Logic Not added, output reduction on Harvester, Fermenter, and Gravel Sieve
- 2019-04-23 V2.03 * Piston/WorldEdit/replacer detection added, farming and grinder recipes added
## New in v2 (from players point of view)

@ -1,5 +1,21 @@
# Release Notes for ModPack TechPack [techpack]
2019-04-23 V2.03 * ,
## V2.03 (2019-04-23)
### Additions
- Farming and Grinder recipes added (thanks to obl3pplifp)
- Support for Signs Bot chest and Box added
### Removals
### Changes
### Fixes
- Piston/WorldEdit/Replacer tool detection added. If node is replaced/removed/copied,
it will switch to a "defect" dummy node.
## V2.02.06 (2019-03-23)

@ -33,11 +33,14 @@ end
local function on_time(pos, elasped)
local meta = minetest.get_meta(pos)
local number = meta:get_string("number")
local mem = tubelib.get_data(number, "memory") or table.copy(DEFAULT_MEM)
meta:set_string("infotext", "Server "..number..": ("..(mem.size or 0).."/"..SERVER_CAPA..")")
return true
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local number = meta:get_string("number")
local mem = tubelib.get_data(number, "memory") or table.copy(DEFAULT_MEM)
meta:set_string("infotext", "Server "..number..": ("..(mem.size or 0).."/"..SERVER_CAPA..")")
return true
end
return false
end
minetest.register_node("sl_controller:server", {

@ -15,47 +15,51 @@
local function switch_on(pos, node)
node.name = "smartline:button_active"
minetest.swap_node(pos, node)
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local cycle_time = meta:get_int("cycle_time")
if cycle_time > 0 then -- button mode?
minetest.get_node_timer(pos):start(cycle_time)
if tubelib.data_not_corrupted(pos) then
node.name = "smartline:button_active"
minetest.swap_node(pos, node)
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local cycle_time = meta:get_int("cycle_time")
if cycle_time > 0 then -- button mode?
minetest.get_node_timer(pos):start(cycle_time)
end
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
end
tubelib.send_message(numbers, placer_name, clicker_name, "on", own_num)
end
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
end
tubelib.send_message(numbers, placer_name, clicker_name, "on", own_num)
end
local function switch_off(pos)
local node = minetest.get_node(pos)
node.name = "smartline:button"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):stop()
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
if tubelib.data_not_corrupted(pos) then
local node = minetest.get_node(pos)
node.name = "smartline:button"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):stop()
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
end
tubelib.send_message(numbers, placer_name, clicker_name, "off", own_num)
end
tubelib.send_message(numbers, placer_name, clicker_name, "off", own_num)
end

@ -67,27 +67,30 @@ end
local function on_timer(pos,elapsed)
local meta = minetest.get_meta(pos)
local poll_numbers = meta:get_string("poll_numbers")
local idx = meta:get_int("index") + 1
if poll_numbers == "" then
local own_number = meta:get_string("own_number")
meta:set_string("infotext", "SmartLine State Collector "..own_number..": stopped")
meta:set_int("state", 0)
meta:set_int("stored_state", 0)
return false
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local poll_numbers = meta:get_string("poll_numbers")
local idx = meta:get_int("index") + 1
if poll_numbers == "" then
local own_number = meta:get_string("own_number")
meta:set_string("infotext", "SmartLine State Collector "..own_number..": stopped")
meta:set_int("state", 0)
meta:set_int("stored_state", 0)
return false
end
if idx > meta:get_int("num_numbers") then
idx = 1
send_event(meta)
end
meta:set_int("index", idx)
request_state(meta, poll_numbers, idx)
return true
end
if idx > meta:get_int("num_numbers") then
idx = 1
send_event(meta)
end
meta:set_int("index", idx)
request_state(meta, poll_numbers, idx)
return true
return false
end
minetest.register_node("smartline:collector", {

@ -578,16 +578,19 @@ local function execute(meta, number, debug)
end
local function check_rules(pos, elapsed)
--local t = minetest.get_us_time()
local meta = minetest.get_meta(pos)
meta:set_int("runtime", (meta:get_int("runtime") or 1) + 1)
local number = meta:get_string("number")
local state = meta:get_int("state")
if state == tubelib.RUNNING and number then
execute(meta, number, debug)
if tubelib.data_not_corrupted(pos) then
--local t = minetest.get_us_time()
local meta = minetest.get_meta(pos)
meta:set_int("runtime", (meta:get_int("runtime") or 1) + 1)
local number = meta:get_string("number")
local state = meta:get_int("state")
if state == tubelib.RUNNING and number then
execute(meta, number, debug)
end
--print("time", minetest.get_us_time() - t)
return true
end
--print("time", minetest.get_us_time() - t)
return true
return false
end
local function switch_state(pos, state, fs_data)

@ -28,8 +28,11 @@ local function display_update(pos, objref)
end
local function on_timer(pos)
local meta = minetest.get_meta(pos)
lcdlib.update_entities(pos)
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
lcdlib.update_entities(pos)
return false
end
return false
end

@ -139,12 +139,15 @@ minetest.register_node("smartline:playerdetector", {
end,
on_timer = function (pos, elapsed)
if scan_for_player(pos) then
switch_on(pos)
minetest.get_node_timer(pos):start(1)
return false
if tubelib.data_not_corrupted(pos) then
if scan_for_player(pos) then
switch_on(pos)
minetest.get_node_timer(pos):start(1)
return false
end
return true
end
return true
return false
end,
paramtype = "light",

@ -75,9 +75,12 @@ minetest.register_node("smartline:repeater", {
end,
on_timer = function(pos,elapsed)
local meta = minetest.get_meta(pos)
meta:set_int("overload_cnt", 0)
return true
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
meta:set_int("overload_cnt", 0)
return true
end
return false
end,
after_dig_node = function(pos)

@ -98,37 +98,40 @@ local function restart_timer(pos, time)
end
local function check_rules(pos, elapsed)
local meta = minetest.get_meta(pos)
local rules = minetest.deserialize(meta:get_string("rules"))
if rules then
local running = meta:get_int("running")
local index = meta:get_int("index") or 1
local number = meta:get_string("number")
local endless = meta:get_int("endless") or 0
local placer_name = meta:get_string("placer_name")
while true do -- process all rules as long as offs == 0
local rule = rules[index]
local offs = rules[index].offs
if type(offs) == "string" then
offs = 0
end
tubelib.send_message(rule.num, placer_name, nil, tAction[rule.act], number)
index = get_next_slot(index, rules, endless)
if index ~= nil and offs ~= nil and running == 1 then
-- after the last rule a pause with 2 or more sec is required
if index == 1 and offs < 1 then
offs = 2
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local rules = minetest.deserialize(meta:get_string("rules"))
if rules then
local running = meta:get_int("running")
local index = meta:get_int("index") or 1
local number = meta:get_string("number")
local endless = meta:get_int("endless") or 0
local placer_name = meta:get_string("placer_name")
while true do -- process all rules as long as offs == 0
local rule = rules[index]
local offs = rules[index].offs
if type(offs) == "string" then
offs = 0
end
meta:set_string("infotext", "SmartLine Sequencer "..number..": running ("..index.."/"..NUM_SLOTS..")")
meta:set_int("index", index)
if offs > 0 then
minetest.after(0, restart_timer, pos, offs)
return false
tubelib.send_message(rule.num, placer_name, nil, tAction[rule.act], number)
index = get_next_slot(index, rules, endless)
if index ~= nil and offs ~= nil and running == 1 then
-- after the last rule a pause with 2 or more sec is required
if index == 1 and offs < 1 then
offs = 2
end
meta:set_string("infotext", "SmartLine Sequencer "..number..": running ("..index.."/"..NUM_SLOTS..")")
meta:set_int("index", index)
if offs > 0 then
minetest.after(0, restart_timer, pos, offs)
return false
end
else
return stop_the_sequencer(pos)
end
else
return stop_the_sequencer(pos)
end
end
return false
end
return false
end
@ -147,7 +150,7 @@ local function start_the_sequencer(pos)
return false
end
local function on_receive_fields(pos, formname, fields, player)
local function on_receive_fields(pos, formname, fields, player)
local meta = minetest.get_meta(pos)
local running = meta:get_int("running")
if minetest.is_protected(pos, player:get_player_name()) then

@ -86,41 +86,44 @@ local function formspec_help()
end
local function check_rules(pos,elapsed)
local hour = math.floor(minetest.get_timeofday() * 24)
local meta = minetest.get_meta(pos)
local events = minetest.deserialize(meta:get_string("events"))
local numbers = minetest.deserialize(meta:get_string("numbers"))
local actions = minetest.deserialize(meta:get_string("actions"))
local done = minetest.deserialize(meta:get_string("done"))
local placer_name = meta:get_string("placer_name")
local own_num = meta:get_string("own_num")
-- check all rules
for idx,act in ipairs(actions) do
if act ~= "" and numbers[idx] ~= "" then
local hr = (events[idx] - 1) * 2
if ((hour - hr) % 24) <= 4 then -- last 4 hours?
if done[idx] == false then -- not already executed?
if tubelib.data_not_corrupted(pos) then
local hour = math.floor(minetest.get_timeofday() * 24)
local meta = minetest.get_meta(pos)
local events = minetest.deserialize(meta:get_string("events"))
local numbers = minetest.deserialize(meta:get_string("numbers"))
local actions = minetest.deserialize(meta:get_string("actions"))
local done = minetest.deserialize(meta:get_string("done"))
local placer_name = meta:get_string("placer_name")
local own_num = meta:get_string("own_num")
-- check all rules
for idx,act in ipairs(actions) do
if act ~= "" and numbers[idx] ~= "" then
local hr = (events[idx] - 1) * 2
if ((hour - hr) % 24) <= 4 then -- last 4 hours?
if done[idx] == false then -- not already executed?
tubelib.send_message(numbers[idx], placer_name, nil, act, own_num)
done[idx] = true
end
else
done[idx] = false
end
if hour == hr and done[idx] == false then
tubelib.send_message(numbers[idx], placer_name, nil, act, own_num)
done[idx] = true
end
else
done[idx] = false
end
if hour == hr and done[idx] == false then
tubelib.send_message(numbers[idx], placer_name, nil, act, own_num)
done[idx] = true
end
end
-- prepare for the next day
if hour == 23 then
done = {false,false,false,false,false,false}
end
meta:set_string("done", minetest.serialize(done))
meta:set_string("infotext","SmartLine Timer ("..own_num..")"..hour..":00")
return true
end
-- prepare for the next day
if hour == 23 then
done = {false,false,false,false,false,false}
end
meta:set_string("done", minetest.serialize(done))
meta:set_string("infotext","SmartLine Timer ("..own_num..")"..hour..":00")
return true
return false
end

@ -268,38 +268,41 @@ function techpack_warehouse.after_place_node(self, pos, placer, itemstack)
end
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("tubelib_number")
local player_name = meta:get_string("player_name")
local offs = meta:get_int("offs")
local push_dir = meta:get_string("push_dir")
if push_dir == "" then push_dir = "L" end
meta:set_int("offs", offs + 1)
for i = 0,7 do
local idx = ((i + offs) % 8) + 1
local stack = inv:get_stack("shift", idx)
if stack:get_count() > 0 then
if tubelib.push_items(pos, push_dir, stack, player_name) then
-- The effort is needed here for the case the
-- pusher pushes into its own chest.
local num = stack:get_count()
stack = inv:get_stack("shift", idx)
stack:take_item(num)
inv:set_stack("shift", idx, stack)
self.State:keep_running(pos, meta, COUNTDOWN_TICKS)
break
else
self.State:blocked(pos, meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
local inv = meta:get_inventory()
if not inv:is_empty("shift") then
--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")
if push_dir == "" then push_dir = "L" end
meta:set_int("offs", offs + 1)
for i = 0,7 do
local idx = ((i + offs) % 8) + 1
local stack = inv:get_stack("shift", idx)
if stack:get_count() > 0 then
if tubelib.push_items(pos, push_dir, stack, player_name) then
-- The effort is needed here for the case the
-- pusher pushes into its own chest.
local num = stack:get_count()
stack = inv:get_stack("shift", idx)
stack:take_item(num)
inv:set_stack("shift", idx, stack)
self.State:keep_running(pos, meta, COUNTDOWN_TICKS)
break
else
self.State:blocked(pos, meta)
end
end
end
else
self.State:idle(pos, meta)
end
else
self.State:idle(pos, meta)
return self.State:is_active(meta)
end
return self.State:is_active(meta)
return false
end
function techpack_warehouse.can_dig(self, pos)

@ -16,47 +16,51 @@
local function switch_on(pos, node)
node.name = "tubelib:button_active"
minetest.swap_node(pos, node)
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local cycle_time = meta:get_int("cycle_time")
if cycle_time > 0 then -- button mode?
minetest.get_node_timer(pos):start(cycle_time)
if tubelib.data_not_corrupted(pos) then
node.name = "tubelib:button_active"
minetest.swap_node(pos, node)
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local cycle_time = meta:get_int("cycle_time")
if cycle_time > 0 then -- button mode?
minetest.get_node_timer(pos):start(cycle_time)
end
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
end
tubelib.send_message(numbers, placer_name, clicker_name, "on", own_num) -- <<=== tubelib
end
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
end
tubelib.send_message(numbers, placer_name, clicker_name, "on", own_num) -- <<=== tubelib
end
local function switch_off(pos)
local node = minetest.get_node(pos)
node.name = "tubelib:button"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):stop()
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
if tubelib.data_not_corrupted(pos) then
local node = minetest.get_node(pos)
node.name = "tubelib:button"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):stop()
minetest.sound_play("button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
local clicker_name = nil
if meta:get_string("public") == "false" then
clicker_name = meta:get_string("clicker_name")
end
tubelib.send_message(numbers, placer_name, clicker_name, "off", own_num) -- <<=== tubelib
end
tubelib.send_message(numbers, placer_name, clicker_name, "off", own_num) -- <<=== tubelib
end

48
tubelib/defect.lua Normal file

@ -0,0 +1,48 @@
minetest.register_node("tubelib:defect_dummy", {
description = "Corrupted Tubelib Node",
tiles = {
"tubelib_front.png",
"tubelib_front.png",
"tubelib_front.png^tubelib_defect.png",
"tubelib_front.png^tubelib_defect.png",
"tubelib_front.png^tubelib_defect.png",
"tubelib_front.png^tubelib_defect.png",
},
drop = "",
groups = {cracky=3, crumbly=3, choppy=3, not_in_creative_inventory=1},
is_ground_content = false,
})
function tubelib.data_not_corrupted(pos)
if minetest.pos_to_string(pos) ~= minetest.get_meta(pos):get_string("my_pos") then
-- node number corrupt?
local meta = minetest.get_meta(pos)
local number = meta:get_string("tubelib_number")
if number == "" then
number = meta:get_string("number")
end
if number == "" then
number = meta:get_string("own_num")
end
if number == "" then
number = meta:get_string("own_number")
end
if number == "" then
tubelib.remove_node(pos)
minetest.set_node(pos, {name = "tubelib:defect_dummy"})
meta:from_table(nil)
return false
end
-- node moved?
local info = tubelib.get_node_info(number)
if not info or not vector.equals(info.pos, pos) then
tubelib.remove_node(pos)
minetest.set_node(pos, {name = "tubelib:defect_dummy"})
meta:from_table(nil)
return false
end
minetest.get_meta(pos):get_string("my_pos", minetest.pos_to_string(pos))
end
return true
end

@ -270,9 +270,12 @@ end
-- move items to the output slots
local function keep_running(pos, elapsed)
local meta = M(pos)
distributing(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
distributing(pos, meta)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -101,6 +101,7 @@ else
-- conversion from v1.16 to v2.00
dofile(minetest.get_modpath("tubelib") .. "/migrate.lua")
dofile(minetest.get_modpath("tubelib") .. "/states.lua")
dofile(minetest.get_modpath("tubelib") .. "/defect.lua")
dofile(minetest.get_modpath("tubelib") .. "/node_states.lua")
dofile(minetest.get_modpath("tubelib") .. "/pusher.lua")
dofile(minetest.get_modpath("tubelib") .. "/blackhole.lua")

@ -104,4 +104,32 @@ tubelib.register_node("shop:shop", {}, {
end,
})
tubelib.register_node("signs_bot:box", {}, {
on_pull_item = function(pos, side)
local meta = minetest.get_meta(pos)
return tubelib.get_item(meta, "main")
end,
on_push_item = function(pos, side, item)
local meta = minetest.get_meta(pos)
return tubelib.put_item(meta, "main", item)
end,
on_unpull_item = function(pos, side, item)
local meta = minetest.get_meta(pos)
return tubelib.put_item(meta, "main", item)
end,
})
tubelib.register_node("signs_bot:chest", {}, {
on_pull_item = function(pos, side)
local meta = minetest.get_meta(pos)
return tubelib.get_item(meta, "main")
end,
on_push_item = function(pos, side, item)
local meta = minetest.get_meta(pos)
return tubelib.put_item(meta, "main", item)
end,
on_unpull_item = function(pos, side, item)
local meta = minetest.get_meta(pos)
return tubelib.put_item(meta, "main", item)
end,
})

@ -376,17 +376,9 @@ function NodeStates:on_node_load(pos, not_start_timer)
meta:set_int("counter", 0)
end
-- node number corrupt?
number = meta:get_string("tubelib_number")
if number == "" then
number = tubelib.get_new_number(pos, self.node_name_passive)
meta:set_string("tubelib_number", number)
else
local info = tubelib.get_node_info(number)
if not info or info.pos ~= pos then
number = tubelib.get_new_number(pos, self.node_name_passive)
meta:set_string("tubelib_number", number)
end
-- node corrupt?
if not tubelib.data_not_corrupted(pos) then
return
end
-- state corrupt?

@ -66,9 +66,12 @@ local function pushing(pos, meta)
end
local function keep_running(pos, elapsed)
local meta = M(pos)
pushing(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
pushing(pos, meta)
return State:is_active(meta)
end
return false
end
minetest.register_node("tubelib:pusher", {

@ -6,6 +6,12 @@ the automated mining, farming, and crafting.
A Tutorial to this Mod is available as ![Wiki](https://github.com/joe7575/techpack/wiki)
With contributions from:
* obl3pplifp, https://github.com/obl3pplifp/techpack_compat and as pull requests
* realmicu, as pull requests
* theFox6, as pull request
## Dependencies
tubelib, default
opt. unified_inventory

@ -127,12 +127,15 @@ end
local function keep_running(pos, elapsed)
local meta = M(pos)
local inv = meta:get_inventory()
local craft = get_craft(pos, inv)
local output_item = craft.output.item
autocraft(pos, meta, inv, craft)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
local inv = meta:get_inventory()
local craft = get_craft(pos, inv)
local output_item = craft.output.item
autocraft(pos, meta, inv, craft)
return State:is_active(meta)
end
return false
end
-- note, that this function assumes allready being updated to virtual items

@ -14,26 +14,30 @@
local function switch_on(pos)
local node = minetest.get_node(pos)
node.name = "tubelib_addons1:detector_active"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):start(1)
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "on", own_num)
if tubelib.data_not_corrupted(pos) then
local node = minetest.get_node(pos)
node.name = "tubelib_addons1:detector_active"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):start(1)
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "on", own_num)
end
end
local function switch_off(pos)
local node = minetest.get_node(pos)
node.name = "tubelib_addons1:detector"
minetest.swap_node(pos, node)
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "off", own_num)
if tubelib.data_not_corrupted(pos) then
local node = minetest.get_node(pos)
node.name = "tubelib_addons1:detector"
minetest.swap_node(pos, node)
local meta = minetest.get_meta(pos)
local own_num = meta:get_string("own_num")
local numbers = meta:get_string("numbers")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "off", own_num)
end
end

@ -144,9 +144,12 @@ local function convert_leaves_to_biogas(pos, meta)
end
local function keep_running(pos, elapsed)
local meta = M(pos)
convert_leaves_to_biogas(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
convert_leaves_to_biogas(pos, meta)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -103,10 +103,13 @@ local function grinding(pos, meta, inv)
end
local function keep_running(pos, elapsed)
local meta = M(pos)
local inv = meta:get_inventory()
grinding(pos, meta, inv)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
local inv = meta:get_inventory()
grinding(pos, meta, inv)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -243,30 +243,33 @@ end
-- move the "harvesting copter" to the next pos and harvest the field below
local function keep_running(pos, elapsed)
local meta = M(pos)
local this = minetest.deserialize(meta:get_string("this"))
this.num_items = 0
if not_blocked(pos, this, meta) then
if check_fuel(pos, this, meta) then
if calc_new_pos(pos, this, meta) then
if harvest_field(this, meta) then
meta:set_string("this", minetest.serialize(this))
meta:set_string("infotext",
"Tubelib Harvester "..this.number..
": running ("..this.idx.."/"..this.max..")")
State:keep_running(pos, meta, COUNTDOWN_TICKS, this.num_items)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
local this = minetest.deserialize(meta:get_string("this"))
this.num_items = 0
if not_blocked(pos, this, meta) then
if check_fuel(pos, this, meta) then
if calc_new_pos(pos, this, meta) then
if harvest_field(this, meta) then
meta:set_string("this", minetest.serialize(this))
meta:set_string("infotext",
"Tubelib Harvester "..this.number..
": running ("..this.idx.."/"..this.max..")")
State:keep_running(pos, meta, COUNTDOWN_TICKS, this.num_items)
else
State:blocked(pos, meta)
end
else
State:blocked(pos, meta)
State:stop(pos, meta)
end
else
State:stop(pos, meta)
State:fault(pos, meta)
end
else
State:fault(pos, meta)
end
return State:is_active(meta)
end
return State:is_active(meta)
return false
end

@ -112,9 +112,12 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
end
local function keep_running(pos, elapsed)
local meta = M(pos)
sample_liquid(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
sample_liquid(pos, meta)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -48,6 +48,7 @@ local tn = tubelib_addons1.register_tree_node
local dn = tubelib_addons1.register_default_farming_node
local fn = tubelib_addons1.register_farming_node
local gn = tubelib_addons1.register_ground_node
local gr = tubelib.add_grinder_recipe
-------------------------------------------------------------------------------
-- Default Farming
@ -103,6 +104,13 @@ if farming.mod == "redo" then
fn("farming:oat_8", "farming:oat", "farming:oat_1")
fn("farming:rye_8", "farming:rye", "farming:rye_1")
fn("farming:rice_8", "farming:rice", "farming:rice_1")
fn('farming:beetroot_5', 'farming:beetroot 2', 'farming:beetroot_1')
fn('farming:cocoa_4', 'farming:cocoa_beans 2', 'farming:cocoa_1')
fn('farming:garlic_5', 'farming:garlic 2', 'farming:garlic_1')
fn('farming:onion_5', 'farming:onion 2', 'farming:onion_1')
fn('farming:pea_5', 'farming:pea_pod 3', 'farming:pea_1')
fn('farming:pepper_5', 'farming:pepper 2', 'farming:pepper_1')
fn('farming:pineapple_8', 'farming:pineapple 1', 'farming:pineapple_1')
end
-------------------------------------------------------------------------------
@ -246,3 +254,55 @@ end
minetest.after(10, register_flowers)
-------------------------------------------------------------------------------
-- moretrees
-------------------------------------------------------------------------------
if minetest.global_exists("moretrees") then
local function register_tree(treename)
local trunk_name = 'moretrees:' .. treename .. '_trunk'
local sappling_name = 'moretrees:' .. treename .. '_sapling'
local leaves_name = 'moretrees:' .. treename .. '_leaves'
tn(trunk_name, trunk_name, sappling_name)
fn(leaves_name)
gr({input=trunk_name, output=leaves_name .. ' 8'})
end
-- "ordinary" moretrees blocks
for i in ipairs(moretrees.treelist) do
local treename = moretrees.treelist[i][1]
if treename ~= 'jungletree' then
register_tree(treename)
end
end
-- "weird" moretrees trunks
tn('moretrees:date_palm_fruit_trunk', 'moretrees:date_palm_trunk', 'moretrees:date_palm_sapling')
gr({input='moretrees:date_palm_fruit_trunk', output='moretrees:date_palm_leaves 8'})
tn('moretrees:date_palm_ffruit_trunk', 'moretrees:date_palm_trunk', 'moretrees:date_palm_sapling')
gr({input='moretrees:date_palm_ffruit_trunk', output='moretrees:date_palm_leaves 8'})
tn('moretrees:date_palm_mfruit_trunk', 'moretrees:date_palm_trunk', 'moretrees:date_palm_sapling')
gr({input='moretrees:date_palm_mfruit_trunk', output='moretrees:date_palm_leaves 8'})
tn('moretrees:jungletree_trunk', 'default:jungletree', 'default:junglesapling')
gr({input='moretrees:jungletree_trunk', output='default:jungleleaves 8'})
tn('moretrees:palm_fruit_trunk', 'moretrees:palm_trunk', 'moretrees:palm_sapling')
gr({input='moretrees:palm_fruit_trunk', output='moretrees:palm_leaves 8'})
tn('moretrees:palm_fruit_trunk_gen', 'moretrees:palm_trunk', 'moretrees:palm_sapling')
gr({input='moretrees:palm_fruit_trunk_gen', output='moretrees:palm_leaves 8'})
tn('moretrees:rubber_tree_trunk_empty', 'moretrees:rubber_tree_trunk_empty', 'moretrees:rubber_tree_sapling')
gr({input='moretrees:rubber_tree_trunk_empty', output='moretrees:rubber_tree_leaves 8'})
-- moretrees fruit and leaves
fn('moretrees:acorn')
fn('moretrees:cedar_cone')
fn('moretrees:coconut_3', 'moretrees:coconut')
fn('moretrees:dates_f4', 'moretrees:date 16')
fn('moretrees:fir_cone')
fn('moretrees:fir_leaves_bright')
fn('moretrees:jungletree_leaves_red')
fn('moretrees:jungletree_leaves_yellow')
fn('moretrees:spruce_cone')
end

@ -66,9 +66,12 @@ local function pushing(pos, meta)
end
local function keep_running(pos, elapsed)
local meta = M(pos)
pushing(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
pushing(pos, meta)
return State:is_active(meta)
end
return false
end
minetest.register_node("tubelib_addons1:pusher_fast", {

@ -238,9 +238,12 @@ local function quarry_next_node(pos, meta)
end
local function keep_running(pos, elapsed)
local meta = M(pos)
quarry_next_node(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
quarry_next_node(pos, meta)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -139,9 +139,12 @@ end
local function keep_running(pos, elapsed)
local meta = M(pos)
convert_biogas_to_biofuel(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
convert_biogas_to_biofuel(pos, meta)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -13,29 +13,33 @@
]]--
local function switch_on(pos, meta)
minetest.sound_play("tubelib_addons2_door", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local numbers = meta:get_string("numbers")
local number = meta:get_string("number")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "on", number)
minetest.get_node_timer(pos):start(4)
if tubelib.data_not_corrupted(pos) then
minetest.sound_play("tubelib_addons2_door", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local numbers = meta:get_string("numbers")
local number = meta:get_string("number")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "on", number)
minetest.get_node_timer(pos):start(4)
end
end
local function switch_off(pos)
minetest.sound_play("tubelib_addons2_door", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local numbers = meta:get_string("numbers")
local number = meta:get_string("number")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "off", number)
if tubelib.data_not_corrupted(pos) then
minetest.sound_play("tubelib_addons2_door", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
local meta = minetest.get_meta(pos)
local numbers = meta:get_string("numbers")
local number = meta:get_string("number")
local placer_name = meta:get_string("placer_name")
tubelib.send_message(numbers, placer_name, nil, "off", number)
end
end
local function formspec1(numbers)

@ -76,19 +76,21 @@ minetest.register_craft({
tubelib.register_node("tubelib_addons2:logic_not", {}, {
on_recv_message = function(pos, topic, payload)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local numbers = meta:get_string("numbers")
local own_number = meta:get_string("own_number")
if topic == "set_numbers" then
meta:set_string("infotext", "Tubelib Logic Not "..own_number..": connected with "..payload)
meta:set_string("numbers", payload)
meta:set_string("formspec", formspec(meta))
return true
elseif topic == "on" then
return tubelib.send_message(numbers, owner, nil, "off", payload)
elseif topic == "off" then
return tubelib.send_message(numbers, owner, nil, "on", payload)
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local numbers = meta:get_string("numbers")
local own_number = meta:get_string("own_number")
if topic == "set_numbers" then
meta:set_string("infotext", "Tubelib Logic Not "..own_number..": connected with "..payload)
meta:set_string("numbers", payload)
meta:set_string("formspec", formspec(meta))
return true
elseif topic == "on" then
return tubelib.send_message(numbers, owner, nil, "off", payload)
elseif topic == "off" then
return tubelib.send_message(numbers, owner, nil, "on", payload)
end
end
end,
})

@ -108,9 +108,12 @@ minetest.register_node("tubelib_addons2:mesecons_converter", {
},
on_timer = function(pos,elapsed)
local meta = minetest.get_meta(pos)
meta:set_int("overload_cnt", 0)
return true
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
meta:set_int("overload_cnt", 0)
return true
end
return false
end,
after_dig_node = function(pos)

@ -62,9 +62,12 @@ minetest.register_node("tubelib_addons2:repeater", {
end,
on_timer = function(pos,elapsed)
local meta = minetest.get_meta(pos)
meta:set_int("overload_cnt", 0)
return true
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
meta:set_int("overload_cnt", 0)
return true
end
return false
end,
after_dig_node = function(pos)

@ -89,37 +89,40 @@ local function restart_timer(pos, time)
end
local function check_rules(pos, elapsed)
local meta = minetest.get_meta(pos)
local rules = minetest.deserialize(meta:get_string("rules"))
if rules then
local running = meta:get_int("running")
local index = meta:get_int("index") or 1
local number = meta:get_string("number")
local endless = meta:get_int("endless") or 0
local placer_name = meta:get_string("placer_name")
while true do -- process all rules as long as offs == 0
local rule = rules[index]
local offs = rules[index].offs
if type(offs) == "string" then
offs = 0
end
tubelib.send_message(rule.num, placer_name, nil, tAction[rule.act], number)
index = get_next_slot(index, rules, endless)
if index ~= nil and offs ~= nil and running == 1 then
-- after the last rule a pause with 1 or more sec is required
if index == 1 and offs < 1 then
offs = 1
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local rules = minetest.deserialize(meta:get_string("rules"))
if rules then
local running = meta:get_int("running")
local index = meta:get_int("index") or 1
local number = meta:get_string("number")
local endless = meta:get_int("endless") or 0
local placer_name = meta:get_string("placer_name")
while true do -- process all rules as long as offs == 0
local rule = rules[index]
local offs = rules[index].offs
if type(offs) == "string" then
offs = 0
end
meta:set_string("infotext", "Tubelib Sequencer "..number..": running ("..index.."/"..NUM_SLOTS..")")
meta:set_int("index", index)
if offs > 0 then
minetest.after(0, restart_timer, pos, offs)
return false
tubelib.send_message(rule.num, placer_name, nil, tAction[rule.act], number)
index = get_next_slot(index, rules, endless)
if index ~= nil and offs ~= nil and running == 1 then
-- after the last rule a pause with 1 or more sec is required
if index == 1 and offs < 1 then
offs = 1
end
meta:set_string("infotext", "Tubelib Sequencer "..number..": running ("..index.."/"..NUM_SLOTS..")")
meta:set_int("index", index)
if offs > 0 then
minetest.after(0, restart_timer, pos, offs)
return false
end
else
return stop_the_sequencer(pos)
end
else
return stop_the_sequencer(pos)
end
end
return false
end
return false
end
@ -139,54 +142,56 @@ local function start_the_sequencer(pos)
end
local function on_receive_fields(pos, formname, fields, player)
local meta = minetest.get_meta(pos)
local running = meta:get_int("running")
if minetest.is_protected(pos, player:get_player_name()) then
return
end
if fields.help ~= nil then
meta:set_string("formspec", formspec_help())
return
end
local endless = meta:get_int("endless") or 0
if fields.endless ~= nil then
endless = fields.endless == "true" and 1 or 0
meta:set_int("index", 1)
end
meta:set_int("endless", endless)
local rules = minetest.deserialize(meta:get_string("rules"))
if fields.exit ~= nil then
meta:set_string("formspec", formspec(tubelib.state(running), rules, endless))
return
end
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local running = meta:get_int("running")
if minetest.is_protected(pos, player:get_player_name()) then
return
end
if fields.help ~= nil then
meta:set_string("formspec", formspec_help())
return
end
local endless = meta:get_int("endless") or 0
if fields.endless ~= nil then
endless = fields.endless == "true" and 1 or 0
meta:set_int("index", 1)
end
meta:set_int("endless", endless)
local rules = minetest.deserialize(meta:get_string("rules"))
if fields.exit ~= nil then
meta:set_string("formspec", formspec(tubelib.state(running), rules, endless))
return
end
for idx = 1,NUM_SLOTS do
if fields["offs"..idx] ~= nil then
rules[idx].offs = tonumber(fields["offs"..idx]) or ""
for idx = 1,NUM_SLOTS do
if fields["offs"..idx] ~= nil then
rules[idx].offs = tonumber(fields["offs"..idx]) or ""
end
if fields["num"..idx] ~= nil and tubelib.check_numbers(fields["num"..idx]) then
rules[idx].num = fields["num"..idx]
end
if fields["act"..idx] ~= nil then
rules[idx].act = kvAction[fields["act"..idx]]
end
end
if fields["num"..idx] ~= nil and tubelib.check_numbers(fields["num"..idx]) then
rules[idx].num = fields["num"..idx]
end
if fields["act"..idx] ~= nil then
rules[idx].act = kvAction[fields["act"..idx]]
end
end
meta:set_string("rules", minetest.serialize(rules))
meta:set_string("rules", minetest.serialize(rules))
if fields.button ~= nil then
if running > STOP_STATE then
if fields.button ~= nil then
if running > STOP_STATE then
stop_the_sequencer(pos)
else
start_the_sequencer(pos)
end
elseif fields.num1 ~= nil then -- any other change?
stop_the_sequencer(pos)
else
start_the_sequencer(pos)
local endless = meta:get_int("endless") or 0
meta:set_string("formspec", formspec(tubelib.state(running), rules, endless))
end
elseif fields.num1 ~= nil then -- any other change?
stop_the_sequencer(pos)
else
local endless = meta:get_int("endless") or 0
meta:set_string("formspec", formspec(tubelib.state(running), rules, endless))
end
end

@ -67,37 +67,40 @@ end
local function check_rules(pos,elapsed)
local hour = math.floor(minetest.get_timeofday() * 24)
local meta = minetest.get_meta(pos)
local events = minetest.deserialize(meta:get_string("events"))
local numbers = minetest.deserialize(meta:get_string("numbers"))
local actions = minetest.deserialize(meta:get_string("actions"))
local done = minetest.deserialize(meta:get_string("done"))
local placer_name = meta:get_string("placer_name")
local number = meta:get_string("number")
-- check all rules
for idx,act in ipairs(actions) do
if act ~= "" and numbers[idx] ~= "" then
local hr = (events[idx] - 1) * 2
if ((hour - hr) % 24) <= 4 then -- last 4 hours?
if done[idx] == false then -- not already executed?
tubelib.send_message(numbers[idx], placer_name, nil, act, number)
done[idx] = true
if tubelib.data_not_corrupted(pos) then
local hour = math.floor(minetest.get_timeofday() * 24)
local meta = minetest.get_meta(pos)
local events = minetest.deserialize(meta:get_string("events"))
local numbers = minetest.deserialize(meta:get_string("numbers"))
local actions = minetest.deserialize(meta:get_string("actions"))
local done = minetest.deserialize(meta:get_string("done"))
local placer_name = meta:get_string("placer_name")
local number = meta:get_string("number")
-- check all rules
for idx,act in ipairs(actions) do
if act ~= "" and numbers[idx] ~= "" then
local hr = (events[idx] - 1) * 2
if ((hour - hr) % 24) <= 4 then -- last 4 hours?
if done[idx] == false then -- not already executed?
tubelib.send_message(numbers[idx], placer_name, nil, act, number)
done[idx] = true
end
else
done[idx] = false
end
else
done[idx] = false
end
end
-- prepare for the next day
if hour == 23 then
done = {false,false,false,false,false,false}
end
meta:set_string("done", minetest.serialize(done))
meta:set_string("infotext","Tubelib Timer "..hour..":00")
return true
end
-- prepare for the next day
if hour == 23 then
done = {false,false,false,false,false,false}
end
meta:set_string("done", minetest.serialize(done))
meta:set_string("infotext","Tubelib Timer "..hour..":00")
return true
return false
end

@ -254,9 +254,12 @@ end
-- move items to the output slots
local function keep_running(pos, elapsed)
local meta = M(pos)
distributing(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
distributing(pos, meta)
return State:is_active(meta)
end
return false
end
local function on_receive_fields(pos, formname, fields, player)

@ -51,9 +51,12 @@ local function pushing(pos, meta)
end
local function keep_running(pos, elapsed)
local meta = M(pos)
pushing(pos, meta)
return State:is_active(meta)
if tubelib.data_not_corrupted(pos) then
local meta = M(pos)
pushing(pos, meta)
return State:is_active(meta)
end
return false
end
minetest.register_node("tubelib_addons3:pusher", {

@ -90,33 +90,36 @@ local function configured(pos, item)
end
local function shift_items(pos, elapsed)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("shift") then
local number = meta:get_string("number")
local player_name = meta:get_string("player_name")
local offs = meta:get_int("offs")
meta:set_int("offs", offs + 1)
for i = 0,7 do
local idx = ((i + offs) % 8) + 1
local stack = inv:get_stack("shift", idx)
if stack:get_count() > 0 then
if tubelib.push_items(pos, "R", stack, player_name) then
-- The effort is needed here for the case the
-- pusher pushes into its own chest.
local num = stack:get_count()
stack = inv:get_stack("shift", idx)
stack:take_item(num)
inv:set_stack("shift", idx, stack)
aging(pos, meta)
return true
else
set_state(meta, "blocked")
if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("shift") then
local number = meta:get_string("number")
local player_name = meta:get_string("player_name")
local offs = meta:get_int("offs")
meta:set_int("offs", offs + 1)
for i = 0,7 do
local idx = ((i + offs) % 8) + 1
local stack = inv:get_stack("shift", idx)
if stack:get_count() > 0 then
if tubelib.push_items(pos, "R", stack, player_name) then
-- The effort is needed here for the case the
-- pusher pushes into its own chest.
local num = stack:get_count()
stack = inv:get_stack("shift", idx)
stack:take_item(num)
inv:set_stack("shift", idx, stack)
aging(pos, meta)
return true
else
set_state(meta, "blocked")
end
end
end
end
return true
end
return true
return false
end
local function formspec()