Michael_Roy

the giga-gigachad

Apr 26th, 2026
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1.  
  2. ```lua
  3. -- Block mapping (by slot in turtle inventory):
  4. -- 1 = black wool
  5. -- 2 = gray wool
  6. -- 3 = light gray wool
  7. -- 4 = quartz
  8. -- 5 = stone
  9. -- 6 = basalt
  10. -- 0 = air (skip)
  11.  
  12. -- TODO: paste your 64x64 pixels table here:
  13. -- pixels = {
  14. -- {0,0,0,...}, -- row 1 (top)
  15. -- ...
  16. -- {0,0,0,...} -- row 64 (bottom)
  17. -- }
  18.  
  19. local WIDTH = 64
  20. local HEIGHT = 64
  21.  
  22. -- Selects the correct slot for a given block id (1–6)
  23. local function selectBlock(id)
  24. if id == 0 then return false end
  25. if id < 1 or id > 6 then return false end
  26. turtle.select(id)
  27. return true
  28. end
  29.  
  30. -- Places a block in front if id != 0
  31. local function placeBlock(id)
  32. if id == 0 then return end
  33. if selectBlock(id) then
  34. -- Try to dig if something is there
  35. while turtle.detect() do
  36. turtle.dig()
  37. sleep(0.2)
  38. end
  39. turtle.place()
  40. end
  41. end
  42.  
  43. -- Move forward safely
  44. local function safeForward()
  45. while not turtle.forward() do
  46. turtle.dig()
  47. sleep(0.2)
  48. end
  49. end
  50.  
  51. -- Move up safely
  52. local function safeUp()
  53. while not turtle.up() do
  54. turtle.digUp()
  55. sleep(0.2)
  56. end
  57. end
  58.  
  59. -- Move down safely
  60. local function safeDown()
  61. while not turtle.down() do
  62. turtle.digDown()
  63. sleep(0.2)
  64. end
  65. end
  66.  
  67. -- Return to bottom-left after finishing a row
  68. local function goToRowStart(row)
  69. -- row 1 is top, row HEIGHT is bottom
  70. -- We build from bottom to top, so:
  71. -- row HEIGHT = y=0, row 1 = y=HEIGHT-1
  72. -- We assume turtle starts at bottom-left, facing the wall.
  73. end
  74.  
  75. -- Main build routine
  76. local function build()
  77. -- Start at bottom-left, facing wall.
  78. -- We will build from bottom row (HEIGHT) up to top row (1).
  79. for y = HEIGHT, 1, -1 do
  80. -- Move to correct vertical level
  81. if y == HEIGHT then
  82. -- already at bottom
  83. else
  84. safeUp()
  85. end
  86.  
  87. -- Build this row left-to-right
  88. for x = 1, WIDTH do
  89. local id = pixels[y][x]
  90. placeBlock(id)
  91. if x < WIDTH then
  92. safeForward()
  93. end
  94. end
  95.  
  96. -- Move back to row start (left side)
  97. turtle.turnLeft()
  98. turtle.turnLeft()
  99. for x = 1, WIDTH - 1 do
  100. safeForward()
  101. end
  102. turtle.turnLeft()
  103. turtle.turnLeft()
  104. end
  105.  
  106. -- Return to bottom-left (go down HEIGHT-1)
  107. for i = 1, HEIGHT - 1 do
  108. safeDown()
  109. end
  110. end
  111.  
  112. build()
  113.  
Advertisement
Add Comment
Please, Sign In to add comment