Nike622000

Me Barney

Jun 14th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.85 KB | None | 0 0
  1. local monSide = "back"
  2. local Bcolor = colors.blue
  3. local senSide = "top"
  4.  
  5. Item = {}
  6. Item[1] = "Glass"
  7. Item[2] = "UU-Matter"
  8. Item[3] = " "
  9. Item[4] = " "
  10. Item[5] = " "
  11. Item[6] = " "
  12. Item[7] = " "
  13. Item[8] = " "
  14. Item[9] = " "
  15. Item[10] = " "
  16. Item[11] = " "
  17. Item[12] = " "
  18. Item[13] = " "
  19. Item[14] = " "
  20. Item[15] = " "
  21. Item[16] = " "
  22. Item[17] = " "
  23. Item[18] = " "
  24. Item[19] = " "
  25. Item[20] = " "
  26. Item[21] = " "
  27. Item[22] = " "
  28. Item[23] = " "
  29.  
  30. os.loadAPI("ocs/apis/sensor")
  31. mon = peripheral.wrap(monSide)
  32. sen = sensor.wrap(senSide)
  33.  
  34. local xMax,yMax = mon.getSize()
  35.  
  36. --function
  37.  
  38. function bdraw(xp1,yp1,xp2,yp2,txt,col)
  39.  if col==nil then
  40.  mon.setBackgroundColor(colors.lime)
  41.  else
  42.  mon.setBackgroundColor(col)
  43.  end
  44.  mon.setCursorPos(xp1,yp1)
  45.  for i=1,(xp2-xp1) do
  46.   mon.write("-")
  47.  end
  48.  mon.setCursorPos(xp1,yp2)
  49.  for i=1,(xp2-xp1) do
  50.   mon.write("-")
  51.  end
  52.  for i=yp1,yp2 do
  53.   mon.setCursorPos(xp1,i)
  54.   mon.write("|")
  55.   mon.setCursorPos(xp2,i)
  56.   mon.write("|")
  57.  end
  58.  for i=(yp1+1),(yp2-1) do
  59.   mon.setCursorPos((xp1+1),i)
  60.   for j=(xp1+1),(xp2-1) do
  61.    mon.write(" ")
  62.    j = j+1
  63.   end
  64.   i = i+1
  65.  end
  66.  if math.floor(((xp2-xp1)-#txt)/2)==0 then
  67.   xp1 = xp1+1
  68.  end
  69.  mon.setCursorPos(math.floor(((xp2-xp1)-#txt)/2)+xp1,math.floor((yp2-yp1)/2)+yp1)
  70.  --print(math.floor(((xp2-xp1)-#txt)/2))
  71.  mon.write(txt)
  72. end
  73.  
  74. function Background()
  75. mon.setBackgroundColor(Bcolor)
  76.   for yPos=1,yMax do
  77.     for xPos=1,xMax do
  78.         mon.setCursorPos(xPos,yPos)
  79.       mon.write(" ")
  80.     end
  81.   end
  82. end
  83.  
  84. Background()
  85. mon.clear()
  86. Itemname = {}
  87. Itemmenge = {}
  88. while true do
  89. Posmon = 0
  90. mon.setCursorPos(xMax/2-14,1)
  91. mon.setBackgroundColor(colors.black)
  92. mon.write("ME-Uebersicht made by ")
  93. mon.setBackgroundColor(colors.black)
  94. mon.setTextColor(colors.cyan)
  95. mon.write("Nike622000")
  96. mon.setBackgroundColor(Bcolor)
  97.  
  98. mon.setTextColor(colors.white)
  99. bdraw(xMax-14,yMax-2,xMax,yMax,"Aktualisieren",colors.cyan)
  100. event,_,xPos,yPos = os.pullEvent()
  101. mon.setBackgroundColor(colors.white)
  102.  
  103. if event=="monitor_touch" then
  104.     if xPos>=xMax-14 and xPos<=xMax and yPos>=yMax-2 and yPos<=yMax then
  105. Background()
  106.         for yPos = 2,yMax do
  107.             mon.setBackgroundColor(Bcolor)
  108.             mon.setTextColor(colors.white)
  109.             mon.setCursorPos(xMax/2+5,yPos)
  110.             mon.write("|")
  111.            
  112.             end
  113.             ziele = sen.getTargets()
  114.             for k,v in pairs(ziele) do
  115.                     if v.Name == "ME Wireless Access Point"
  116.                     and v.Position.X==-3
  117.                     and v.Position.Y==-1
  118.                     and v.Position.Z==0
  119.                     then
  120.                     details = sen.getTargetDetails(k)
  121.                         if #Itemmenge <= 0 then
  122.                         print("1")
  123.                         d = false
  124.                         end
  125.                         for i = 1,#details.Items do
  126.                         for b = 1,23 do
  127.                             mon.setCursorPos(50,2+i)
  128.                             if details.Items[i].Name == Item[b] then
  129.                             Posmon = Posmon+1
  130.                             if d then
  131.                             for f = 1,23 do
  132.                             if Item[b] == Itemname[f] then
  133.                             mon.setCursorPos(50,2+Posmon)
  134.                             mon.write("                                                       ")
  135.                             mon.setCursorPos(50,2+Posmon)
  136.                             bilanz = details.Items[i].Size-Itemmenge[f]
  137.                             if bilanz > 0 then
  138.                             mon.setTextColor(colors.lime)
  139.                             end
  140.                             if bilanz < 0 then
  141.                             mon.setTextColor(colors.red)
  142.                             end
  143.                             if bilanz == 0 then
  144.                             mon.setTextColor(colors.yellow)
  145.                             end
  146.                             mon.write(bilanz)
  147.                             end
  148.                             end
  149.                             end
  150.                             mon.setTextColor(colors.white)
  151.                             mon.setCursorPos(2,2+Posmon)
  152.                             mon.write(details.Items[i].Name)
  153.                             mon.setCursorPos(27,2+Posmon)
  154.                             mon.write(details.Items[i].Size)
  155.                             Itemname[i] = details.Items[i].Name
  156.                             Itemmenge[i] = details.Items[i].Size
  157.                             d = true
  158.                             end
  159.                             end
  160.                             end
  161.                            
  162.                            
  163.                        
  164.                     end
  165.                     end
  166.         end
  167.     end
  168. end
Add Comment
Please, Sign In to add comment