Guest User

util_item

a guest
Jan 9th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. --[[ Code by mikebald
  2.      Modify / Take / Use how you like
  3. --]]
  4.  
  5. function DropAll()
  6.     for i=1,16 do
  7.         turtle.select(i)
  8.         turtle.dropDown()
  9.     end
  10. end
  11.  
  12. function MoveAll(from, to)
  13.     turtle.select(from)
  14.     return turtle.transferTo(to)
  15. end
  16.  
  17. -- moves = ((fuel / 100) * 6)
  18. function FuelNeeded( moves )
  19.     return math.ceil((moves * 100) / 6)
  20. end
  21.  
  22. function Refuel( slot )
  23.     turtle.select(slot)
  24.     return turtle.refuel(64)
  25. end
  26.  
  27. function RefuelAll()
  28.     for i=1,16 do
  29.         turtle.select(i)
  30.         turtle.refuel(64)
  31.     end
  32. end
  33.  
  34. function NonEmptySlot()
  35.     for i=1,16 do
  36.         if turtle.getItemCount(i) > 1 then
  37.             turtle.select(i)
  38.             return true
  39.         end
  40.     end
  41. end
  42.  
  43. function PlaceNext()
  44.     while not turtle.placeDown() do
  45.         NonEmptySlot()
  46.         if turtle.detectDown() then
  47.             turtle.digDown()
  48.         else
  49.             turtle.attackDown()
  50.         end
  51.     end
  52. end
  53.  
  54. function ConfirmFull()
  55.     for i=1,16 do
  56.         if turtle.getItemSpace(i) > 0 then
  57.             return false
  58.         end
  59.     end
  60.     return true
  61. end
  62.  
  63. function ConfirmAmount( amount )
  64.     local total = 0
  65.     for i=1,16 do
  66.         total = total + turtle.getItemCount(i)
  67.         if total >= amount then return true end
  68.     end
  69.     return false
  70. end
Advertisement
Add Comment
Please, Sign In to add comment