KaychenHH

Wuffelz Inventory

Feb 15th, 2025
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.74 KB | Gaming | 0 0
  1. --
  2. --Wuffelz Inventory V1
  3. --written in 02/2025 by Kay Michaelsen
  4. --
  5. --vardef
  6. --
  7. monitor1 = peripheral.wrap("monitor_0")
  8. monitor2 = peripheral.wrap("monitor_2")
  9. --monitor3 = peripheral.wrap("monitor_7")
  10. --monitor4 = peripheral.wrap("monitor_56")
  11. rss = peripheral.wrap("meBridge_0")
  12. --
  13. obergrenze = 30000
  14. aSeeds = 0
  15. aPro = 0
  16. myst = "mysticalagriculture:"
  17. imm = "immersiveengineering:"
  18. automat = true
  19. dPage = 1
  20. dMax = 0
  21.  
  22. gefunden = {}
  23. agefunden = 0
  24.  
  25. pName = {}
  26. pDN = {}
  27. pLine = {}
  28. pStat = {}
  29. pByte = {}
  30. pFound = {}
  31. pStored = {}
  32. pSide = {}
  33. pMax = {}
  34. aPro = 30
  35. dMax = 1
  36.  
  37.  
  38.  
  39. function UserCommand( xpos, ypos)
  40.  
  41.     local bunt = {}
  42.  
  43.     print("UC" ,xpos ,ypos)
  44.     if ypos == 23 then
  45.         if (xpos>42) and (xpos<54) then
  46.             if automat == true then
  47.                 automat = false
  48.             else
  49.                 automat = true
  50.             end
  51.         end
  52.     elseif ypos == 1 then
  53.         if (xpos<6) then
  54.             --prev page
  55.             if dPage > 1 then
  56.                 dPage = dPage -1
  57.             end
  58.         elseif (xpos>52) then
  59.             if dPage < dMax then
  60.                 dPage = dPage +1
  61.             end
  62.         end
  63.     end
  64.     dMax = math.floor(agefunden / 20) +1
  65.  
  66. end
  67.  
  68.  
  69. function CheckInferiumReihe(lesen)
  70.  
  71.     such = {}
  72.     such.name = "refined"
  73.  
  74.     rs = rss.listItems()
  75.  
  76.     if not(rs == nil) then
  77.         for slot, item in pairs(rs) do
  78.             if not(string.find(item.name,such.name) == nil) then
  79.                 agefunden = agefunden + 1
  80.                 gefunden.name[agefunden] = item.name
  81.                 gefunden.menge[agefunden] = item.amount
  82.             end
  83.  
  84.         end
  85.     end
  86.  
  87. end
  88.  
  89. function MonAufbau(moni)
  90.  
  91.     if not(moni == nil) then
  92.         moni.setTextScale(0.5)
  93.         moni.setBackgroundColor(colors.black)
  94.         moni.clear()
  95.         moni.setBackgroundColor(colors.green)
  96.         moni.setTextColor(colors.black)
  97.         moni.setCursorPos(16,1)
  98.         moni.write(" *** Wuffelz Inventory *** ")
  99.  
  100.         moni.setCursorPos(2,1)
  101.         if dPage > 1 then
  102.             moni.setBackgroundColor(colors.orange)
  103.         else
  104.             moni.setBackgroundColor(colors.black)
  105.             moni.setTextColor(colors.orange)
  106.         end
  107.         moni.write(" << ")
  108.  
  109.         moni.setCursorPos(7,1)
  110.         moni.setBackgroundColor(colors.black)
  111.         moni.setTextColor(colors.orange)
  112.         moni.write(string.format("%1d", dPage))
  113.  
  114.         moni.setCursorPos(53,1)
  115.         if dPage < dMax then
  116.             moni.setBackgroundColor(colors.orange)
  117.             moni.setTextColor(colors.black)
  118.         else
  119.             moni.setBackgroundColor(colors.black)
  120.             moni.setTextColor(colors.orange)
  121.         end
  122.         moni.write(" >> ")
  123.  
  124.         for i = 0,20 do
  125.             moni.setBackgroundColor(colors.black)
  126.             moni.setTextColor(colors.blue)
  127.             moni.setCursorPos(1, i + 2)
  128.             pr = i + ((dPage - 1) * 20)
  129.             if pr <= agefunden then
  130.                 moni.write(gefunden.name[pr])
  131.                 moni.setCursorPos(50, i + 2)
  132.                 moni.write(string.format("%6d", gefunden.menge[pr]))
  133.             end
  134.         end
  135.         moni.setBackgroundColor(colors.black)
  136.         moni.setTextColor(colors.blue)
  137.         moni.setCursorPos(5,23)
  138.  
  139.     end
  140.  
  141. end
  142.  
  143.  
  144. while true do
  145.  
  146.     CheckInferiumReihe(lesen)
  147.  
  148.     MonAufbau(monitor1)
  149.     MonAufbau(monitor2)
  150.     --MonAufbau(monitor3)
  151.     --MonAufbau(monitor4)
  152.  
  153.     event, button, x, y = os.pullEventRaw()
  154.  
  155.     if event == "terminate" then
  156.         break
  157.     elseif event == "redstone" then
  158.         --neuer Durchlauf
  159.     elseif (event == "monitor_touch") and (button == "monitor_0") then
  160.         UserCommand( x, y)
  161.     elseif (event == "monitor_touch") and (button == "monitor_2") then
  162.         UserCommand( x, y)
  163.     else
  164.         print(event, button, x, y)
  165.     end
  166.  
  167. end
  168.  
  169.  
Advertisement
Add Comment
Please, Sign In to add comment