MinoCraft72

Info Screen

Dec 17th, 2014
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.03 KB | None | 0 0
  1. --Config:
  2.  dataType = "energy" -- energy or liquid
  3.  Side = "right" -- side
  4.  Dir = "up" -- direction, use only if type is liquid
  5.  nameBat = "Storage Room Bank"
  6.  activRs = true
  7.  chargeRunEngine = 90
  8.  rsSide = "bottom"
  9.  minA = 4
  10.  fullColor = colors.red
  11.  emptyColor = colors.lightGray
  12.  percentColor = colors.black
  13.  runColor = colors.white
  14.  backColor = colors.black
  15.  margeW = 1
  16.  monActiv = true
  17.  monSide = "monitor_1"
  18.  
  19. --Prog:
  20.  
  21. function liquidScreen()
  22.   if dataType == "liquid" then
  23.    tank = peripheral.wrap(Side)
  24.    data = tank.getTankInfo(Dir)
  25.       for a,b in pairs(data) do
  26.        info = data[1]
  27.       end
  28.       for k, v in pairs(info) do
  29.        tankCap = info.capacity
  30.        tankData = info.contents
  31.         if tankData ~= nil then
  32.           for a,b in pairs(tankData) do
  33.            tankName = tankData.rawName
  34.            tankAmount = tankData.amount
  35.           end
  36.         else
  37.          tankAmount = 0
  38.         end
  39.       end
  40.       xPos = minA
  41.       yPos = margeW
  42.       term.setCursorPos(xPos+1,yPos)
  43.       term.setTextColor(colors.white)
  44.       print(tankName)
  45.       term.setCursorPos(xPos+1,yPos+1)
  46.       print(tankAmount .."/".. tankCap.." mB")
  47.       pct = math.floor((tankAmount/tankCap)*100)
  48.   end
  49. end
  50.  
  51. function screen()
  52.  longueur = minA+20
  53.  --yPos = margeW
  54.  charge = minA + math.floor(pct/5)
  55.  term.clearLine(1,yPos+3)
  56.  strg = pct.."%"
  57.   for x = charge,longueur do
  58.    paintutils.drawPixel(x+1,yPos+3,emptyColor)
  59.     if charge <= string.len(strg) then
  60.      term.setCursorPos(charge,yPos+3)
  61.      term.setTextColor(percentColor)
  62.      print(strg)
  63.      term.setCursorPos(runColor)
  64.     end
  65.   end
  66.     if pct < chargeRunEngine then
  67.      runColor = colors.orange
  68.       if activRs then
  69.        rs.setOutput(rsSide, true)
  70.       end
  71.     elseif pct == 100 then
  72.      runColor = colors.lime
  73.       if activRs then
  74.        rs.setOutput(rsSide, false)
  75.       end
  76.     end
  77.  minB = minA+charge
  78.   for x = minA,charge+1 do
  79.    paintutils.drawPixel(x,yPos+3,fullColor)
  80.     if charge > string.len(strg) then
  81.      term.setCursorPos(charge-string.len(strg)+2,yPos+3)
  82.      term.setTextColor(percentColor)
  83.      print(strg)
  84.      term.setTextColor(runColor)
  85.     end      
  86.   end
  87. end
  88.  
  89. function energyScreen()
  90.   if dataType == "energy" then
  91.    bat = peripheral.wrap(Side)
  92.    batName = nameBat
  93.    batEnergyStored = bat.getEnergyStored()
  94.    batMaxEnergyStored = bat.getMaxEnergyStored()
  95.    xPos = minA
  96.    yPos = margeW
  97.    pct = math.floor((batEnergyStored/batMaxEnergyStored)*100)
  98.    term.setCursorPos(xPos+1,yPos)
  99.    term.clearLine()
  100.    term.setTextColor(runColor)
  101.    print(batName)
  102.    term.setTextColor(colors.white)
  103.    term.setCursorPos(xPos+1,yPos+1)
  104.    term.clearLine()
  105.    print(batEnergyStored.."/"..batMaxEnergyStored.." RF")
  106.   end  
  107. end
  108.  
  109.  term.clear()
  110.  if monActiv then
  111.   mon = peripheral.wrap(monSide)
  112.   term.redirect(mon)
  113.  end  
  114.  term.setBackgroundColor(backColor)
  115.  term.clear()
  116.  sleep(1)
  117.  while true do
  118.   sleep(0)
  119.   term.setBackgroundColor(backColor)
  120.   energyScreen()
  121.   liquidScreen()
  122.   screen()
  123.  end
Advertisement
Add Comment
Please, Sign In to add comment