Advertisement
Guest User

startup

a guest
Feb 13th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. glass = peripheral.wrap("back")
  2. battery = peripheral.wrap("tile_thermalexpansion_cell_resonant_name_0")
  3. reactor = peripheral.wrap("BigReactors-Reactor_0")
  4. modem = peripheral.wrap("top")
  5.  
  6. lbTime = 0
  7.  
  8. function round(what, precision)
  9.   return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
  10.   end
  11.  
  12. function addBox()
  13.   glass.addBox(1,1,80,10,0xCCCCCC,0.2)
  14.  
  15. end
  16.  
  17. function batDis()
  18.   batLvl = battery.getEnergyStored()
  19.   batMax = battery.getMaxEnergyStored()
  20.   batRatio = batLvl / batMax
  21.   endX = math.floor(78 * batRatio)
  22.  
  23.   glass.addText(3,15,"Resonant Cell")
  24.   glass.addBox(3,25,75,5,0x00FF00)
  25.  
  26.   glass.addText(3,32,round(batLvl/1000000,1) .. "MRF/" .. batMax/1000000 .. "MRF")
  27.  
  28.  
  29.   glass.addBox(endX,25,(78-endX),5,0xFF0000)
  30.   end
  31.  
  32. function reactorDis()
  33.   isOn = reactor.getActive()
  34.   rfStored = reactor.getEnergyStored()
  35.   rfPerTick = reactor.getEnergyProducedLastTick()
  36.  
  37.   glass.addText(3,42,"Reactor")
  38.   if isOn == true then
  39.     glass.addText(3,51,"Active",0x00FF00)
  40.     end
  41.   if isOn == false then
  42.     glass.addText(3,51,"Inactive",0xFF0000)
  43.     end
  44.   glass.addText(3,60,"Internal Buffer")
  45.   glass.addBox(3,70,75,5,0x00FF00)
  46.   endX = math.floor(78 * (rfStored / 10000000))
  47.   glass.addBox(endX,70,(78-endX),5,0xFF0000)
  48.  
  49.   glass.addText(3,77,round(rfStored/1000000, 1) .. "MRF/10MRF")
  50.   glass.addText(3,86,math.floor(rfPerTick) .. "RF/t")
  51.   end
  52.  
  53.  
  54. function timeDis()
  55.   time = textutils.formatTime(os.time(), false)
  56.   glass.addText(5,2,"Time: " .. time, 0xEEEEEE)
  57.  
  58. end
  59.  
  60. function cobbleDis()
  61.   glass.addText(3,92,"Cobble Barrel",0xCCCCCC)
  62.   glass.addText(3,96,"qty: " .. qty .. "/4096")
  63.   if uccobble == true then
  64.     if lbTime<10 then
  65.       glass.addText(3,180,"UC: " .. qty*6561)
  66.       lbTime = lbTime + 1
  67.     else
  68.       uccobble = false
  69.       end
  70.     end
  71.   end
  72.  
  73. function start()
  74.   glass.clear()
  75.   while true do
  76.     glass.clear()
  77.     addBox()
  78.     timeDis()
  79.     batDis()
  80.     reactorDis()
  81.     cobbleDis()
  82.     glass.sync()
  83.     sleep(0.1)
  84.     end
  85.   end
  86.  
  87. function commands()
  88.   while true do
  89.     event,side,player,id,command=os.pullEvent("glasses_chat_command")
  90.     if command == "hello" then
  91.       redstone.setOutput("top", true)
  92.       end
  93.     if command == "bye" then
  94.       redstone.setOutput("top", false)
  95.       end
  96.     if command == "reset" then
  97.       print("Restarting...")
  98.       shell.run("restart")
  99.       print("Restarted.")
  100.       end
  101.     if command == "reactor enable" then
  102.       reactor.setActive(true)
  103.       end
  104.     if command == "reactor disable" then
  105.       reactor.setActive(false)
  106.       end
  107.     if command == "spooky" then
  108.      -- glass.addTriangle((3,150),(33,150),(18,120),0x00FF00)
  109.       eye = glass.addIcon(270,140,"minecraft:ender_eye")
  110.       end
  111.     if command == "uccobble" then
  112.       uccobble = true
  113.       end
  114.      
  115.     end
  116.   end  
  117.  
  118. function listener()
  119.   modem.open(1)
  120.   while true do
  121.   la,lb,lc,ld,qty,le = os.pullEvent("modem_message")
  122.     end
  123.   end
  124.    
  125. parallel.waitForAll(start, commands, listener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement