SHARE
TWEET

reactorClient

a guest Jan 6th, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --variables
  2. running = true
  3. id = 11
  4.  
  5.  
  6. --Functions
  7.  
  8. function reset()
  9.  term.clear()
  10.  term.setCursorPos(1,1)
  11. end
  12.  
  13. function gui()
  14.  reset()
  15.  print("Power ON/OFF")
  16.  term.setCursorPos(1,3)
  17.  print("Eject Waste")
  18.  term.setCursorPos(1,5)
  19.  print("Reactor Information")
  20.  term.setCursorPos(1,7)
  21.  print("Test Connection")
  22.  term.setCursorPos(1,9)
  23.  print("Exit Program")
  24. end
  25. function testConnection()
  26.  testID = 8
  27.  rednet.send(8, "ping")
  28.  testCon = {os.pullEvent("rednet_message")}
  29.   if testCon[1] == testID and testCon[3] == "pong" then
  30.    print("Connection Good!")
  31.    sleep(5)
  32.    shell.run("reactorClient")
  33.   end
  34. end
  35. function reactorInfo()
  36.  reset()
  37.  message = { os.pullEvent("rednet_message") }
  38.  isActive = message[3][1]
  39.  fuel = message[3][2]
  40.  fuelMax = message[3][3]
  41.  energyStored = message[3][4]
  42.  RFS = message[3][5]
  43.  reactivity = message[3][6]
  44.  waste = message[3][7]
  45.  caseTemp = message[3][8]
  46.  fuelTemp = message[3][9]
  47.  if isActive == "true" then
  48.   print("Reactor On")
  49.  elseif message[3][1] =="false" then
  50.   print("Reactor Off")
  51.  end
  52.  print("Fuel: "..fuel.."/"..fuelMax)
  53.  print("Energy: "..energyStored.." RF")
  54.  print("RF/s: "..RFS)
  55.  print("Reactivity"..reactivity.."%")
  56.  print("waste: "..waste.." mB")
  57.  print("Casing Temp: "..caseTemp)
  58.  print("Fuel Temp: "..fuelTemp)
  59. end
  60. function receive()
  61.  msg = { os.pullEvent("rednet_message") }
  62.  event = msg[1]
  63.  SID = msg[2]
  64.  sent = msg[3]
  65.  reset()
  66.  print(sent)
  67.  sleep(5)
  68.  shell.run("reactorClient")
  69. end
  70. function debug()
  71.  term.setCursorPos(1,11)
  72.  for k,v in pairs(click) do
  73.   print(v)
  74.  end
  75. end
  76. --Main Program
  77. rednet.open("back")
  78. gui()
  79.  
  80. click = { os.pullEvent("mouse_click") }
  81. button = click[1]
  82. xPos = click[2]
  83. yPos = click[3]
  84.  
  85. if xPos >= 1 and xPos <= 13 and yPos == 1 then
  86.  rednet.send(id, "power")
  87.  receive()
  88. elseif button == 1 and xPos >= 1 and xPos <= 13 and yPos == 3 then
  89.  rednet.send(id, "waste")
  90.  receive()
  91. elseif button == 1 and xPos >= 1 and xPos <= 18 and yPos == 5 then
  92.  rednet.send(id, "reactorInfo")
  93.  reactorInfo()
  94. elseif button == 1 and xPos >= 1 and xPos <= 13 and yPos == 7 then
  95.  reset()
  96.  textutils.slowPrint("Testing Connection...")
  97.  testConnection()
  98. elseif button == 1 and xPos >= 1 and xPos <= 13 and yPos == 9 then
  99.  print("Exiting Program")
  100.  running = false
  101.  shell.reboot()
  102. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top