Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- h = fs.open("text","r")
- local args = {...}
- local myChar = args[1]
- local height = 0
- local ascending = true
- --reset slot selection to 1
- turtle.select(1)
- --checks to see if it has 2 or more blocks. if it only has one, it will back away from construction until it has been refilled
- function checkInventory()
- --checks the current slot
- local amount = turtle.getItemCount()
- if amount>=2 then
- return
- end
- if (turtle.getSelectedSlot()==16) or (turtle.getItemCount(turtle.getSelectedSlot()+1)==0) then
- turtle.back()
- turtle.select(1)
- --once it backs up, it sleeps five seconds at a time and then rechecks if it has been filled
- while turtle.getItemCount()<=1 do
- sleep(5)
- end
- --tries to move forward again
- while (turtle.detect() == true) do
- sleep(1)
- end
- turtle.forward()
- --ready to continue
- return
- end
- if (amount==0) then
- turtle.select(turtle.getSelectedSlot()+1)
- end
- end
- --tries to move up. if it fails, it waits 5 seconds then tries again.
- function up()
- while (turtle.up()==false) do
- sleep(5)
- end
- height = height + 1
- end
- --tries to move down. if it fails, it waits 5 seconds then tries again.
- function down()
- if height==0 then
- return
- end
- while (turtle.down()==false) do
- sleep(5)
- end
- height = height-1
- end
- --performs the turn at the top/bottom of a column
- function turn()
- turtle.turnRight()
- while (turtle.forward() == false) do
- sleep(5)
- end
- turtle.turnLeft()
- down()
- end
- checkInventory()
- line = h.readLine()
- while ((line ~= "") and (line ~= nil)) do
- for i=1,string.len(line) do
- checkInventory()
- if (not turtle.detect()) and (string.sub(line,i,i) == myChar) then
- turtle.place()
- end
- --move then check to see if it has enough resources to continue
- if (ascending==true) then
- up()
- else
- down()
- end
- end
- --the column is complete, so we perform a turn
- turn()
- line = h.readLine()
- ascending = not ascending
- end
- turtle.back()
- turtle.back()
Advertisement
Add Comment
Please, Sign In to add comment