Clem105

MFE

Oct 26th, 2013
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. function Split(str,pat)
  2.         local t = {}
  3.         local fpat = "(.-)" .. pat
  4.     local last_end = 1
  5.     local s, e, cap = str:find(fpat, 1)
  6.     while s do
  7.         if s ~= 1 or cap ~= "" then
  8.             table.insert(t,cap)
  9.         end
  10.         last_end = e+1
  11.         s, e, cap = str:find(fpat, last_end)
  12.     end
  13.     if last_end <= #str then
  14.         cap = str:sub(last_end)
  15.         table.insert(t, cap)
  16.     end
  17.     return t
  18. end
  19. local MFE = peripheral.wrap("back")
  20. local Titre = "Petite MFE"
  21. local x,y = term.getSize()
  22.  
  23.     term.clear()
  24.     for x = 6,47 do
  25.         paintutils.drawPixel(x,9,colors.white)
  26.         paintutils.drawPixel(x,14,colors.white)
  27.     end
  28.     for y = 9,14 do
  29.         paintutils.drawPixel(6,y,colors.white)
  30.         paintutils.drawPixel(47,y,colors.white)
  31.     end
  32.     local Capacity = MFE.getEUCapacity()
  33.     local Energy = MFE.getEUStored()
  34.     local pourcent = ((Energy*100)/Capacity)
  35.     local Resultat = (pourcent/(2.5))
  36.     local String = tostring(Resultat)
  37.     local StringBis = tostring(pourcent)
  38.     local t = Split(StringBis,",")
  39.     local p = Split(String,",")
  40.     local limite = tonumber(p[1])
  41.     for i = 0,limite do
  42.         if limite > 0 then
  43.             i = i+7
  44.         end
  45.         paintutils.drawPixel(i,10,colors.red)
  46.         paintutils.drawPixel(i,11,colors.red)
  47.         paintutils.drawPixel(i,12,colors.red)
  48.         paintutils.drawPixel(i,13,colors.red)
  49.     end
  50.     term.setCursorPos((x-((x/2)+#Titre)),7)
  51.     print(Titre)
  52.     term.setCursorPos((x-((x/2)+#t[1])),16)
  53.     print(t[1].." %")
  54.     sleep(5)
  55.     os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment