Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Making a Tutle that mines out a quarry
- local tArgs = { ... }
- local x = tonumber(tArgs[1])
- local y = tonumber(tArgs[1])
- local z = tonumber(tArgs[2])
- local turnDir = 0
- -- Check if there is a chest below the turtle
- function checkChest()
- if turtle.detectDown() then
- local success, data = turtle.inspectDown()
- if success then
- if data.name == "minecraft:chest" then
- return true
- end
- end
- end
- return false
- end
- function start()
- -- Check if there is a chest below the turtle
- if checkChest() then
- print("Chest found")
- turtle.turnRight()
- turtle.forward()
- turtle.dig()
- turtle.digDown()
- turtle.turnLeft()
- print("Starting to mine")
- else
- print("No chest found")
- end
- end
- function mine()
- -- make an algortihmn that mines out a square using the x and y variables until the given z is reached
- -- then return to the starting position
- for i = 1, z do
- for j = 1, x do
- turtle.dig()
- turtle.forward()
- end
- if turnDir == 0 then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turnDir = 1
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turnDir = 0
- end
- end
- end
- function main()
- start()
- mine()
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement