Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```lua
- -- Block mapping (by slot in turtle inventory):
- -- 1 = black wool
- -- 2 = gray wool
- -- 3 = light gray wool
- -- 4 = quartz
- -- 5 = stone
- -- 6 = basalt
- -- 0 = air (skip)
- -- TODO: paste your 64x64 pixels table here:
- -- pixels = {
- -- {0,0,0,...}, -- row 1 (top)
- -- ...
- -- {0,0,0,...} -- row 64 (bottom)
- -- }
- local WIDTH = 64
- local HEIGHT = 64
- -- Selects the correct slot for a given block id (1–6)
- local function selectBlock(id)
- if id == 0 then return false end
- if id < 1 or id > 6 then return false end
- turtle.select(id)
- return true
- end
- -- Places a block in front if id != 0
- local function placeBlock(id)
- if id == 0 then return end
- if selectBlock(id) then
- -- Try to dig if something is there
- while turtle.detect() do
- turtle.dig()
- sleep(0.2)
- end
- turtle.place()
- end
- end
- -- Move forward safely
- local function safeForward()
- while not turtle.forward() do
- turtle.dig()
- sleep(0.2)
- end
- end
- -- Move up safely
- local function safeUp()
- while not turtle.up() do
- turtle.digUp()
- sleep(0.2)
- end
- end
- -- Move down safely
- local function safeDown()
- while not turtle.down() do
- turtle.digDown()
- sleep(0.2)
- end
- end
- -- Return to bottom-left after finishing a row
- local function goToRowStart(row)
- -- row 1 is top, row HEIGHT is bottom
- -- We build from bottom to top, so:
- -- row HEIGHT = y=0, row 1 = y=HEIGHT-1
- -- We assume turtle starts at bottom-left, facing the wall.
- end
- -- Main build routine
- local function build()
- -- Start at bottom-left, facing wall.
- -- We will build from bottom row (HEIGHT) up to top row (1).
- for y = HEIGHT, 1, -1 do
- -- Move to correct vertical level
- if y == HEIGHT then
- -- already at bottom
- else
- safeUp()
- end
- -- Build this row left-to-right
- for x = 1, WIDTH do
- local id = pixels[y][x]
- placeBlock(id)
- if x < WIDTH then
- safeForward()
- end
- end
- -- Move back to row start (left side)
- turtle.turnLeft()
- turtle.turnLeft()
- for x = 1, WIDTH - 1 do
- safeForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- -- Return to bottom-left (go down HEIGHT-1)
- for i = 1, HEIGHT - 1 do
- safeDown()
- end
- end
- build()
Advertisement
Add Comment
Please, Sign In to add comment