Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wlk = { ... }
- local totalMoved = 0
- local length, width = tonumber(wlk[1]), tonumber(wlk[2])
- if #wlk ~= 2 or type(length) ~= "number" or type(width) ~= "number" then --checking user'sInput
- print( "use the program properly!" )
- return
- end
- local function walkLength() --move forward for (length) times
- for i = 2, length do
- turtle.forward()
- totalMoved = totalMoved + 1
- end
- end
- face = 0
- local function altTurn() --alternating turn (left, left),(right, right)
- if face < 2 then
- face = face+1
- turtle.turnLeft()
- elseif face == 2 then
- face = face+1
- turtle.turnRight()
- else
- face = 0
- turtle.turnRight()
- end
- end
- local cWidth = 0
- turtle.turnRight()
- while width ~= cWidth do
- print('Percent done: '..math.floor(totalMoved / (length * width) * 100)..'%')
- walkLength()
- cWidth = cWidth+1
- if width ~= cWidth then -- rechecking
- altTurn()
- turtle.forward()
- altTurn()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment