Guest User

holo-info.lua

a guest
Jan 2nd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local holo = component.hologram
  4. local energyCell = component.tile_thermalexpansion_cell_resonant_name
  5. local h = 0
  6.  
  7. holo.clear()
  8. holo.setScale(0.33)
  9. holo.setPaletteColor(1,0x00ff00)
  10. holo.setPaletteColor(2,0xffff00)
  11. holo.setPaletteColor(3,0xff0000)
  12.  
  13. local barSize = 16
  14.  
  15. function anzeigeBalken(t, w, ti, wi, h)
  16.   local absHoehe = h * 32
  17.   local color = 1
  18.   if h < 0.2 then
  19.     color = 3
  20.   elseif h < 0.75 then
  21.     color = 2
  22.   end
  23.   for i = t, t + ti do
  24.     for j = w, w + wi do
  25.       holo.fill(i, j, 0, absHoehe, color)
  26.     end
  27.   end
  28. end
  29.  
  30. while true do
  31.   local energy = energyCell.getEnergyStored()
  32.   local maxEnergy = energyCell.getMaxEnergyStored()
  33.   h = energy / maxEnergy
  34.   print(h.." = "..energy.." / "..maxEnergy)
  35.   anzeigeBalken(0, 0, barSize, 1 ,1)
  36.   anzeigeBalken(0, 1, barSize, barSize - 1, h)
  37.   os.sleep(2)
  38. end
Advertisement
Add Comment
Please, Sign In to add comment