Hastwell

Auto Bow Combiner

Oct 11th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. -- warning: can only run on a crafty turtle
  2. -- TODO: add turtle detection
  3.  
  4. -- Stack Keys
  5. -- |- name (Sign)
  6. -- |- rawName (item.sign)
  7. -- |- id
  8. -- |- dmg (0)
  9. -- |- maxSize (16 - max size of stack)
  10. -- |- ench(table)
  11. --      Empty for sign
  12. --      "Efficiency V"
  13. -- |- qty
  14. local chest = peripheral.wrap('front')
  15.  
  16. local function checkChest()
  17.     local chestStacks = chest.getAllStacks()
  18.     local weakestBow = 1
  19.     local strongestBow = 1
  20.    
  21.     for k,v in pairs(chestStacks) do
  22.         if table.getn(v.ench) > 0 then
  23.             print("Enchant found - skipp")
  24.         else
  25.             if v.dmg > chestStacks[strongestBow].dmg then strongestBow = k end
  26.             if v.dmg < chestStacks[weakestBow].dmg then weakestBow = k end
  27.         end
  28.     end
  29.    
  30.     return {weakestIndex=weakestBow, weakestStack=chestStacks[weakestBow], strongestIndex=strongestBow, strongestStack=chestStacks[strongestBow]}
  31. end
  32.  
  33. ccResults = checkChest()
  34. print("Strongestbow is #"..ccResults.strongestIndex.." at dmg "..ccResults.strongestStack.dmg)
  35. print("Weakestbow is #"..ccResults.weakestIndex.." at dmg "..ccResults.weakestStack.dmg)
  36. print("Beginning chest withdraw transaction...")
  37. success = chest.pullItemIntoSlot('east',ccResults.weakestIndex,1,1)
  38. print(success)
Advertisement
Add Comment
Please, Sign In to add comment