Advertisement
Skortioth

[CC]: Turtle Room Program

Jan 21st, 2022 (edited)
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. -- The command is: room length width height - example: room 5 5 3
  2.  
  3. local args = {...}
  4. local length,width,height
  5.  
  6. if( #args==2)then
  7. length = tonumber(args[1])
  8. width = tonumber( args[1])
  9. height = tonumber(args[2])
  10.     print("Creating room with "..args[1].."x"..args[1].."x"..args[2].."...")
  11. elseif(#args==3)then
  12. length = tonumber(args[1])
  13. width = tonumber(args[2])
  14. height = tonumber( args[3])
  15.     print("Creating room with "..args[1].."x"..args[2].."x"..args[3].."...")
  16. end
  17.  
  18. local function forward()
  19.     while not(turtle.forward())do
  20.         turtle.dig()
  21.     end
  22. end
  23.  
  24. local function up()
  25.     while not(turtle.up())do
  26.         turtle.digUp()
  27.     end
  28. end
  29.  
  30. local tright = true
  31. local function turnAround()
  32.     if(tright)then
  33.         turtle.turnRight()
  34.         forward()
  35.         turtle.turnRight()
  36.     else
  37.         turtle.turnLeft()
  38.         forward()
  39.         turtle.turnLeft()
  40.     end
  41.     tright = not tright
  42. end
  43.  
  44.  
  45. for h=0, height-1 do
  46.    if h > 0 then
  47.        up()
  48.        turtle.turnLeft()
  49.        turtle.turnLeft()
  50.    end
  51.     for w=0, width-1 do
  52.        if w > 0 then
  53.            turnAround()
  54.        end
  55.         for l=0,length-2 do
  56.             forward()
  57.         end
  58.     end
  59.     --tright = (not tright)
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement