View difference between Paste ID: PEXA8Fp6 and AEsgNwAL
SHOW: | | - or go back to the newest paste.
1-
--File: /digtunnel_old
1+
--File: /digtunnel
2
3-
dofile("/cattech/turtle.lua")
3+
local moves = dofile("/cattech/moves.lua")
4
local lists = dofile("/cattech/lists.lua")
5-
local moves = require("moves")
5+
6
dofile("/cattech/common.lua")
7
dofile("/cattech/file.lua")
8
dofile("/cattech/comms.lua")
9
10
local torchCounter = 7;
11
local redstoneTorchCounter = 1;
12
13-
		print("placing Torch!")
13+
14-
		placeLight(1)
14+
15
16
	if (torchCounter > 7) then
17
		log("info","placing Torch!")
18
		moves.placeLight(2)
19
		torchCounter = 0
20
	end
21
end
22
23
function checkRedstoneTorch() 
24
	redstoneTorchCounter = redstoneTorchCounter +1
25
26
	if (redstoneTorchCounter > 4) then
27
		log("info","placing Redstone Torch!")
28
		moves.up()
29-
		print("Continuing remaining: ",continue)
29+
		moves.turnLeft()
30
		moves.forward()
31
        local placeItem = selectTurtleItemByList(lists.redstoneMarker)
32
        if placeItem ~= nil then
33
            turtle.placeDown(placeItem)
34-
print("Going " .. config["pathDirection"] .. "  " .. config["maxSteps"] .. " blocks")
34+
35
		moves.turnRight()
36
		moves.turnRight()
37
		moves.forward()
38
		moves.forward()
39
        local placeItem = selectTurtleItemByList(lists.redstoneMarker)
40
        if placeItem ~= nil then
41
            turtle.placeDown(placeItem)
42
		end
43
		moves.turnLeft()
44
		moves.turnLeft()
45-
		turtle.digDown()
45+
		moves.forward()
46-
		turtle.down()
46+
		moves.turnRight()
47
		moves.down()
48-
		digTunnelSlice(tonumber(config["stairHeight"]))
48+
49
		redstoneTorchCounter = 0
50-
			secureTunnelSlice(tonumber(config["stairHeight"]))
50+
51
end
52
53
config = loadConfigAndDefaults()
54-
		goDigForward()
54+
55
if #arg >= 1 then
56
    config["maxSteps"] = tonumber(arg[1])
57
	if #arg >= 2 then
58
		config["pathDirection"] = arg[2]
59-
		digTunnelSlice(tonumber(config["stairHeight"])) 
59+
60
else
61-
			secureTunnelSlice(tonumber(config["stairHeight"]))
61+
62
	if continue ~= nil then
63
		log("info","Continuing remaining: ",continue)
64
		config["maxSteps"] = continue
65-
		turtle.up()
65+
66-
		goDigForward()
66+
67
68
displayHash(config)
69
local haveRednet = initializeRednetModem()
70
71-
		digTunnelSlice(tonumber(config["tunnelHeight"])) 
71+
log("info","Going " .. config["pathDirection"] .. "  " .. config["maxSteps"] .. " blocks")
72
73-
			secureTunnelSlice(tonumber(config["tunnelHeight"]))
73+
if (config["pathDirection"] == "mineshaft") then
74
	config["pathDirection"] = "level"
75
end
76
77-
		goDigForward()
77+
78
while spaces < config["maxSteps"] do
79
	refuelIfNeeded(30)
80
	if haveRednet then
81
		chunkload()
82
	end
83
84
	if (config["pathDirection"] == "down") then
85
		-- Starts 1 above first step
86-
	if 
86+
		moves.down()
87
88
		moves.digTunnelSlice(tonumber(config["stairHeight"]))
89
		if config["safeTunnel"] == "yes" then
90
			sleep(1)
91
			moves.secureTunnelSlice(tonumber(config["stairHeight"]))
92
		end
93
		checkTorch()
94
95
		moves.forward()
96
	end
97
98
	if (config["pathDirection"] == "up") then
99
		-- Starts on first step.
100
		moves.digTunnelSlice(tonumber(config["stairHeight"])) 
101
		if config["safeTunnel"] == "yes" then
102
			sleep(1)
103
			moves.secureTunnelSlice(tonumber(config["stairHeight"]))
104
		end
105
		checkTorch()
106
107
		moves.up()
108
		moves.forward()
109
	end
110
111
	if (config["pathDirection"] == "level") then
112
		-- Starts the ground
113
		moves.digTunnelSlice(tonumber(config["tunnelHeight"])) 
114
115
		if config["safeTunnel"] == "yes" then
116
			sleep(1)
117
			moves.secureTunnelSlice(tonumber(config["tunnelHeight"]))
118
		end
119
120
		checkTorch()
121
		-- Mineshaft mode, place redstone torches every 4 spots to indicate branch locations.
122
		checkRedstoneTorch()
123
124
		moves.forward()
125
	end
126
127
	local remaining = config["maxSteps"] - spaces
128
	updateLine(remaining.."/"..config["maxSteps"])
129
130
	local inv = scanInventory()
131
132
	if (inv.empty == 0) then
133
		dropCommonItems(inv)
134
	end
135
136
	spaces = spaces + 1
137
	updateContinue("digtunnel",remaining)
138
end
139
140
updateContinue("digtunnel",nil)
141