Last active
January 18, 2016 20:05
-
-
Save joelhelbling/f43673e5f48f06195753 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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