Advertisement
N1nt3nd0

CC_DraconicStorage

Nov 19th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. local screen = peripheral.wrap('monitor_7')
  2. local storage = peripheral.wrap('top')
  3. local maxStore = storage.getMaxEnergyStored()
  4. local storeOld = 0
  5.  
  6. local paints = { title = colors.orange,
  7.                  percent = colors.yellow,
  8.                  background = colors.cyan,
  9.                  rft = colors.yellow }
  10.  
  11. function setText(txt,x,y,color)
  12.     screen.setCursorPos(x,y)
  13.     screen.clearLine()
  14.     screen.setTextColor(color)
  15.     screen.write(txt)
  16. end
  17.  
  18. function check()
  19.     local store = storage.getEnergyStored()
  20.     local percent = math.floor((store*100)/maxStore)
  21.     local effective = math.floor((store - storeOld)/20)
  22.     storeOld = store
  23.     if effective > 0 then
  24.         effColor, effEquals = colors.lime, '+'
  25.     else
  26.         effColor, effEquals = colors.red, ''
  27.     end
  28.     setText('--'..tostring(percent)..'%--',3,3,paints.percent)
  29.     setText(effEquals..tostring(effective),1,5,effColor)
  30.     screen.setTextColor(paints.rft)
  31.     screen.write('Rf/t')
  32. end
  33.  
  34. screen.setBackgroundColor(paints.background)
  35. screen.setTextScale(2.5)
  36. screen.clear()
  37. setText('DracStore',2,1,paints.title)
  38.  
  39. while true do
  40.     pcall(check)
  41.     os.sleep(1)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement