Tweaked farm_control.lua so that the planting and harvesting are separate
This commit is contained in:
parent
86a170fce1
commit
7f929c2cc8
1 changed files with 10 additions and 7 deletions
|
|
@ -6,11 +6,13 @@ LEVELS["minecraft:oak_log"] = {4 * 64, "minecraft:oak_sapling"}
|
||||||
|
|
||||||
local STORAGE = ""
|
local STORAGE = ""
|
||||||
local HARVESTER = ""
|
local HARVESTER = ""
|
||||||
|
local PLANTER = ""
|
||||||
|
|
||||||
local HARVESTER_RELAY = ""
|
local HARVESTER_RELAY = ""
|
||||||
|
local PLANTER_RELAY = ""
|
||||||
|
|
||||||
local SLEEP_TIME = 10
|
local SLEEP_TIME = 40
|
||||||
local HARVESTER_SIGNAL_TIME = 2
|
local SIGNAL_TIME = 2
|
||||||
|
|
||||||
-------------------------------- PROGRAM --------------------------------------
|
-------------------------------- PROGRAM --------------------------------------
|
||||||
|
|
||||||
|
|
@ -51,13 +53,12 @@ function load_stack(item_name, src, dest)
|
||||||
local src = peripheral.wrap(src)
|
local src = peripheral.wrap(src)
|
||||||
for slot, item in pairs(src.list()) do
|
for slot, item in pairs(src.list()) do
|
||||||
if item.name == item_name then
|
if item.name == item_name then
|
||||||
src.pushItems(dest, slot)
|
return src.pushItems(dest, slot)
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function send_harvester (relay_and_side)
|
function send_machine (relay_and_side)
|
||||||
local RELAY_COMMAND = "setOutput"
|
local RELAY_COMMAND = "setOutput"
|
||||||
local relay, side = relay_and_side:match"(.+):(.+)"
|
local relay, side = relay_and_side:match"(.+):(.+)"
|
||||||
peripheral.call(relay, RELAY_COMMAND, side, true)
|
peripheral.call(relay, RELAY_COMMAND, side, true)
|
||||||
|
|
@ -72,10 +73,12 @@ while true do
|
||||||
local needs_farming = check_levels(LEVELS, STORAGE)
|
local needs_farming = check_levels(LEVELS, STORAGE)
|
||||||
if needs_farming ~= nil then
|
if needs_farming ~= nil then
|
||||||
for _, item in ipairs(needs_farming) do
|
for _, item in ipairs(needs_farming) do
|
||||||
load_stack(item, STORAGE, HARVESTER)
|
load_stack(item, STORAGE, PLANTER)
|
||||||
end
|
end
|
||||||
|
send_machine(PLANTER_RELAY)
|
||||||
|
os.sleep(SLEEP_TIME)
|
||||||
end
|
end
|
||||||
send_harvester(HARVESTER_RELAY)
|
send_machine(HARVESTER_RELAY)
|
||||||
os.sleep(SLEEP_TIME)
|
os.sleep(SLEEP_TIME)
|
||||||
pull_items(HARVESTER, STORAGE)
|
pull_items(HARVESTER, STORAGE)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue