Guest User

startup

a guest
Aug 19th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. rednet.open("top")
  2. os.loadAPI("button")
  3. alarmReset = true
  4.  
  5. button.setTable("Stop", alarmToggle, 1, 10, 10, 12)
  6. button.screen()
  7. button.heading("Reactor 1")
  8.  
  9. while true do
  10. --[[
  11.   0 = reactor.getActive
  12.   1 = reactor.getEnergyProductedLastTick
  13.   2 = reactor.getEnergyStored
  14.   3-6 = reactor.getControlRodLevel
  15.   7 = reactor.getFuleAmount
  16. ]]--
  17.    
  18.   --variables
  19.   local id, msg = rednet.receive()
  20.   local data = textutils.unserialize(msg)
  21.   local mon = peripheral.wrap("monitor_0")
  22.  
  23.   --getClick
  24.   function getClick()
  25.     event, side, x, y = os.pullEvent("monitor_touch")
  26.     button.checkxy(x, y)
  27.   end
  28.  
  29.   --alarm function
  30.   function alarmToggle(value)
  31.     local alarm = false
  32.    
  33.     --If alarmToggle is set to on
  34.     if value == 1 then
  35.       alarm = on
  36.     else
  37.       --button.flash("Stop Alarm")
  38.     end
  39.    
  40.     --Turn on or off alarm
  41.     if alarm == true and alarmReset == true then
  42.       redstone.setOutput("left", true)
  43.       alarmReset = false
  44.     else
  45.       redstone.setOutput("left", false)
  46.     end
  47.   end
  48.  
  49.  
  50.  
  51.   --Monitor prep
  52.   mon.clear()
  53.   mon.setTextScale(1)
  54.  
  55.   --Is reactor on    
  56.   mon.setCursorPos(1,1)
  57.   mon.setTextColor(colors.white)
  58.   mon.write("Active: ")
  59.   mon.setTextColor(colors.lime)
  60.   if data[0] == true then mon.write("Yes") else mon.setTextColor(colors.red) mon.write("No") end
  61.  
  62.   --RF Produced
  63.   mon.setCursorPos(1,2)
  64.   mon.setTextColor(colors.white)
  65.   mon.write("RF/T: ")  
  66.   mon.setTextColor(colors.lime)
  67.   mon.write(data[1] .. "")
  68.  
  69.   --RF Stored in reactor
  70.   mon.setCursorPos(1,3)
  71.   mon.setTextColor(colors.white)
  72.   mon.write("RF Stored: ")
  73.   mon.setTextColor(colors.lime)
  74.   if data[2] < 2500000 then mon.setTextColor(colors.red) end
  75.   if data[2] < 1000000 then alarmToggle(1) else alarmReset = true end
  76.   mon.write(data[2] .. "")
  77.  
  78.   --Fule Rods
  79.   mon.setCursorPos(1,4)
  80.   mon.setTextColor(colors.white)
  81.   mon.write("Rod 1 Level: ")
  82.   mon.setTextColor(colors.lime)
  83.   mon.write(data[3] .. "%")
  84.  
  85.   mon.setCursorPos(1,5)
  86.   mon.setTextColor(colors.white)
  87.   mon.write("Rod 2 Level: ")
  88.   mon.setTextColor(colors.lime)
  89.   mon.write(data[4] .. "%")
  90.  
  91.   mon.setCursorPos(1,6)
  92.   mon.setTextColor(colors.white)
  93.   mon.write("Rod 3 Level: ")
  94.   mon.setTextColor(colors.lime)
  95.   mon.write(data[5] .. "%")
  96.  
  97.   mon.setCursorPos(1,7)
  98.   mon.setTextColor(colors.white)
  99.   mon.write("Rod 4 Level: ")
  100.   mon.setTextColor(colors.lime)
  101.   mon.write(data[6] .. "%")
  102.  
  103.   --Reactor Fule
  104.   mon.setCursorPos(1,8)
  105.   mon.setTextColor(colors.white)
  106.   mon.write("Reacor Fuel: ")
  107.   mon.setTextColor(colors.lime)
  108.   if data[7] < 110000 then mon.setTextColor(colors.red) alarmToggle(1) else alarmReset=true end
  109.   mon.write(data[7])
  110.  
  111.  getClick()
  112.  
  113. end
Advertisement
Add Comment
Please, Sign In to add comment