Advertisement
Guest User

test1.lua

a guest
Sep 16th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1. --Big Reactors Control Program for Opencomputers
  2. --By Tacnuke2011
  3.  
  4. --requires
  5.  
  6. local component = require("component")
  7. local term = require("term")
  8. local event = require("event")
  9. local serialization = require("serialization")
  10. local colors = require("colors")
  11. local keyboard = require("keyboard")
  12. --vars
  13.  
  14. local br = component.br_reactor
  15. local gpu = component.gpu
  16. local enMax = 9500000
  17. local enMin = 2000000
  18. local temEn = br.getEnergyStored()
  19. local w, h = gpu.getResolution()
  20.  
  21. --energy check
  22.  
  23. local function power()
  24.     local temEn = br.getEnergyStored()
  25.     if temEn <= enMin then br.setActive(true)
  26.       elseif temEn >= enMax then br.setActive(false)    
  27.     end
  28.  
  29.   info()
  30.  
  31. end
  32.  
  33. --display settings and output
  34.  
  35. local function display()  
  36.  
  37.  
  38.   gpu.setResolution(90, 40)
  39.   gpu.setForeground(0x0040ff)
  40.   gpu.setBackground(0x000000)
  41.  
  42.  
  43.   power()  
  44.  
  45. end
  46.  
  47.  function info()
  48.  
  49.  
  50.   if br.getActive() then
  51.       term.setCursor(54, 10)
  52.       gpu.setForeground(0x000000)
  53.       gpu.setBackground(0x00a500)
  54.       gpu.fill(54, 10, 6, 1, " ")
  55.       term.write("Online")
  56.       term.setCursor(44, 10)
  57.       gpu.setForeground(0x000000)
  58.       gpu.setBackground(0xff0000)
  59.       gpu.fill(44, 10, 7, 1, " ")
  60.       term.write("Offline")
  61.  
  62.     elseif not br.getActive() then
  63.       term.setCursor(54, 10)
  64.       gpu.setForeground(0x0040ff)
  65.       gpu.setBackground(0xff0000)
  66.       gpu.fill(54, 10, 6, 1, " ")
  67.       term.write("Online")
  68.       term.setCursor(44, 10)
  69.       gpu.setForeground(0x0040ff)
  70.       gpu.setBackground(0x00a500)
  71.       gpu.fill(44, 10, 7, 1, " ")
  72.       term.write("Offline")
  73.        
  74.   end
  75.  
  76.   local enStor =  math.floor(br.getEnergyStored()/10^5)
  77.   gpu.setForeground(0x0040ff)
  78.   gpu.setBackground(0x000000)
  79.   term.setCursor(29, 10)
  80.   term.write("Reactor Status:")
  81.   term.setCursor(32, 12)
  82.   term.write("Fuel Amount: "..br.getFuelAmount().." mB")
  83.   term.setCursor(31, 13)
  84.   term.write("Waste Amount: "..br.getWasteAmount().. " mB")
  85.   term.setCursor(34, 14)
  86.   term.clearLine()
  87.   term.setCursor(34, 14)
  88.   term.write("RF Stored: "..enStor.."%")
  89.   term.setCursor(30, 15)
  90.   term.clearLine()
  91.   term.setCursor(30, 15)
  92.   term.write("RF Production: " ..math.floor(br.getEnergyProducedLastTick()).. " RF/t")
  93.   term.setCursor(31, 16)
  94.   term.clearLine()
  95.   term.setCursor(31, 16)
  96.   term.write("Casing Temp.: "..math.floor(br.getCasingTemperature()).." C")
  97.   term.setCursor(33, 17)
  98.   term.clearLine()
  99.   term.setCursor(33, 17)
  100.   term.write("Fuel Temp.: "..math.floor(br.getFuelTemperature()).." C")
  101.   term.setCursor(28, 18)
  102.   term.clearLine()
  103.   term.setCursor(28, 18)
  104.   term.write("Fuel Reactivity: "..math.floor(br.getFuelReactivity()).." %")
  105.   term.setCursor(36, 20)
  106.   gpu.setBackground(0x00a500)
  107.   gpu.fill(35, 20, 6, 1, " ")
  108.   term.write("Exit")
  109.   display()
  110.    
  111. end
  112.  
  113. --event listener
  114. -- x keypress
  115.  
  116. function listen(name, address, x, y, button, player)
  117. local run = true
  118.   if x >= 36 and x <= 39 and y == 20 then
  119.     run = false
  120.   end
  121. end
  122.  
  123. --main loop
  124.  
  125. while run do
  126. local name, address, x, y, button, player = event.pull("touch")
  127.  
  128. if x >= 36 and x <= 40 and y == 20 then
  129.    print("ding")
  130.   os.sleep(.5)
  131.   break
  132.  else
  133.   os.sleep(.5)
  134.   term.clear()
  135.   info()
  136. end
  137. end
  138.  
  139. event.ignore("touch", listen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement