--[[
red = door down
blue = door up
black = door back
white = door fwd
orange = seeder fwd
yellow = seeder back
lime = seeder up
cyan = seeder down
light blue = deploy!
gray = hide up
light gray = hide down
brown = hide back
purple = hide fwd
magenta = water harvest
--]]
local out = "back"
local dDown = colors.red
local dUp = colors.blue
local dBackwd = colors.black
local dFwd = colors.white
local sFwd = colors.orange
local sBackwd = colors.yellow
local sUp = colors.lime
local sDown = colors.cyan
local deployer = colors.lightBlue
local hUp = colors.gray
local hDown = colors.lightGray
local hBackwd = colors.brown
local hFwd = colors.purple
local wHarvest = colors.magenta
-- WATER HARVEST
function Harvest()
rs.setBundledOutput(out, wHarvest)
sleep(70)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- DEPLOYER
function Deploy()
rs.setBundledOutput(out, deployer)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- SEEDER UP
function msUp()
rs.setBundledOutput(out, sUp)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- SEEDER DOWN
function msDown()
rs.setBundledOutput(out, sDown)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- SEEDER FWD
function msForward()
rs.setBundledOutput(out, sFwd)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- SEEDER BACK
function msBack()
rs.setBundledOutput(out, sBackwd)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- DOOR UP
function mdUp()
rs.setBundledOutput(out, dUp)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- DOOR DOWN
function mdDown()
rs.setBundledOutput(out, dDown)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- DOOR FWD
function mdForward()
rs.setBundledOutput(out, dFwd)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- DOOR BACK
function mdBack()
rs.setBundledOutput(out, dBackwd)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- HIDE UP
function mhUp()
rs.setBundledOutput(out, hUp)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- HIDE DOWN
function mhDown()
rs.setBundledOutput(out, hDown)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- HIDE FWD
function mhForward()
rs.setBundledOutput(out, hFwd)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
-- HIDE BACK
function mhBack()
rs.setBundledOutput(out, hBackwd)
sleep(0.1)
rs.setBundledOutput(out, 0)
sleep(1)
end
function openDoor()
-- 3x down, 4x back
mdDown()
mdDown()
mdDown()
mdBack()
mdBack()
mdBack()
mdBack()
end
function closeDoor()
-- 4x fwd, 3x up
mdForward()
mdForward()
mdForward()
mdForward()
mdUp()
mdUp()
mdUp()
end
function hideS()
-- 7x down, 4x back
mhDown()
mhDown()
mhDown()
mhDown()
mhDown()
mhDown()
mhDown()
mhBack()
mhBack()
mhBack()
mhBack()
end
function unhideS()
-- 4x fwd, 7x up
mhForward()
mhForward()
mhForward()
mhForward()
mhUp()
mhUp()
mhUp()
mhUp()
mhUp()
mhUp()
mhUp()
end
function seedOneField()
msForward()
Deploy()
msForward()
Deploy()
msForward()
Deploy()
msForward()
Deploy()
msForward()
Deploy()
msForward()
Deploy()
msForward()
Deploy()
end
function seedAll()
msForward()
msForward()
seedOneField()
msUp()
seedOneField()
msUp()
seedOneField()
msUp()
seedOneField()
msUp()
seedOneField()
msUp()
seedOneField()
end
function sReturn()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msDown()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msDown()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msDown()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msDown()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msDown()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
msBack()
end
function doEverything()
openDoor()
unhideS()
seedAll()
sReturn()
hideS()
closeDoor()
end
function printMenu()
local hhline = "============================"
local hline = "----------------------------"
term.clear()
term.setCursorPos(1,1)
print(hhline)
print("|| Seeder control panel ||")
print(hline)
print("| Available operations: |")
print("| 1. Seed all (fullauto) |")
print("| 2. Seed all (refill pos) |")
print("| 3. Refill position |")
print("| 4. Park seeder |")
print("| 5. Open door |")
print("| 6. Close door |")
print("| 7. Harvest |")
print(hline)
end
function input()
local validChoice = false
local choice = 0
while not validChoice do
print("Please make your choice:")
local input = tonumber(read())
if input ~= 1 and input ~= 2 and input ~= 3 and input ~= 4 and input ~= 5 and input ~= 6 and input ~= 7 then
print("Invalid choice, try again.")
validChoice = false
else
choice = input
validChoice = true
end
end
return choice
end
function doChoice(choice)
choice = tonumber(choice)
if choice == 1 then
doEverything()
elseif choice == 2 then
seedAll()
sReturn()
elseif choice == 3 then
--if not doorIsOpen then
openDoor()
--end
--if sIsHidden then
unhideS()
--end
elseif choice == 4 then
--if doorIsOpen and not sIsHidden then
hideS()
--end
elseif choice == 5 then
--if not doorIsOpen then
openDoor()
--end
elseif choice == 6 then
--if doorIsOpen then
closeDoor()
--end
elseif choice == 7 then
Harvest()
end
end
function main()
while true do
printMenu()
local usrInput = input()
doChoice(usrInput)
end
end
main()