View difference between Paste ID: sVaDcEKr and 5Psfihcx
SHOW: | | - or go back to the newest paste.
1
-- Program:
2
--   mine
3
-- Original program by Direwolf20
4
-- Modified by Kzorith and even more by Liktorn
5
-- Description:
6
--   Operates the mining wells and Force Manipulator
7
-- Hardware requirements:
8
--   1 Advanced Mining Turtle
9
--   1 Rednet cable
10
11
function turnOff()
12
	rs.setBundledOutput("bottom",0)
13
end
14
function startTesseract()
15
	--  print what we are doing
16
	print("Mining for 8 seconds")
17
	--  set a redstone signal to activate the tesseract
18
	--    (mine is white)
19
	rs.setBundledOutput("bottom",colors.white)
20
	--  wait 8 seconds for the mining operation to complete
21
	sleep(8)
22
	--  turn off all redstone signals
23
	turnOff()
24
end
25
26
function move()
27
	--moving the platform
28
	--  print what we are doing
29
	print("Moving platform")
30
	--  wait 5 seconds
31
	sleep(5)
32
	--  set a redstone signal to activate the Force Manipulator
33
	--    (Move is orange)
34
	rs.setBundledOutput("bottom",colors.orange)
35
	-- make sure that the Force Manipulator have time to get the signal
36
	sleep(1)
37
	--  turn off all redstone signals
38
	turnOff()
39
	sleep(4)
40
	-- and move the turtle 1 forward
41
	turtle.forward()
42
	-- and now, check if a block is present in front of the turtle
43
	-- in that case, clear, and run the clearDebris program
44
	if turtle.detect() then
45
		print("Obstacle detected,")
46
		print("running clearDebris program")
47
		turtle.forward()
48
		shell.run("clearDebris")
49
	end
50
		
51
		
52
		
53
end
54
55
function placeChest()
56
	print("Placing chest")
57
	turtle.select(1)
58
	turtle.place()
59
	sleep(0.5)
60
61
end
62-
	-- break the program
62+
63
function breakChest()
64
	print("Breasking chest")
65
	--brakes the chest in front of it
66
	turtle.dig()
67-
		while true do
67+
68-
			print("Error: No cable below. Miner stuck. Infinite loop")
68+
69-
			return
69+
70-
		end
70+
71
	-- checks if the cable is under the turtle
72
	-- if not, the miner is stuck
73
	-- run the clearDebris program
74
	if turtle.detectDown() then
75
	  -- if true, then everything is allright and the miner can continue
76
		print("Cable below, continuing")
77
		placeChest()
78
	else
79
		-- no cable detected below. Thst means that the miner is stuck
80
		-- no chest gets placed, and the main program can't detect
81
		-- that a block is in the chest.The program pauses
82
		print("Error: No cable below. Running the clearDebris program")
83
		-- run the clear program to remove the debris
84
		shell.run("clearDebris")
85
		-- move the platform to the new cleared location
86
		move()
87
		return
88
	end
89
end
90
91
breakChest()
92
startTesseract()
93
94
95
96
-- move the platform
97
move()
98
checkCable()