View difference between Paste ID: SNXdXJmZ and 1Vu239GE
SHOW: | | - or go back to the newest paste.
1
local tArgs = { ... }
2
3
if #tArgs ~= 2 then
4-
        print( "Usage: pave <width>, <length>" )
4+
        print( "Usage: stairs <depth>, <length>" )
5
        return
6
end
7
8-
local width = tonumber( tArgs[1] )
8+
local depth = tonumber( tArgs[1] )
9-
if width < 1 then
9+
if depth < 1 then
10-
        print( "Pave width must be positive" )
10+
        print( "stair depth must be positive" )
11
        return
12
end
13
14
local length = tonumber( tArgs[2] )
15
if length < 1 then
16-
        print( "Pave length must be positive" )
16+
        print( "stair length must be positive" )
17
        return
18
end
19
20-
turtle.refuel()
20+
local function digForward()
21
  while (turtle.detect()) do
22
    turtle.dig()
23
    sleep(0.2)
24
  end
25
end
26
27
local function digUp()
28-
print("paving "..width.." x "..length)
28+
  while (turtle.detectUp()) do
29
    turtle.digUp()
30
    sleep(0.2)
31-
local start = width/2
31+
32-
turtle.turnLeft()
32+
33-
for i=1,start do
33+
34-
  turtle.forward()
34+
turtle.select(16)
35
local requiredFuel = (depth*2 / 80) + 1
36
if (requiredFuel < turtle.getFuelLevel()) then
37
  turtle.refuel()
38-
local goRight = true
38+
39-
for i=1,length do
39+
40-
  turtle.forward()
40+
41-
  if (turtle.detect()) then
41+
42-
    return
42+
43
 return
44
end
45-
  if (goRight) then
45+
46-
    turtle.turnRight()
46+
print("stairs "..depth.." x "..length)
47-
  else 
47+
48-
    turtle.turnLeft()
48+
local curDepth = 0
49
turtle.select(1)
50
51-
  for j=1,width do
51+
while (curDepth < depth) do
52-
    if (j > 1) then
52+
  for i=1,length do
53-
      turtle.forward()
53+
    digForward() 
54
    turtle.forward()
55
    turtle.digDown()
56-
      turtle.placeDown()
56+
    digUp()
57
    turtle.down()
58
    if (not turtle.detectDown()) then
59
      turtle.placeDown()   
60-
  if (goRight) then
60+
    else
61-
    turtle.turnLeft()
61+
      if (not turtle.compareDown()) then
62-
  else 
62+
        turtle.digDown()
63-
    turtle.turnRight()
63+
        turtle.placeDown()    
64
      end
65-
  goRight = not goRight
65+
66
  
67
    curDepth = curDepth + 1
68
    if (curDepth == depth) then
69
      return
70
    end
71
  end
72
  turtle.turnRight()
73
end
74
75
turtle.turnRight()
76
turtle.turnRight()
77
78
curDepth = 0
79
while (curDepth < depth) do
80
  for i=1,length do
81
    turtle.up()
82
    turtle.forward()
83
84
    curDepth = curDepth + 1
85
    if (curDepth == depth) then
86
      return
87
    end
88
  end
89
  turtle.turnLeft()
90
end