Skip to content

Instantly share code, notes, and snippets.

@joelhelbling
Last active January 18, 2016 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhelbling/f43673e5f48f06195753 to your computer and use it in GitHub Desktop.
Save joelhelbling/f43673e5f48f06195753 to your computer and use it in GitHub Desktop.
local slot_switch
slot_switch = function()
if turtle.getSelectedSlot() == 16 then
return turtle.select(1)
else
return turtle.select(turtle.getSelectedSlot() + 1)
end
end
local slot_check
slot_check = function()
if turtle.getItemCount() == 0 then
print("Slot empty, switching...")
end
while turtle.getItemCount() == 0 do
slot_switch()
end
end
local lay_blocks
lay_blocks = function()
if turtle.detect() then
slot_check()
turtle.placeDown()
turtle.up()
turtle.turnLeft()
return turtle.turnLeft()
else
slot_check()
turtle.placeDown()
return turtle.forward()
end
end
local running = true
print("Running...")
if turtle.detect() then
print("Wrong direction, turning around...")
turtle.turnLeft()
turtle.turnLeft()
end
print("Building wall now!")
while running do
if turtle.detectUp() then
slot_check()
turtle.placeDown()
local last_row = true
while last_row do
lay_blocks()
if turtle.detectUp() then
turtle.placeDown()
last_row = false
running = false
end
end
else
lay_blocks()
end
end
return print("All done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment