Advertisement
Guest User

reactor

a guest
Dec 9th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. args = {...}
  2. modem = peripheral.wrap("back")
  3. modem.open(235)
  4.  
  5. if #args > 0 and args[1] == "status" then
  6.   while true do
  7.     _,_,_,_,mesg,_ = os.pullEvent("modem_message")
  8.     data = {}
  9.     for i in string.gmatch(mesg,"([^,%s]+)") do
  10.       data[#data+1] = i
  11.     end
  12.     power = tonumber(data[2])
  13.     energy = tonumber(data[3])
  14.     f_rate = tonumber(data[4])
  15.     fuel = tonumber(data[5])
  16.     rod_level = tonumber(data[6])
  17.     term.clear()
  18.     term.setCursorPos(1,1)
  19.     term.write("Reactor: ")
  20.     if data[1] == "true" then
  21.       term.setTextColor(colors.green)
  22.       term.write("Active")
  23.     else
  24.       term.setTextColor(colors.red)
  25.       term.write("Inactive")
  26.     end
  27.     term.setTextColor(colors.white)
  28.     term.setCursorPos(1,2)
  29.     term.write("Energy: ")
  30.     if energy < 10 then
  31.       term.setTextColor(colors.red)
  32.     elseif energy < 50 then
  33.       term.setTextColor(colors.orange)
  34.     elseif energy < 70 then
  35.       term.setTextColor(colors.yellow)
  36.     else
  37.       term.setTextColor(colors.green)
  38.     end
  39.     term.write(tostring(energy).."%")
  40.     term.setTextColor(colors.white)
  41.     term.setCursorPos(1,3)
  42.     term.write("Power: " .. tostring(power) .."K RF/t")
  43.    
  44.    
  45.    
  46.   end
  47. else
  48.   command = ""
  49.   for _,arg in pairs(args) do
  50.     command = command.." "..arg
  51.   end
  52.   --print(command)
  53.   modem.transmit(233,235,command)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement