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

View File

@ -150,6 +150,7 @@ tubelib_addons1 optional: unified_inventory
- 2019-01-12 V2.00 * release - 2019-01-12 V2.00 * release
- 2019-01-27 V2.01 * SaferLua Controller Terminal added - 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-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) ## New in v2 (from players point of view)

View File

@ -1,5 +1,21 @@
# Release Notes for ModPack TechPack [techpack] # 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) ## V2.02.06 (2019-03-23)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -86,41 +86,44 @@ local function formspec_help()
end end
local function check_rules(pos,elapsed) local function check_rules(pos,elapsed)
local hour = math.floor(minetest.get_timeofday() * 24) if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos) local hour = math.floor(minetest.get_timeofday() * 24)
local events = minetest.deserialize(meta:get_string("events")) local meta = minetest.get_meta(pos)
local numbers = minetest.deserialize(meta:get_string("numbers")) local events = minetest.deserialize(meta:get_string("events"))
local actions = minetest.deserialize(meta:get_string("actions")) local numbers = minetest.deserialize(meta:get_string("numbers"))
local done = minetest.deserialize(meta:get_string("done")) local actions = minetest.deserialize(meta:get_string("actions"))
local placer_name = meta:get_string("placer_name") local done = minetest.deserialize(meta:get_string("done"))
local own_num = meta:get_string("own_num") 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 -- check all rules
if act ~= "" and numbers[idx] ~= "" then for idx,act in ipairs(actions) do
local hr = (events[idx] - 1) * 2 if act ~= "" and numbers[idx] ~= "" then
if ((hour - hr) % 24) <= 4 then -- last 4 hours? local hr = (events[idx] - 1) * 2
if done[idx] == false then -- not already executed? 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) tubelib.send_message(numbers[idx], placer_name, nil, act, own_num)
done[idx] = true done[idx] = true
end 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
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 end
return false
-- 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 end

View File

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

View File

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

48
tubelib/defect.lua Normal file
View 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

View File

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

View File

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

View File

@ -104,4 +104,32 @@ tubelib.register_node("shop:shop", {}, {
end, 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,
})

View File

@ -376,17 +376,9 @@ function NodeStates:on_node_load(pos, not_start_timer)
meta:set_int("counter", 0) meta:set_int("counter", 0)
end end
-- node number corrupt? -- node corrupt?
number = meta:get_string("tubelib_number") if not tubelib.data_not_corrupted(pos) then
if number == "" then return
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
end end
-- state corrupt? -- state corrupt?

View File

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

View File

@ -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) 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 ## Dependencies
tubelib, default tubelib, default
opt. unified_inventory opt. unified_inventory

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,6 +48,7 @@ local tn = tubelib_addons1.register_tree_node
local dn = tubelib_addons1.register_default_farming_node local dn = tubelib_addons1.register_default_farming_node
local fn = tubelib_addons1.register_farming_node local fn = tubelib_addons1.register_farming_node
local gn = tubelib_addons1.register_ground_node local gn = tubelib_addons1.register_ground_node
local gr = tubelib.add_grinder_recipe
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Default Farming -- Default Farming
@ -103,6 +104,13 @@ if farming.mod == "redo" then
fn("farming:oat_8", "farming:oat", "farming:oat_1") fn("farming:oat_8", "farming:oat", "farming:oat_1")
fn("farming:rye_8", "farming:rye", "farming:rye_1") fn("farming:rye_8", "farming:rye", "farming:rye_1")
fn("farming:rice_8", "farming:rice", "farming:rice_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 end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -246,3 +254,55 @@ end
minetest.after(10, register_flowers) 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -67,37 +67,40 @@ end
local function check_rules(pos,elapsed) local function check_rules(pos,elapsed)
local hour = math.floor(minetest.get_timeofday() * 24) if tubelib.data_not_corrupted(pos) then
local meta = minetest.get_meta(pos) local hour = math.floor(minetest.get_timeofday() * 24)
local events = minetest.deserialize(meta:get_string("events")) local meta = minetest.get_meta(pos)
local numbers = minetest.deserialize(meta:get_string("numbers")) local events = minetest.deserialize(meta:get_string("events"))
local actions = minetest.deserialize(meta:get_string("actions")) local numbers = minetest.deserialize(meta:get_string("numbers"))
local done = minetest.deserialize(meta:get_string("done")) local actions = minetest.deserialize(meta:get_string("actions"))
local placer_name = meta:get_string("placer_name") local done = minetest.deserialize(meta:get_string("done"))
local number = meta:get_string("number") local placer_name = meta:get_string("placer_name")
local number = meta:get_string("number")
-- check all rules
for idx,act in ipairs(actions) do -- check all rules
if act ~= "" and numbers[idx] ~= "" then for idx,act in ipairs(actions) do
local hr = (events[idx] - 1) * 2 if act ~= "" and numbers[idx] ~= "" then
if ((hour - hr) % 24) <= 4 then -- last 4 hours? local hr = (events[idx] - 1) * 2
if done[idx] == false then -- not already executed? if ((hour - hr) % 24) <= 4 then -- last 4 hours?
tubelib.send_message(numbers[idx], placer_name, nil, act, number) if done[idx] == false then -- not already executed?
done[idx] = true tubelib.send_message(numbers[idx], placer_name, nil, act, number)
done[idx] = true
end
else
done[idx] = false
end end
else
done[idx] = false
end end
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 end
return false
-- 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 end

View File

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

View File

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

View File

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