neo34rd

inspectchest.lua

May 1st, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. function getSlot(c, i)
  2. return c.getStackInSlot(i)
  3. end
  4.  
  5.  
  6. function getName(c, i)
  7. local slot = getSlot(c, i)
  8. if slot then
  9. return slot.name
  10. else
  11. return false
  12. end
  13. end
  14.  
  15.  
  16. function getID(c, i)
  17. local slot = getSlot(c, i)
  18. if slot then
  19. return slot.id
  20. else
  21. return false
  22. end
  23. end
  24.  
  25.  
  26. function getDamage(c, i)
  27. local slot = getSlot(c, i)
  28. if slot then
  29. return slot.dmg
  30. else
  31. return false
  32. end
  33. end
  34.  
  35.  
  36. function getQty(c, i)
  37. local slot = getSlot(c, i)
  38. if slot then
  39. return slot.qty
  40. else
  41. return false
  42. end
  43. end
  44.  
  45.  
  46. function inspectSlot(c, i)
  47. name = getName(c, i)
  48. if name == false then
  49. --print("no item in slot: ", i)
  50. else
  51. sprint(name)
  52. sprint(getID(c, i))
  53. sprint(getDamage(c, i))
  54. sprint(getQty(c, i))
  55. end
  56. end
  57.  
  58.  
  59. function sprint(s)
  60. if s == false then
  61. return
  62. else
  63. print(s)
  64. end
  65. end
  66.  
  67.  
  68. function peek(c)
  69. local max = c.getInventorySize()
  70. for i = 1, max do
  71. inspectSlot(c, i)
  72. end
  73. end
  74.  
  75.  
  76. function getSlotWithItem(c, itemName, itemDamage)
  77. c.condenseItems()
  78. local max = c.getInventorySize()
  79. for i = 1, max do
  80. local slot = getSlot(c, i)
  81. if slot ~= nil then
  82. if slot.id == itemName and slot.dmg == itemDamage then
  83. return i
  84. end
  85. end
  86. end
  87. return nil
  88. end
Advertisement
Add Comment
Please, Sign In to add comment