Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- player = peripheral.wrap("top")
- --modem = peripheral.wrap("right")
- manip = peripheral.wrap("bottom")
- modem.open(1337)
- -- function GetPacket()
- -- local packet = {}
- -- packet.event,
- -- packet.side,
- -- packet.frequency,
- -- packet.replyFrequency,
- -- packet.message,
- -- packet.distance = os.pullEvent("modem_message")
- -- return packet
- -- end
- function SwapItems (heldSlot, targetSlot, tempSlot)
- player.pushItems("up", heldSlot, 64, tempSlot)
- player.pullItems("up", targetSlot, 64, heldSlot)
- end
- function SwapBack (heldSlot, targetSlot, tempSlot)
- player.pushItems("up", heldSlot, 64, targetSlot)
- player.pullItems("up", tempSlot, 64, heldSlot)
- end
- function TestName(slot, name)
- local item = player.getItemMeta(slot)
- --print(name)
- if item then
- --print(item.displayName)
- return item.displayName == name
- else return false end
- end
- function RunTest(name)
- for itemSlot = 1, 9, 1 do
- result = TestName(itemSlot, name)
- if result then
- --print(itemSlot)
- return itemSlot
- end
- end
- end
- function ConsumeItem(slot)
- inv = manip.getInventory()
- item = inv.getItem(slot)
- if item and item.consume then
- item.consume()
- end
- end
- --print (manip.getMetaOwner().heldItem.getMetadata().displayName)
- while true do
- itemTest = player.getItemMeta(27)
- if not itemTest then
- --SEE HOW HUNGRY I AM
- saturation = manip.getMetaOwner().food.saturation
- if saturation < 10 then
- SwapItems (27, 1, 26)
- ConsumeItem(27)
- end
- health = manip.getMetaOwner().health
- maxHealth = manip.getMetaOwner().maxHealth
- potions = manip.getMetaOwner().potionEffects
- --CHECK IF REGEN IS ACTIVE
- if not string.find(potions, "regen") then
- --CHECK IF I GOT OUCHIES
- if health < (maxHealth - 20) then
- SwapItems (27, 2, 26)
- ConsumeItem(27)
- SwapBack (27, 2, 26)
- end
- end
- end
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement