View difference between Paste ID: QwPsPGTg and HbSng9gL
SHOW: | | - or go back to the newest paste.
1-
-- pastebin get HbSng9gL startup
1+
-- pastebin get QwPsPGTg startup
2
-- -------------------------------------------
3-
-- My excavate -Sinkir-
3+
-- Dark iron farm -Sinkir-
4-
-- Version 2.1 (2014/10/2)
4+
-- Version 1.0 (2014/10/11)
5-
-- slot 1 ender Chest resources      +-+-+-+-+
5+
-- slot 1  Wrath Igniter             +-+-+-+-+
6-
-- slot 2 ender Chest fuel           |C|C|L|F|
6+
-- slot 2  Iron block                |W|I| | |
7-
-- slot 3 chuck Loader or anchor     |S|D| | |
7+
-- slot 16 Fuel                      | | | | |
8-
-- slot 4 Fuel                       | | | | |
8+
--                                   | | | | |
9-
-- slot 5 Stone(block to ignore 1)   | | | | |
9+
--                                   | | | |F|
10-
-- slot 6 Dirt (block to ignore 2)   +-+-+-+-+
10+
--                                   +-+-+-+-+
11
-- -------------------------------------------
12
--   _____
13
--  |  ___|   _ _ __   ___
14
--  | |_ | | | | '_ \ / __|
15
--  |  _|| |_| | | | | (__
16
--  |_|   \__,_|_| |_|\___|
17
--
18-
dataFilePath = "data"
18+
19-
urlPhp = "http://sinkir.free.fr/turtle/"
19+
20-
-- Exemple of data file:
20+
21-
-- --------------------
21+
22-
-- 1,0,0,n
22+
23-
-- 2,0,0,n
23+
24-
-- 3,0,0,n
24+
25-
-- 4,0,0,n
25+
26-
-- 4,0,1,n
26+
27-
-- 4,0,2,n
27+
28-
-- 4,0,3,n
28+
29-
-- 4,0,3,s
29+
30-
-- 3,0,3,s
30+
31-
-- 2,0,3,s
31+
32-
-- 1,0,3,s
32+
33-
-- ...
33+
34-
-- --------------------
34+
	if(fuel() < 1)then
35-
-- we keep 5 last move
35+
36-
-- format : x,y,z,facing
36+
		select(16)
37-
--               (n e s w)
37+
38-
-- last line keep the info of the actual action
38+
39
	if(count(16) == 0)then
40
		return false
41-
-- `.+x       |-z     +y.'
41+
42-
--   `.       |       .'
42+
43-
--     `.     |up   .'
43+
44-
--  north`.   |   .' east
44+
45-
--         `. | .'
45+
	if(turtle.compareTo(16) == true)then
46-
--           :+:
46+
		if(count(16) < 64) then
47-
--         .' | `.
47+
			turtle.transferTo(16, turtle.getItemSpace(16))
48-
--   west.'   |   `. south
48+
49-
--     .'     |     `.
49+
50-
--   .'       |down   `.
50+
51-
-- .'-y     +z|       -x`.
51+
52-
-- 
52+
function dropAll()
53-
-- yes +z is for down
53+
54
	for i=3,15 do
55
		if(count(i)>0)then
56-
-- si x est egale a 0 on est sur la colone de bloc devan l'anchor
56+
57-
-- si x est egale a 8 on est sur la colone de fin
57+
58-
-- si y est egale a 1 on remonte pour retrouvé l'anchor
58+
			flag = turtle.dropDown()
59-
-- si y est egale a 0 on continue de dessendre 
59+
60-
-- si z est egale a 0 on est sur la ligne de bloc de l'anchor
60+
61
				i = i-1
62-
-- si x = 8 && z == 0 on dessend
62+
63-
-- si x = 8 && z == 3 on stop dessendre on ce retourne
63+
64-
-- si x = 0 && z == 3 on dessend
64+
65-
-- si x = 0 && z == 6 on stop dessendre on ce retourne
65+
66-
-- si x = 8 && z == 6 on dessend
66+
67-
-- si x = 8 && z == 9 on stop dessendre on ce retourne
67+
68
function init()
69
	if(turtle.detectUp() == true)then
70
		if(turtle.back() == false)then
71-
function checkLabel()
71+
			print("can't go back; exit")
72-
	if(os.getComputerLabel() == nil)then
72+
			shell.exit()
73-
		os.setComputerLabel(httpget("turtlegetlabel"))
73+
74
			return true
75
		end
76
	end
77-
function checkStop()
77+
	if(turtle.detect() == false)then
78-
	if(os.getComputerLabel() == nil)then
78+
		if(count(2) == 0)then
79-
		if(httpget("turtlegetstop") == "1")then
79+
			print("no iron block; reboot")
80
			sleep(30)
81
			os.reboot()
82-
		end	
82+
83
	end
84-
		if(httpget("turtlegetstop&label="..os.getComputerLabel()) == "1")then
84+
85
86
function checkIgniter()
87
	if(count(1) == 0)then
88
		select(1)
89
		if(turtle.suckDown() == false)then
90
			print("can't get Igniter")
91
			return false
92
		end
93-
function httpget(param)
93+
94-
	local sExample = http.get(urlPhp.."?a="..param) --Get contents of page
94+
95-
	local txt = sExample.readAll()
95+
96-
	sExample.close() --Just in case
96+
97-
	
97+
98-
	--print(txt)
98+
function checkIronBlock()
99-
	return txt
99+
	local i = 0
100
	if(turtle.detect() == true)then
101
		select(2)
102
		if(turtle.compare() == true)then
103-
	if(fuel() < 16)then
103+
			i = 0
104
			while (i < 16)do
105-
		select(4)
105+
				sleep(0.5)
106
				if(turtle.compare() == false)then
107
					i = 16
108-
	if(count(4) == 0)then
108+
109
					i = i+1
110
				end
111
			end
112
113
			
114-
	if(turtle.compareTo(4) == true)then
114+
			if(turtle.compare() == true)then
115-
		if(count(4) < 64) then
115+
				reIgnite()
116-
			turtle.transferTo(4, turtle.getItemSpace(4))
116+
117
				turtle.dig()
118
			end
119
		else
120-
function go(i)
120+
			turtle.dig()
121-
	if(i == nil)then
121+
122-
		i = 0
122+
123
		if(count(2) == 1)then
124
			select(2)
125
			turtle.place()
126-
	if(turtle.detect()==true)then
126+
			sleep(10)
127-
		if(turtle.dig()==false)then
127+
			turtle.dig()
128-
			fileSet(dataFilePath.."-IMPORTANT", "move,digUp,up")
128+
			turtle.dropDown()
129-
			z = z-1
129+
130
			os.reboot()
131
		elseif(count(2) > 0)then
132
			select(2)
133-
			if(turtle.detect()==true)then
133+
			turtle.place()
134-
				while(i<50)do
134+
135-
					i=i+1
135+
136-
					if(turtle.dig()==true)then
136+
137-
						sleep(1)
137+
138-
						if(turtle.forward()==true)then
138+
139-
							return true
139+
140-
						else
140+
141-
							return go(i)
141+
function reIgnite()
142-
						end
142+
	testFuel()
143-
					end
143+
	if(checkIgniter() == false)then
144-
					sleep(0.2)
144+
		print("no Igniter; exit")
145-
					
145+
		shell.exit()
146
	end
147
	if(turtle.detect() == true)then
148-
				if(turtle.forward()==true)then
148+
149-
					return true
149+
		if(turtle.dig() == true)then
150
			turtle.forward()
151-
					return go(i)
151+
			select(1)
152
			turtle.place()
153
			select(2)
154
			turtle.back()
155
		end
156-
		if(turtle.forward()==true)then
156+
157
end
158
159-
			while(i<50 and turtle.attack() == true)do
159+
160-
				i=i+1
160+
161-
				sleep(0.2)
161+
162-
				
162+
163
-- |_|  |_|\__,_|_|_| |_| |  | |
164-
			return go(0)
164+
165
166
--
167
168-
	return false
168+
169
170
testFuel()
171-
function up(i)
171+
172
init()
173-
	if(i == nil)then
173+
stop = false
174-
		i = 0
174+
175
	checkIgniter()
176
	checkIronBlock()
177-
	
177+
	dropAll()
178-
	if(turtle.detectUp()==true)then
178+
	--sleep(1)
179-
		select(7)
179+