Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scriptName = "mason"
- local args = {...}
- if #args < 3 then
- print("Usage: " .. scriptName .. " <width> <height> <channel>")
- return
- end
- local WIDTH = tonumber(args[1])
- local HEIGHT = tonumber(args[2])
- local CHANNEL = args[3]
- if not COLOR_CHANNELS[CHANNEL] then
- print(CHANNEL .. " is not a valid color channel.")
- return
- end
- dofile("turtle_bot")
- local t = TurtleBot.new(scriptName, "North")
- t:connect()
- local function selectBlocks()
- for k,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 standardSegment()
- place()
- place("down")
- place("up")
- end
- local function firstSegment()
- place("down")
- place("up")
- end
- local function lastSegment()
- place()
- place("down")
- t:up()
- place("down")
- t:up()
- place("down")
- end
- local function turnAround()
- t:right()
- t:right()
- end
- local function build()
- for h=1, HEIGHT, 3 do
- t:up()
- turnAround()
- firstSegment()
- t:back()
- for w=1, WIDTH - 2 do
- standardSegment()
- t:back()
- end
- lastSegment()
- end
- end
- local function collectBlocks()
- local stacks = math.ceil(HEIGHT * WIDTH / 64)
- for i=1, stacks do
- t:enderCollect(COLOR_CHANNELS[CHANNEL], 64)
- end
- t:dig("up")
- end
- local function main()
- collectBlocks()
- build()
- end
- t:execute(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement