Advertisement
Guest User

main

a guest
Jun 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. -- Main computer program
  2. -- Use 6x3 monitor. 61x19 text.
  3.  
  4. local mon = peripheral.wrap("monitor_2")
  5. mon.setTextColor(colors.white)
  6. mon.setBackgroundColor(colors.blue)
  7.  
  8. local batt = {}
  9. for i = 10,19 do
  10.   table.insert(batt, peripheral.wrap("tile_thermalexpansion_cell_basic_name_"..tostring(i)))
  11. end
  12.  
  13. local maxnrg = 800000000
  14. local savnrg = 80000000
  15.  
  16. local surv = {}
  17. for i = 1,6 do
  18.   table.insert(surv, peripheral.wrap("generatorfurnace_"..tostring(i)))
  19. end
  20.  
  21. -- Main
  22. while true do
  23.  
  24.   local tnrg = 0
  25.   local nrg = {}
  26.   for i = 1,10 do
  27.     local a = batt[i].getEnergyStored()
  28.     table.insert(nrg, tostring(a))
  29.     tnrg = tnrg + a
  30.   end
  31.   mon.clear()
  32.   for i = 1,9,2 do
  33.     mon.setCursorPos(10,(i+1)/2+3)
  34.     mon.write(nrg[i])
  35.   end
  36.   for i = 2,10,2 do
  37.     mon.setCursorPos(20,i/2+3)
  38.     mon.write(nrg[i])
  39.   end
  40.   mon.setCursorPos(10,10)
  41.   mon.write(tostring(tnrg))
  42.   mon.setCursorPos(20,10)
  43.   mon.write(tostring(maxnrg))
  44.   mon.setCursorPos(30,10)
  45.   local a = math.ceil(tnrg/maxnrg * 100)
  46.   mon.write(tostring(a).."%")
  47.  
  48.   local sum = 0
  49.   for i = 1,6 do
  50.     local a = surv[i].getStackInSlot(1)
  51.     if a ~= nil then
  52.       sum = sum + a.qty
  53.     end
  54.   end
  55.   mon.setCursorPos(10,12)
  56.   mon.write("Fuel : "..tostring(sum))
  57.   mon.setCursorPos(10,13)
  58.   local total = sum * 1600000
  59.   mon.write(tostring(total))
  60.  
  61.   if total + tnrg + savnrg < maxnrg then
  62.     redstone.setBundledOutput("bottom",colors.red)
  63.   else
  64.     redstone.setBundledOutput("bottom",0)
  65.   end
  66.  
  67.   sleep(1)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement