jamawie

Muzze77 - ME Reader

May 11th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. shell.run("clear")
  3. sen = sensor.wrap("bottom")
  4. targs = sen.getTargets()
  5.  
  6. locale = "1,0,0"
  7.  
  8. function tableSortSize(a,b)
  9.   return(a.ItemSize > b.ItemSize)
  10. end
  11.  
  12. function cbut(cx,cy,tcol,itemName, itemSize)
  13. if tcol == nil or tcol == "" then
  14.   tcol = colors.white
  15. end
  16. mon.setTextColor(tcol)
  17. mon.setCursorPos(cx,cy)
  18. mon.clearLine(cy)
  19. mon.write(itemName .. ": " .. itemSize)
  20. mon.setTextColor(colors.white)
  21. end
  22.  
  23.  
  24. mon = peripheral.wrap("back")
  25. globX, globY = mon.getSize()
  26.  
  27.  
  28. function itemClaim(itemName1, itemSize1,posX,posY,color)
  29.   table.insert(items,{ItemName = itemName1,ItemSize = itemSize1,locationX = posX, locationY = posY, colorID = color})  
  30. end
  31.  
  32.  
  33.  
  34. mon.clear()
  35.  
  36. while true do
  37.   items = {}
  38.   mon.setCursorPos(globX/2-9,1)
  39.   mon.clearLine(1)
  40.   mon.write("Muzze77 ME Inventar")
  41.   s = sen.getTargetDetails(locale)
  42.  
  43.   for v, k in pairs(s.Items) do
  44.     if k.Name == "UU-Matter" then
  45.     itemClaim(k.Name,k.Size,2,0,colors.pink)
  46.     elseif k.Name == "Iron Ingot" then
  47.     itemClaim(k.Name,k.Size,2,0,colors.gray)
  48.     end
  49.   end
  50.  
  51.   table.sort(items,tableSortSize)
  52.  
  53.   for itemK=1, #items do
  54.     cbut(items[itemK].locationX, itemK, items[itemK].colorID, items[itemK].ItemName,items[itemK].ItemSize)
  55.   end
  56.  
  57.  
  58.   items = nil
  59.   sleep(10)
  60.  
  61. end
Add Comment
Please, Sign In to add comment