Advertisement
hohserg

pimAndPresent.lua

Dec 27th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local c=require("component")
  2. local modem=c.modem
  3. local pim=c.pim
  4. local io=require("io")
  5.  
  6. local chestSide="east"
  7. local trashSide="south"
  8. local presentSide="west"
  9.  
  10. local function presentPredicate(stack)
  11.     --return stack.id=="OpenComputers:item" and stack.dmg==88 --1.7.10
  12.     return stack.id=="OpenComputers:misc" and stack.dmg==2
  13. end
  14. local function trashPredicate(stack)
  15.     --return stack.id=="OpenComputers:item" and stack.dmg==21 --1.7.10
  16.     return stack.id=="OpenComputers:material" and stack.dmg==15
  17. end
  18.  
  19. io.write("Command?\n")
  20. while true do
  21.     io.write(">")
  22.     local cmd = io.read()
  23.  
  24.     if cmd=="afk eject" then
  25.         for i=1,pim.getInventorySize() do
  26.             pim.pushItemIntoSlot(chestSide,i,64,i)
  27.         end
  28.         io.write("success!\n")
  29.     elseif cmd=="afk pick up" then
  30.         for i=1,pim.getInventorySize() do
  31.             pim.pullItemIntoSlot(chestSide,i,64,i)
  32.         end
  33.         io.write("success!\n")
  34.     elseif cmd=="start" then
  35.         modem.broadcast(111,"")
  36.         while true do
  37.             for i=9,1,-1 do
  38.                 stack=pim.getStackInSlot(i)
  39.                 if stack and trashPredicate(stack) then
  40.                     pim.pushItem(trashSide,i,64)
  41.                 else
  42.                     break
  43.                 end
  44.             end
  45.            
  46.             for i=1,9 do
  47.                 stack=pim.getStackInSlot(i)
  48.                 if stack and presentPredicate(stack) then
  49.                     pim.pushItem(presentSide,i,64)
  50.                 else
  51.                     break
  52.                 end
  53.             end
  54.         end
  55.     elseif cmd=="exit" then
  56.         return
  57.     end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement