Guest User

startup

a guest
Jun 2nd, 2013
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. rednet.open("left")
  2. monitor = peripheral.wrap("right")
  3. monitor.clear()
  4. monitor.write("Test")
  5.  
  6. function sendData()
  7.   while true do
  8.     shell.run("clear")
  9.     print("You can turn on and off AE grid here:")
  10.     tosendData = read()
  11.  
  12.   if tosendData == "off" or tosendData == "OFF" then
  13.     print("Cutting off AE power grid...")
  14.     rednet.send(1,"off")
  15.     print("Looking for response...")
  16.     id,message = rednet.receive(1)
  17.     if message == "ack" then
  18.       print("Power system has been cut off!")
  19.       sleep(2)
  20.     end
  21.    
  22.   elseif tosendData == "on" or tosendData == "ON" then
  23.     print("Turning on AE power grid...")
  24.     rednet.send(1,"on")
  25.     id,message = rednet.receive(1)
  26.     if message == "ack" then
  27.       print("Power system has been turned on!")
  28.       sleep(2)
  29.     else
  30.       print("Retrying one more time...")
  31.       rednet.send(1,"on")
  32.       id,message = rednet.receive()
  33.       if message == "ack" then
  34.         print("Power system has been turned on!")
  35.         sleep(2)
  36.       else
  37.         print("Message failed. Please try again.")
  38.         sleep(2)
  39.       end
  40.     end
  41.   else
  42.     print("That's not a possible option.")
  43.     sleep(2)
  44. end
  45. sleep(.1)
  46.     end
  47. end
  48.  
  49. function getAEPower()
  50.  while true do
  51.     who,message = rednet.receive()
  52.   if message == "on" then
  53.     monitor.clear()
  54.     monitor.write("AE Power: ON")
  55.   elseif message == "off" then
  56.     monitor.clear()
  57.     monitor.write("AE Power: OFF")
  58.   end
  59.   sleep(.1)
  60.  end
  61. end
  62.  
  63. shell.run("clear")
  64. print("Starting up Client...")
  65. parallel.waitForAll(sendData, getAEPower)
Advertisement
Add Comment
Please, Sign In to add comment