Advertisement
dadragon84

FeedPlayer

Mar 4th, 2025
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. local modules = peripheral.find("manipulator") or peripheral.find("neuralInterface")
  2.     if not modules then
  3.         error("Must have neural interface or manipulator", 0)
  4.     else
  5.         textutils.slowPrint("Initializing Neural Interface!", 15)
  6.     end
  7.  
  8.     if not modules.hasModule("plethora:sensor") then
  9.         error("The entity sensor is missing", 0)
  10.     else
  11.         textutils.slowPrint("Initializing Sensors!", 15)
  12.     end
  13.     if not modules.hasModule("plethora:introspection") then
  14.         error("The introspection module is missing", 0)
  15.     else
  16.         textutils.slowPrint("Initializing Player Inventory!", 15)
  17.     end
  18.  
  19.     local inv = modules.getInventory()
  20.     local cachedSlot = false
  21.     while true do
  22.         local data = modules.getMetaOwner()
  23.         while data.food.hungry do
  24.             local item
  25.             if cachedSlot then
  26.                 local slotItem = inv.getItem(cachedSlot)
  27.                 if slotItem and slotItem.consume then
  28.                     item = slotItem
  29.                 else
  30.                     cachedSlot = nil
  31.                 end
  32.             end
  33.             if not item then
  34.                 for slot, meta in pairs(inv.list()) do
  35.                     local slotItem = inv.getItem(slot)
  36.                     if slotItem and slotItem.consume then
  37.                         print("Using food from slot " .. slot)
  38.                         item = slotItem
  39.                         cachedSlot = slot
  40.                         break
  41.                     end
  42.                 end
  43.             end
  44.             if item then
  45.                 item.consume()
  46.             else
  47.                 print("Cannot find food")
  48.                 break
  49.             end
  50.             data = modules.getMetaOwner()
  51.         end
  52.         sleep(5)
  53.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement