kd8lvt

Reactor PDA

Sep 7th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. --This is in fact my code. Liscenced under Mozilla 2
  2. shell.run("clear")
  3. rednet.open("back")
  4. gid = nil
  5.  
  6. function cid()
  7.   output = false
  8.   while true do
  9.     print("test")
  10.     id,msg = rednet.receive()
  11.     if id == gid then
  12.       output = msg
  13.     end
  14.   end
  15.   return output
  16. end
  17.  
  18. function main()
  19.   while true do
  20.     energy = cid()
  21.     fuel = cid()
  22.     state = cid()
  23.     shell.run("clear")
  24.     print("Reactor...")
  25.     if energy < 5000000 and energy > 2500000 then
  26.       term.setTextColor(colors.yellow)
  27.     elseif energy < 2500000 then
  28.       term.setTextColor(colors.red)
  29.     elseif energy > 5000000 then
  30.       term.setTextColor(colors.green)
  31.     end
  32.     print("Energy: "..energy)
  33.     if fuel < 40000 and fuel > 25000 then
  34.       term.setTextColor(colors.yelow)
  35.     elseif fuel < 25000 then
  36.       term.setTextColor(colors.red)
  37.     elseif fuel > 40000 then
  38.       term.setTextColor(colors.green)
  39.     end
  40.     print("Fuel: "..fuel)
  41.     if state == true then
  42.       term.setTextColor(colors.green)
  43.       print("On/Off: ON")
  44.     elseif state == false then
  45.       term.setTextColor(colors.red)
  46.       print("On/Off: OFF")
  47.     end
  48.     term.setTextColor(colors.white)
  49.   end
  50. end
  51.  
  52. while true do
  53.   id,msg = nil
  54.   id,msg = rednet.receive(2)
  55.   if msg == "pair" then
  56.     rednet.send(id,io.read())
  57.     id,msg = rednet.receive(id)
  58.     if msg == "paired" then
  59.       gid = id
  60.       print("paired")
  61.       main()
  62.     end
  63.   end
  64. end
  65. print("paired")
Advertisement
Add Comment
Please, Sign In to add comment