libraryaddict

Untitled

Apr 27th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. --Master
  2. rednet.open("right")
  3. times = 0
  4. function Pos()
  5.   fsp = io.open("Position", "w")
  6.   fsp:write("Position = "..[["]]..Position..[["]])
  7.   fsp:close()
  8. end
  9. if fs.exists("Position") then
  10.   dofile("Position")
  11. else
  12.   write("How many computers am I looking after? ")
  13.   Position = tonumber(read())
  14. end
  15. sleep(1)
  16. rednet.broadcast("Changeover")
  17. print("Changeover!")
  18. Hos = 0
  19. repeat
  20.   local ID, Msg = rednet.receive()
  21.   if Msg == "Changedover!" then
  22.     Hos = Hos+1
  23.     print("Changeover callbacks = "..Hos)
  24.   end
  25. until Hos == Position
  26. print("Changedover!")
  27. while true do
  28.   if turtle.forward() then
  29.     if times < 50 then
  30.       rednet.broadcast("Heave!")
  31.       times = times+1
  32.       Hos = 0
  33.       repeat
  34.         local ID, Msg = rednet.receive()
  35.         if Msg == "Ho!" then
  36.           Hos = Hos+1
  37.         end
  38.       until Hos == Position
  39.     else
  40.       rednet.broadcast("Changeover")
  41.       times = 0
  42.       Hos = 0
  43.       repeat
  44.         local ID, Msg = rednet.receive()
  45.         if Msg == "Changedover!" then
  46.           Hos = Hos+1
  47.         end
  48.       until Hos == Position
  49.       sleep(0.2)
  50.       rednet.broadcast("Heave!")
  51.             Hos = 0
  52.       repeat
  53.         local ID, Msg = rednet.receive()
  54.         if Msg == "Ho!" then
  55.           Hos = Hos+1
  56.         end
  57.       until Hos == Position
  58.     end
  59.   end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment