slay_mithos

Room (basic)

Apr 13th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local args = {...}
  2. local length, width, stop
  3. if (args[1] == nil) then
  4.     print("Please give a size as the first argument.")
  5.     length = 0
  6.     width = 0
  7. else
  8.     length = tonumber(args[1])
  9.     if (args[2] ~= nil) then
  10.         width = tonumber(args[2])
  11.     else
  12.         width = length
  13.     end
  14. end
  15.  
  16. local function forward()
  17.     turtle.digUp()
  18.     turtle.digDown()
  19.     while (not turtle.forward()) do
  20.         if (turtle.detect()) then
  21.             turtle.dig()
  22.         else
  23.             turtle.attack()
  24.         end
  25.     end
  26. end
  27.  
  28. local function turn(turnFunc)
  29.     turnFunc()
  30.     forward()
  31.     turnFunc()
  32. end
  33.  
  34. for i=1, width do
  35.     for j=2, length do
  36.         forward()
  37.     end
  38.     if (i < width) then
  39.         if (i%2 == 1) then
  40.             turn(turtle.turnRight)
  41.         else
  42.             turn(turtle.turnLeft)
  43.         end
  44.     end
  45. end
  46. turtle.digUp()
  47. turtle.digDown()
Advertisement
Add Comment
Please, Sign In to add comment