Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modules = peripheral.find("manipulator") or peripheral.find("neuralInterface")
- if not modules then
- error("Must have neural interface or manipulator", 0)
- else
- textutils.slowPrint("Initializing Neural Interface!", 15)
- end
- if not modules.hasModule("plethora:sensor") then
- error("The entity sensor is missing", 0)
- else
- textutils.slowPrint("Initializing Sensors!", 15)
- end
- if not modules.hasModule("plethora:introspection") then
- error("The introspection module is missing", 0)
- else
- textutils.slowPrint("Initializing Player Inventory!", 15)
- end
- local inv = modules.getInventory()
- local cachedSlot = false
- while true do
- local data = modules.getMetaOwner()
- while data.food.hungry do
- local item
- if cachedSlot then
- local slotItem = inv.getItem(cachedSlot)
- if slotItem and slotItem.consume then
- item = slotItem
- else
- cachedSlot = nil
- end
- end
- if not item then
- for slot, meta in pairs(inv.list()) do
- local slotItem = inv.getItem(slot)
- if slotItem and slotItem.consume then
- print("Using food from slot " .. slot)
- item = slotItem
- cachedSlot = slot
- break
- end
- end
- end
- if item then
- item.consume()
- else
- print("Cannot find food")
- break
- end
- data = modules.getMetaOwner()
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement