Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs == 0 then
- print("What do you want me to do?")
- print(" dig numberOfBlocks")
- print(" move left")
- print(" move right")
- -- relocation code
- elseif tArgs[1] == "move" and #tArgs>=2 then
- if tArgs[2] == "right" or tArgs[2]=="left" then
- turtle.back()
- if tArgs[2]=="right" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- for i=1,3 do turtle.forward() end
- if tArgs[2]=="right" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for i = 1,2 do
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- turtle.back()
- turtle.select(1)
- turtle.placeUp()
- end
- -- Digging code
- elseif tArgs[1] == "dig" then
- local range = 1
- if #tArgs > 1 then
- range = tonumber(tArgs[2])
- end
- -- Check number of torches before digging
- if turtle.getItemCount(1) < range/6 then
- print("I will just light up the tunnel with my personality...")
- else
- local x = 0
- local xmax = 0
- while xmax < range-1 and range <= turtle.getFuelLevel()/2 do
- -- empty inventory
- print("Pooping...")
- for i = 2, 16 do
- turtle.select(i)
- turtle.dropDown()
- end --end inventory drop
- turtle.select(1)
- print("Hi Ho, Hi Ho, it's off to work we go *whistles*")
- -- move forward until wall is hit
- while turtle.forward() do
- x = x + 1
- end -- end while forward
- -- start digging
- while turtle.getItemCount(15) == 0 and x <= range do
- local count = 0 -- counts how many blocks are broken. if above 20, assume water and move on
- while turtle.dig() and count < 20 do
- sleep(0.5)
- count = count + 1
- end
- turtle.forward()
- x = x + 1
- turtle.digDown()
- count = 0
- while turtle.digUp() and count < 20 do
- sleep(0.5)
- count = count + 1
- end
- --place some torches
- if x%6 == 0 then
- turtle.select(1)
- turtle.placeDown()
- end
- end -- end while digging
- -- go back to start
- xmax = x
- while x > 0 do
- if turtle.back() then
- x = x -1
- end
- end
- print("I got all the way to "..xmax)
- end -- end while range check
- end
- if range > turtle.getFuelLevel()/2 then
- print("But I'm le tired")
- else
- print("I fought the blocks, and I won")
- end
- else
- print("You want me to do WHAT???")
- end
Advertisement
Add Comment
Please, Sign In to add comment