Advertisement
Guest User

pig

a guest
Jan 24th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. --white(Rancher) == left
  2. --black(Breeder) == top
  3.  
  4. local modem = peripheral.wrap("back")
  5. local rs_Chronotyper = "left"
  6. local rs_Breeder = "top"
  7. local rs_Grinder = "right"
  8. local freq = 3
  9.  
  10. function toggleBreeder()
  11.   rs.setOutput(rs_Breeder, not rs.getOutput(rs_Breeder))
  12.   return rs.getOutput(rs_Breeder)
  13. end
  14.  
  15. function toggleChronotyper()
  16.   rs.setOutput(rs_Chronotyper, not rs.getOutput(rs_Chronotyper))
  17.   return rs.getOutput(rs_Chronotyper)
  18. end
  19.  
  20. function toggleGrinder()
  21.   rs.setOutput(rs_Grinder, not rs.getOutput(rs_Grinder))
  22.   return rs.getOutput(rs_Grinder)
  23. end
  24.  
  25. function growFlock()
  26.   if rs.getOutput(rs_Breeder) == true then
  27.     toggleBreeder()
  28.   end
  29.   if rs.getOutput(rs_Chronotyper) == false then
  30.     toggleChronotyper()
  31.   end
  32.   if rs.getOutput(rs_Grinder) == false then
  33.     toggleGrinder()
  34.   end
  35. end
  36.  
  37. function harvest()
  38.   if rs.getOutput(rs_Grinder) == true then
  39.     toggleGrinder()
  40.   end
  41.   if rs.getOutput(rs_Chronotyper) == true then
  42.     toggleChronotyper()
  43.   end
  44.   if rs.getOutput(rs_Breeder) == true then
  45.     toggleBreeder()
  46.   end
  47. end
  48.  
  49. function stopAll()
  50.   if rs.getOutput(rs_Breeder) == false then
  51.     toggleBreeder()
  52.   end
  53.   if rs.getOutput(rs_Chronotyper) == false then
  54.     toggleChronotyper()
  55.   end
  56.   if rs.getOutput(rs_Grinder) == false then
  57.     toggleChronotyper()
  58.   end
  59. end
  60.  
  61. modem.setListening(freq, false)
  62. term.clear()
  63. term.setCursorPos(1,1)
  64.  
  65. print(modem.getListening(freq))
  66. modem.setListening(freq, true)
  67. print(modem.getListening(freq))
  68.  
  69. repeat  
  70.      
  71.   local eventType, side, id, chan, message = "null", "null", 0, 0, "null"
  72.   eventType, side, id, chan, message = os.pullEvent()
  73.    
  74.   if eventType == "lan_message" and chan == 3 then
  75.    
  76.     print(eventType.." "..chan.." "..message)
  77.    
  78.     if message == "grow" then
  79.       growFlock()
  80.       print("Grown")
  81.     elseif message == "stop" then
  82.       stopAll()
  83.       print("not growing")
  84.     elseif message == "kill" then
  85.       harvest()
  86.       print("Harvesting")
  87.     else
  88.       print("Invalid Message")
  89.     end
  90.   end
  91. until false
  92.  
  93.  
  94. --while true do
  95. --  term.clear()
  96. --  term.setCursorPos(1,1)
  97. --  write("1 - Breeder, 2 - Rancher:  ")
  98. --  local input = read()
  99.    
  100. --  if input == "1" then
  101. --    local output = toggleBreeder()
  102. --    print(output)
  103. --    sleep(2)  
  104. --  elseif input == "2" then
  105. --    local output = toggleRancher()
  106. --    print(output)
  107. --  else
  108.  --   print("failed")
  109. --    sleep(2)  
  110. --  end
  111. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement