Advertisement
Guest User

startup

a guest
Mar 18th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.65 KB | None | 0 0
  1. -- Program:
  2. --   startup
  3. -- Original Program by Direwolf20
  4. -- Modified by Kzorith
  5. -- Description:
  6. --   Controls the operation of the Uberminer
  7. -- Hardware Requirement:
  8. --   1 Advanced Mining Turtle
  9. --   1 Chest
  10.  
  11. -- Initialization
  12. --  set this to whatever side the chest is on
  13. c = peripheral.wrap("right")
  14.  
  15. --  loop forever doing the following
  16. while true do
  17.    --  set a counter to indicate what slot in the chest we are looking at
  18.    i = 2
  19.    --  while the turtle is low on fuel
  20.    while turtle.getFuelLevel() < 200 do
  21.       --  look in a particular slot in the chest
  22.       --  first time through it'll be the second slot
  23.       --  if there is an item in that slot...
  24.       if c.getStackInSlot(i) then
  25.          --  pull it into the turtle
  26.          --  "west" is the direction that the turtle is from the chest
  27.          --  'i' is the slot in the chest to take from
  28.          --  '64' is the maximum number to take
  29.          --  '16' is the slot in the turtle to put the items      
  30.          c.pushItem("west",i,64,16)
  31.          --  set the turtle to look at slot 16
  32.          turtle.select(16)
  33.          --  try to use what's in that slot to refuel
  34.          turtle.refuel()
  35.          --  if there are still items in the slot, it wasn't suitable for refueling
  36.          if turtle.getItemCount(16) > 0 then
  37.             --  put the item back where you got it
  38.             --  "west" is the direction the turtle is from the chest
  39.             --  '16' is the slot on the turtle to take from
  40.             --  '64' is the maximum amount to take
  41.             --  'i' is the slot in the chest in which to put the items
  42.             c.pullItem("west",16,64,i)
  43.          end -- if getItemCount
  44.          --  set the turtle to look at slot 1
  45.          turtle.select(1)
  46.       end -- if getStackInSlot
  47.       --  move to the next slot in the chest
  48.       i = i + 1
  49.       --  if we've moved beyond the last slot...
  50.       if i > 27 then
  51.       --  print that the turtle can't refuel
  52.          print("No fuel available for refueling.")
  53.          -- exit the while getFuelLevel loop
  54.          break
  55.       end -- if i > 27
  56.    end -- while getFuelLevel
  57.    
  58.    --  print what we are doing
  59.    print("Checking for item in chest")
  60.    --  if there is an item in slot 1
  61.    --  note we don't care about any other slot other than slot 1
  62.    if c.getStackInSlot(1) then
  63.       --  print what we are doing
  64.       print("  Item Present: Mining")
  65.       --  execute the mine program
  66.       shell.run("mine")
  67.    --  otherwise
  68.    else
  69.       --  print what we are doing
  70.       print("  Item Missing: Waiting")
  71.       -- wait 5 seconds
  72.       sleep(5)
  73.    end -- if getStackInSlot
  74. end -- while true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement