Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scriptName = "excavator"
- local args = {...}
- if #args < 4 then
- print("Usage: " .. scriptName .. " <width> <depth> <height> <start>")
- print("<start> should be 'top' or 'bottom'")
- return
- end
- dofile("turtle_bot")
- local t = TurtleBot.new(scriptName, "North")
- t:connect()
- local WIDTH = tonumber(args[1])
- local DEPTH = tonumber(args[2])
- local HEIGHT = tonumber(args[3])
- local START = args[4]
- if not inList(START, {"top", "bottom"}) then
- print("Invalid start option. Use 'top' or 'bottom'.")
- return
- end
- local function mineRow(steps)
- for _ = 1, steps do
- while turtle.detect() do
- t:dig()
- local inventory = t:inventory()
- if #inventory > 10 then
- t:enderDeposit(COLOR_CHANNELS.miningDepot, {})
- t:dig("up")
- end
- t:enderRefuel(2000, 5000, ITEMS.charcoal)
- t:dig("up")
- sleep(.5)
- end
- t:forward()
- end
- end
- local function mineLayer(width, depth)
- for w = 1, width do
- mineRow(depth - 1)
- if w ~= width then
- if w % 2 == 1 then
- t:right()
- mineRow(1)
- t:right()
- else
- t:left()
- mineRow(1)
- t:left()
- end
- end
- end
- if width % 2 == 0 then
- t:right()
- t:right()
- mineRow(width - 1)
- t:right()
- t:right()
- end
- end
- local function main()
- for h = 1, HEIGHT do
- mineLayer(WIDTH, DEPTH)
- if h ~= HEIGHT then
- if START == "top" then
- t:dig("down")
- t:down()
- else
- t:dig("up")
- t:up()
- end
- end
- end
- end
- t:execute(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement