Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. player = peripheral.wrap("top")
  2. --modem = peripheral.wrap("right")
  3. manip = peripheral.wrap("bottom")
  4. modem.open(1337)
  5.  
  6. -- function GetPacket()
  7. -- local packet = {}
  8. -- packet.event,
  9. -- packet.side,
  10. -- packet.frequency,
  11. -- packet.replyFrequency,
  12. -- packet.message,
  13. -- packet.distance = os.pullEvent("modem_message")
  14. -- return packet
  15. -- end
  16.  
  17. function SwapItems (heldSlot, targetSlot, tempSlot)
  18. player.pushItems("up", heldSlot, 64, tempSlot)
  19. player.pullItems("up", targetSlot, 64, heldSlot)
  20. end
  21.  
  22. function SwapBack (heldSlot, targetSlot, tempSlot)
  23. player.pushItems("up", heldSlot, 64, targetSlot)
  24. player.pullItems("up", tempSlot, 64, heldSlot)
  25. end
  26.  
  27. function TestName(slot, name)
  28. local item = player.getItemMeta(slot)
  29. --print(name)
  30. if item then
  31. --print(item.displayName)
  32. return item.displayName == name
  33. else return false end
  34. end
  35.  
  36. function RunTest(name)
  37. for itemSlot = 1, 9, 1 do
  38. result = TestName(itemSlot, name)
  39. if result then
  40. --print(itemSlot)
  41. return itemSlot
  42. end
  43. end
  44. end
  45.  
  46. function ConsumeItem(slot)
  47. inv = manip.getInventory()
  48. item = inv.getItem(slot)
  49. if item and item.consume then
  50. item.consume()
  51. end
  52. end
  53.  
  54. --print (manip.getMetaOwner().heldItem.getMetadata().displayName)
  55.  
  56. while true do
  57.  
  58. itemTest = player.getItemMeta(27)
  59.  
  60. if not itemTest then
  61.  
  62. --SEE HOW HUNGRY I AM
  63.  
  64. saturation = manip.getMetaOwner().food.saturation
  65. if saturation < 10 then
  66. SwapItems (27, 1, 26)
  67. ConsumeItem(27)
  68. end
  69.  
  70. health = manip.getMetaOwner().health
  71. maxHealth = manip.getMetaOwner().maxHealth
  72. potions = manip.getMetaOwner().potionEffects
  73.  
  74. --CHECK IF REGEN IS ACTIVE
  75. if not string.find(potions, "regen") then
  76. --CHECK IF I GOT OUCHIES
  77. if health < (maxHealth - 20) then
  78. SwapItems (27, 2, 26)
  79. ConsumeItem(27)
  80. SwapBack (27, 2, 26)
  81. end
  82. end
  83.  
  84. end
  85.  
  86. sleep(0.5)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement