Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --white(Rancher) == left
- --black(Breeder) == top
- local modem = peripheral.wrap("back")
- local rs_Chronotyper = "left"
- local rs_Breeder = "top"
- local rs_Grinder = "right"
- local freq = 3
- function toggleBreeder()
- rs.setOutput(rs_Breeder, not rs.getOutput(rs_Breeder))
- return rs.getOutput(rs_Breeder)
- end
- function toggleChronotyper()
- rs.setOutput(rs_Chronotyper, not rs.getOutput(rs_Chronotyper))
- return rs.getOutput(rs_Chronotyper)
- end
- function toggleGrinder()
- rs.setOutput(rs_Grinder, not rs.getOutput(rs_Grinder))
- return rs.getOutput(rs_Grinder)
- end
- function growFlock()
- if rs.getOutput(rs_Breeder) == true then
- toggleBreeder()
- end
- if rs.getOutput(rs_Chronotyper) == false then
- toggleChronotyper()
- end
- if rs.getOutput(rs_Grinder) == false then
- toggleGrinder()
- end
- end
- function harvest()
- if rs.getOutput(rs_Grinder) == true then
- toggleGrinder()
- end
- if rs.getOutput(rs_Chronotyper) == true then
- toggleChronotyper()
- end
- if rs.getOutput(rs_Breeder) == true then
- toggleBreeder()
- end
- end
- function stopAll()
- if rs.getOutput(rs_Breeder) == false then
- toggleBreeder()
- end
- if rs.getOutput(rs_Chronotyper) == false then
- toggleChronotyper()
- end
- if rs.getOutput(rs_Grinder) == false then
- toggleChronotyper()
- end
- end
- modem.setListening(freq, false)
- term.clear()
- term.setCursorPos(1,1)
- print(modem.getListening(freq))
- modem.setListening(freq, true)
- print(modem.getListening(freq))
- repeat
- local eventType, side, id, chan, message = "null", "null", 0, 0, "null"
- eventType, side, id, chan, message = os.pullEvent()
- if eventType == "lan_message" and chan == 3 then
- print(eventType.." "..chan.." "..message)
- if message == "grow" then
- growFlock()
- print("Grown")
- elseif message == "stop" then
- stopAll()
- print("not growing")
- elseif message == "kill" then
- harvest()
- print("Harvesting")
- else
- print("Invalid Message")
- end
- end
- until false
- --while true do
- -- term.clear()
- -- term.setCursorPos(1,1)
- -- write("1 - Breeder, 2 - Rancher: ")
- -- local input = read()
- -- if input == "1" then
- -- local output = toggleBreeder()
- -- print(output)
- -- sleep(2)
- -- elseif input == "2" then
- -- local output = toggleRancher()
- -- print(output)
- -- else
- -- print("failed")
- -- sleep(2)
- -- end
- --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement