Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scriptName = "landfill"
- local args = {...}
- if #args < 3 then
- print("Usage: " .. scriptName .. " <width> <depth> <channel>")
- return
- end
- local WIDTH = tonumber(args[1])
- local DEPTH = tonumber(args[2])
- local CHANNEL = args[3]
- dofile("turtle_bot")
- if not COLOR_CHANNELS[CHANNEL] then
- print(CHANNEL .. " is not a valid color channel.")
- return
- end
- local t = TurtleBot.new(scriptName, "North")
- t:connect()
- local function selectBlocks()
- for _, v in pairs(t:inventory()) do
- if v.name ~= ITEMS.enderChest.name then
- turtle.select(v.slot)
- break
- end
- end
- end
- local function place(direction)
- local placeFunc = turtle.place
- if direction == "up" then
- placeFunc = turtle.placeUp
- elseif direction == "down" then
- placeFunc = turtle.placeDown
- end
- selectBlocks()
- placeFunc()
- end
- local function collectBlocks()
- for i=1, 2 do
- t:enderCollect(COLOR_CHANNELS[CHANNEL], 64)
- end
- t:dig("up")
- end
- local function fill()
- local y = 0
- while t:down() do
- y = y + 1
- sleep(.5)
- end
- for _ = 1, y do
- t:up()
- place("down")
- end
- end
- local function traverseRow(steps)
- for _ = 1, steps do
- local inventory = t:inventory()
- if #inventory < 3 then
- collectBlocks()
- end
- fill()
- t:enderRefuel(2000, 5000, ITEMS.charcoal)
- t:dig("up")
- sleep(.5)
- t:forward()
- end
- end
- local function main()
- for w = 1, WIDTH do
- traverseRow(DEPTH - 1)
- if w ~= WIDTH then
- if w % 2 == 1 then
- t:right()
- traverseRow(1)
- t:right()
- else
- t:left()
- traverseRow(1)
- t:left()
- end
- end
- end
- if WIDTH % 2 == 0 then
- t:right()
- t:right()
- traverseRow(WIDTH - 1)
- t:right()
- t:right()
- end
- end
- t:execute(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement