Saferer

LUA Hello World

Jan 23rd, 2021 (edited)
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. shell.run('clear')
  2. args = {...}
  3.  
  4. local length = tonumber(args[1])
  5. local width = tonumber(args[2])
  6.  
  7. local dirIsForward = true
  8. for i = 0, width-1, 1 do
  9.     for j = 0, length-1, 1 do
  10.         while turtle.detect() do
  11.             turtle.dig()
  12.         end
  13.         turtle.forward()
  14.         local yCount = 0
  15.         while(turtle.detectUp()) do
  16.             turtle.digUp()
  17.             turtle.up()
  18.             yCount = yCount + 1
  19.         end
  20.         while (yCount ~= 0) do
  21.             turtle.down()
  22.             yCount = yCount - 1
  23.         end
  24.     end
  25.     if dirIsForward and j ~= width-1 then
  26.         turtle.turnRight()
  27.         while turtle.detect() do
  28.             turtle.dig()
  29.         end
  30.         turtle.forward()
  31.         turtle.turnRight()
  32.     elseif not dirIsForward and j ~= width-1 then
  33.         turtle.turnLeft()
  34.         while turtle.detect() do
  35.             turtle.dig()
  36.         end
  37.         turtle.forward()
  38.         turtle.turnLeft()      
  39.     end
  40.     dirIsForward = not dirIsForward
  41. end                  
  42.        
Add Comment
Please, Sign In to add comment