Nike622000

Me Übersicht

Feb 12th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.67 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2.  
  3. local monSide   = "back"
  4. local Bcol      = colors.lightGray
  5. local Tcol      = colors.white
  6. local senSide   = "right"
  7. local Bcolstart = colors.lightGray
  8. local senX      = -2
  9. local senY      =  0
  10. local senZ      =  0
  11. --nur bei kleinen Me-Systemen verwenden!
  12. local showAll = true
  13.  
  14. mon = peripheral.wrap(monSide)
  15. sen = sensor.wrap(senSide)
  16.  
  17. local xMax,yMax = mon.getSize()
  18.  
  19. Items = {"Glass","UU-Matter","Cobblestone","Mycelium"}
  20. Item = {}
  21. for i = 1,#Items do
  22.   Item[i] = {"_","_",Items[i]}
  23. end
  24.  
  25. function Bg(xP1,yP1,xP2,yP2,col)
  26.   mon.setBackgroundColor(col)
  27.   for xPos = xP1,xP2 do
  28.     for yPos = yP1,yP2 do
  29.       mon.setCursorPos(xPos,yPos)
  30.       mon.write(" ")
  31.     end
  32.   end
  33. end
  34.  
  35. function monitorsp(text)
  36.  
  37. for x=1,string.len(text) do
  38. char = string.sub(text,x,x)
  39. mon.write(char)
  40. sleep(0.2) -- change this to change the print delay
  41. end
  42.  
  43. end
  44.  
  45. function JoJa(xP,yP)
  46.   mon.setCursorPos(xP,yP)
  47.   mon.setBackgroundColor(colors.gray)
  48.   mon.setTextColor(colors.cyan)
  49.   mon.write("Jo")
  50.   mon.setTextColor(colors.orange)
  51.   mon.write("Ja ")
  52.   mon.setTextColor(colors.lightGray)
  53.   mon.write("Productions")
  54.   mon.setBackgroundColor(colors.black)
  55.   mon.setTextColor(colors.white)
  56. end
  57.  
  58. function Bstart()
  59.   Bg(1,1,xMax,yMax,Bcolstart)
  60.   Bg(xMax/2-9,5,xMax/2+8,7,colors.gray)
  61.   JoJa(xMax/2-8,6)
  62.   mon.setCursorPos(xMax/2-7,10)
  63.   mon.setBackgroundColor(Bcolstart)
  64.   mon.setTextColor(colors.black)
  65.   monitorsp("praesentiert:")
  66.   mon.setTextColor(colors.white)
  67.   Bg(xMax/2-9,9,xMax/2+8,11,colors.cyan)
  68.   mon.setCursorPos(xMax/2-8,10)
  69.   mon.setBackgroundColor(colors.cyan)
  70.   mon.write("Me-System Reader")
  71.   Bg(8,yMax-11,xMax-9,yMax-8,colors.red)
  72.   mon.setCursorPos(9,yMax-10)
  73.   mon.write("Copyright by JoJa Productions")
  74.   mon.setCursorPos(9,yMax-9)
  75.   mon.write("Weitergabe ist nicht gestattet!")
  76.   event = os.pullEvent("monitor_touch")
  77. end
  78.  
  79. Bstart()
  80. Page = 1
  81. while true do
  82.  
  83.   mon.setBackgroundColor(colors.black)
  84.   mon.setTextColor(colors.white)
  85.   mon.clear()
  86.   Bg(1,1,xMax,yMax,Bcol)
  87.   ziele = sen.getTargets()
  88.  
  89.   for k,v in pairs(ziele) do
  90.     if v.Name == "ME Wireless Access Point"
  91.     and v.Position.X== senX
  92.     and v.Position.Y== senY
  93.     and v.Position.Z== senZ
  94.     then
  95.       mon.setTextColor(Tcol)
  96.       Bg(2,2,xMax-1,4,colors.gray)
  97.       mon.setBackgroundColor(colors.gray)    
  98.       details = sen.getTargetDetails(k)
  99.       mon.setCursorPos(2,2)
  100.       mon.write("Benutzte Itemarten: "..details.UsedTypes.." Arten")
  101.       mon.setCursorPos(2,3)
  102.       mon.write("Freie Itemarten: "..details.FreeTypes.." Arten")
  103.       mon.setCursorPos(2,4)
  104.       mon.write("Freier Speicherplatz: "..details.FreeCount*(-1).." Items")
  105.       if showAll then
  106.           mon.setBackgroundColor(colors.red)
  107.           mon.setCursorPos(xMax,8)
  108.           mon.write("^")
  109.           mon.setCursorPos(xMax,9)
  110.           mon.write("|")
  111.           mon.setCursorPos(xMax,yMax-2)
  112.           mon.write("V")
  113.           mon.setCursorPos(xMax,yMax-3)
  114.           mon.write("|")
  115.           mon.setBackgroundColor(colors.gray)    
  116.           if xPos >= xMax and xPos <= xMax and
  117.              yPos >=8 and yPos <= 9 then
  118.              Page = Page+1
  119.           end
  120.           if xPos >= xMax and xPos <= xMax and
  121.              yPos >= yMax-3 and yPos <= yMax-2 then
  122.              Page = Page-1
  123.           end
  124.          MaxPage = math.ceil(details.UsedTypes/19)
  125.          if Page < 1 then
  126.          Page = MaxPage
  127.          elseif Page > MaxPage then
  128.          Page =1
  129.          end
  130.  
  131.          Bg(2,6,xMax-1,yMax-2,colors.gray)
  132.          p = 1
  133.          if Page == 1 then
  134.             s1 = 1
  135.             s2 = 19
  136.         else
  137.             s1 = Page*19-19
  138.             s2 = Page*19
  139.         end
  140.         if s2 >= details.UsedTypes then
  141.          s2 = details.UsedTypes
  142.         end
  143.         print(s1)
  144.         print(s2)
  145.          for i = s1,s2 do
  146.             mon.setCursorPos(2,5+p)
  147.             mon.write(details.Items[i].Name)
  148.             mon.setCursorPos(30,5+p)
  149.             mon.write("Anzahl: "..details.Items[i].Size)
  150.             p = p+1
  151.          end
  152.       else
  153.         Bg(2,7,30,6+#Item,colors.gray)
  154.         Bg(40,7,40+7,6+#Item,colors.gray)
  155.         for i = 1,details.UsedTypes do
  156.             for b = 1,#Item do
  157.                 if details.Items[i].Name == Item[b][3] then
  158.                     if Item[b][1] ~= "_" then
  159.                     Item[b][2] = Item[b][1]
  160.                     end
  161.                 Item[b][1] = details.Items[i].Size
  162.                 end
  163.             end
  164.         end
  165.         for i = 1,#Item do
  166.             mon.setCursorPos(2,6+i)
  167.             mon.write(Item[i][3])
  168.             mon.setCursorPos(14,6+i)
  169.             mon.write("Anzahl: "..Item[i][1])
  170.             if Item[i][2] ~= "_" then
  171.                 mon.setCursorPos(41,6+i)
  172.                 mon.write(Item[i][1]-Item[i][2])
  173.             else
  174.                 mon.setCursorPos(46,6+i)
  175.                 mon.write("-")
  176.             end
  177.         end
  178.       end
  179.     end
  180.   end
  181.   event,_,xPos,yPos = os.pullEvent("monitor_touch")
  182. end
Advertisement
Add Comment
Please, Sign In to add comment