View difference between Paste ID: TUN2J3cN and 172twws3
SHOW: | | - or go back to the newest paste.
1-
os.loadAPI("turtleForward.lua")
1+
2
3
-- Get the dimensions
4
function input(newWidth, newLength, newDepth)
5
	width = newWidth
6
	length = newLength
7-
    width = newWidth
7+
8-
    length = newLength
8+
	fuelcost = 0
9-
    depth = newDepth
9+
10-
    fuelcost = 0
10+
11
function getFuelCost()
12
	return fuelcost
13-
function setWidth(newWidth)
13+
14
15
-- Function to Mine to Depth
16
function mineDepth()
17-
function setLength(newLength)
17+
18
    fuelcost = fuelcost + 1
19
  end
20
  for j = 1, depth do
21-
function setDepth(newDepth)
21+
	fuelcost = fuelcost + 1
22
  end
23
end
24
25
-- Function to mine a layer
26
function mine(width, length)
27
  for i = 1, length do
28-
    turtle.digDown()
28+
29-
	turtle.down()
29+
      mineDepth()
30
      fuelcost = fuelcost + 1
31
    end
32
    if i < length then
33-
function mineHeight()
33+
34-
	for j = 1, depth do
34+
        mineDepth()
35-
		turtle.digUp()
35+
        fuelcost = fuelcost + 1
36-
		turtle.up()
36+
37-
  	end
37+
        mineDepth()
38
        fuelcost = fuelcost + 1
39
      end
40
    end
41
  end
42-
  down = true
42+
43
44
45-
      if down then
45+
46-
	  	mineDepth()
46+
47-
		down = false
47+
48-
	  else
48+
    		fuelcost = fuelcost + 1
49-
		mineHeight()
49+
50-
		down = true
50+
51-
	  end
51+
52-
      turtleForward.moveForward()
52+
    		fuelcost = fuelcost + 1
53
	end
54
	fuelcost = fuelcost + 1
55
end
56-
        if down then
56+
57-
	  		mineDepth()
57+
58-
			down = false
58+
function predict(newWidth, newLength, newDepth)
59-
	    else
59+
	input(newWidth, newLength, newDepth)
60-
			mineHeight()
60+
	fuelcost = fuelcost + 1
61-
			down = true
61+
	mine(width, length)
62-
	    end
62+
	mineDepth()
63-
        turtle.turnRight()
63+
	toStart()
64-
        turtleForward.moveForward()
64+
	return fuelcost
65-
        turtle.turnRight()
65+