SHOW:
|
|
- or go back to the newest paste.
1 | - | -- |
1 | + | --[[ |
2 | - | --GPS Deploy by neonerZ v1.1 |
2 | + | GPS Deploy by neonerZ v1.0 (modified for labeled computers by KaosKlaus) |
3 | - | --http://youtube.com/neonerz |
3 | + | http://youtube.com/neonerz |
4 | - | -- |
4 | + | |
5 | - | --This script is originally from BigSHinyToys from ComputerCraft.info |
5 | + | This script is originally from BigSHinyToys from ComputerCraft.info |
6 | - | --Original link can be found here: |
6 | + | Original link can be found here: |
7 | - | --http://www.computercraft.info/forums2/index.php?/topic/3088-how-to-guide-gps-global-position-system/page__p__28333#entry28333 |
7 | + | http://www.computercraft.info/forums2/index.php?/topic/3088-how-to-guide-gps-global-position-system/page__p__28333#entry28333 |
8 | - | --Edited by neonerZ |
8 | + | Edited by neonerZ |
9 | - | -- |
9 | + | |
10 | - | -- Modifications included: |
10 | + | In order to use this script you need to setup |
11 | - | -- |
11 | + | either a mining turtle, or a standard turtle |
12 | - | -- happydude11209: Line 209 - added logic to check if the server is set to no fuel mode |
12 | + | |
13 | - | -- http://www.computercraft.info/forums2/index.php?/topic/9528-gps-deploy-10/page__view__findpost__p__123411 |
13 | + | Mining Turtle: |
14 | - | -- |
14 | + | Slot 1 - Fuel |
15 | - | -- kittykiller: Line 110 - Bug in the locate code if you were using an existing GPS system to deploy a new one |
15 | + | Slot 2 - 1 Disk |
16 | - | -- http://www.computercraft.info/forums2/index.php?/topic/9528-gps-deploy-10/page__view__findpost__p__80323 |
16 | + | Slot 3 - At least 4 modems |
17 | - | -- |
17 | + | Slot 4 - At lease 1 disk drive |
18 | - | -- Mad_Professor: Line 296 - Bug calling computers, monitors. Making people think they needed to load 4 monitors |
18 | + | Slot 5-8 - At least 4 computers (makes use of labeled computers possible) |
19 | - | -- http://www.computercraft.info/forums2/index.php?/topic/9528-gps-deploy-10/page__view__findpost__p__150291 |
19 | + | |
20 | - | -- |
20 | + | Standard Turtle: |
21 | - | -- |
21 | + | Slot 1 - Fuel |
22 | - | -- |
22 | + | Slot 2 - 1 Disk |
23 | - | -- In order to use this script you need to setup |
23 | + | Slot 3 - At least 4 modems |
24 | - | -- either a mining turtle, or a standard turtle |
24 | + | Slot 4 - At lease 4 disk drives |
25 | - | -- Mining Turtle: Slot 1 - Fuel |
25 | + | Slot 5-8 - At least 4 computers (makes use of labeled computers possible) |
26 | - | -- Slot 2 - At least 4 computers |
26 | + | |
27 | - | -- Slot 3 - At least 4 modems |
27 | + | (mining turtles will be able to reuse the same |
28 | - | -- Slot 4 - At lease 1 disk drive |
28 | + | disk drive, where-as a standard turtle will leave |
29 | - | -- Slot 5 - 1 Disk |
29 | + | them and deploy a separate disk drive for each |
30 | - | -- Standard Turtle: Slot 1 - Fuel |
30 | + | GPS host) |
31 | - | -- Slot 2 - At least 4 computers |
31 | + | |
32 | - | -- Slot 3 - At least 4 modems |
32 | + | Default Usage: Place the turtle where you want it |
33 | - | -- Slot 4 - At lease 4 disk drives |
33 | + | deployed facing the SOUTH or 0 direction. |
34 | - | -- Slot 5 - 1 Disk |
34 | + | Fill the turtle with the required materials |
35 | - | -- |
35 | + | above. Then use the command |
36 | - | -- (mining turtles will be able to reuse the same |
36 | + | |
37 | - | -- disk drive, where-as a standard turtle will leave |
37 | + | gps-deploy x y z |
38 | - | -- them and deploy a separate disk drive for each |
38 | + | |
39 | - | -- GPS host) |
39 | + | Where x, y, z is the *absolute* positions of the deploment |
40 | - | -- |
40 | + | turtle. By default the turtle will deploy the |
41 | - | -- Default Usage: Place the turtle where you want it |
41 | + | the GPS array at around y = 254. Add a fourth |
42 | - | -- deployed facing the SOUTH or 0 direction. |
42 | + | value to specify the height offset. |
43 | - | -- Fill the turtle with the required materials |
43 | + | IMPORTANT: It's crucial you use your absolute coordinates, |
44 | - | -- above. Then use the command |
44 | + | (the ones inside the parentheses next to your realitive coordinates) |
45 | - | -- |
45 | + | For Example: If F3 shows X = -6.43534 (-7) or Z = -15.542 (-16) |
46 | - | -- gps-deploy x y z |
46 | + | you'd use -7 and -16 respectively. If you use -6 and -15 all coordinates |
47 | - | -- |
47 | + | that go past 0 in the opposite direction will be off by 1.) |
48 | - | -- Where x, y, z is the *absolute* positions of the deploment |
48 | + | |
49 | - | -- turtle. By default the turtle will deploy the |
49 | + | Example: gps-deploy 1 1 1 20 |
50 | - | -- the GPS array at around y = 254. Add a fourth |
50 | + | |
51 | - | -- value to specify the height offset. |
51 | + | Would assume the turtle's start position is |
52 | - | -- IMPORTANT: It's crucial you use your absolute coordinates, |
52 | + | x=1, y=1, z=1 and will deploy the satelite |
53 | - | -- (the ones inside the parentheses next to your realitive coordinates) |
53 | + | array at y= 21 |
54 | - | -- For Example: If F3 shows X = -6.43534 (-7) or Z = -15.542 (-16) |
54 | + | |
55 | - | -- you'd use -7 and -16 respectively. If you use -6 and -15 all coordinates |
55 | + | neonerZ added features: |
56 | - | -- that go past 0 in the opposite direction will be off by 1.) |
56 | + | Smart Refilling: Fuel should go in slot 1. |
57 | - | -- |
57 | + | If not enough fuel is available script |
58 | - | -- Example: gps-deploy 1 1 1 20 |
58 | + | will prompt user for more fuel and wait 30. |
59 | - | -- |
59 | + | Script will estimate how much fuel is needed |
60 | - | -- Would assume the turtle's start position is |
60 | + | and try to take only that much (in coal) |
61 | - | -- x=1, y=1, z=1 and will deploy the satelite |
61 | + | Item Detection: Script will check slots 2-5 //modified: 2-8 |
62 | - | -- array at y= 21 |
62 | + | for the correct quantity of items. It does |
63 | - | -- |
63 | + | *not* check if items are valid |
64 | - | --neonerZ added features |
64 | + | GPS Host Coordinates: The script now requires |
65 | - | -- Smart Refilling: Fuel should go in slot 1. |
65 | + | you to enter in the coordinates of the |
66 | - | -- If not enough fuel is available script |
66 | + | turtle before launching. This will set |
67 | - | -- will prompt user for more fuel and wait 30. |
67 | + | the GPS host computers to the correct |
68 | - | -- Script will estimate how much fuel is needed |
68 | + | coordinates. |
69 | - | -- and try to take only that much (in coal) |
69 | + | Satelite Array Location: The script allows |
70 | - | -- Item Detection: Script will check slots 2-5 |
70 | + | the user to set an offset for the placement |
71 | - | -- for the correct quantity of items. It does |
71 | + | of the four satelites |
72 | - | -- *not* check if items are valid |
72 | + | |
73 | - | -- GPS Host Coordinates: The script now requires |
73 | + | KaosKlaus added: |
74 | - | -- you to enter in the coordinates of the |
74 | + | support for labeled (non-stackable) computers |
75 | - | -- turtle before launching. This will set |
75 | + | set label for computers after placing them |
76 | - | -- the GPS host computers to the correct |
76 | + | reworked fuel check |
77 | - | -- coordinates. |
77 | + | minor fixes |
78 | - | -- Satelite Array Location: The script allows |
78 | + | --]] |
79 | - | -- the user to set an offset for the placement |
79 | + | |
80 | - | -- of the four satelites |
80 | + | -- ******** FUNCTIONS ******** |
81 | ||
82 | - | -- How heigh up should the satellite be deployed? |
82 | + | |
83 | - | -- This is the default value if you don't pass a |
83 | + | |
84 | - | -- value to the script. There is a check down below |
84 | + | |
85 | - | -- to make sure the user entered values isn't > 254 |
85 | + | |
86 | - | height = 255 |
86 | + | |
87 | print( "would deploy the satelite to y=21") | |
88 | - | -- need to enable rednet first incase using locate |
88 | + | |
89 | - | rednet.open( "right" ) |
89 | + | |
90 | print( "to find out the coords over GPS") | |
91 | end | |
92 | ||
93 | -- move functions - (original code) | |
94 | ||
95 | local mov = {} | |
96 | ||
97 | mov.forward = function () | |
98 | while not turtle.forward() do | |
99 | sleep(1) | |
100 | end | |
101 | return true | |
102 | - | -- confirm default height isn't set above 254 |
102 | + | |
103 | - | -- Check to see if a minimum of 3 values were |
103 | + | |
104 | - | -- passed to the script |
104 | + | |
105 | sleep(1) | |
106 | end | |
107 | return true | |
108 | - | print ("") |
108 | + | |
109 | mov.up = function () | |
110 | while not turtle.up() do | |
111 | sleep(1) | |
112 | end | |
113 | return true | |
114 | end | |
115 | mov.down = function () | |
116 | while not turtle.down() do | |
117 | - | height = tonumber(height) |
117 | + | |
118 | end | |
119 | - | height = tonumber(tArgs[2]) |
119 | + | |
120 | end | |
121 | - | print ("gps-deploy ",xcord," ",ycord," ",zcord," height: ",height) |
121 | + | |
122 | - | xcord = tonumber(xcord) |
122 | + | |
123 | - | ycord = tonumber(ycord) |
123 | + | |
124 | - | zcord = tonumber(zcord) |
124 | + | |
125 | end | |
126 | - | if #tArgs <= 2 then |
126 | + | |
127 | local function selectComp() | |
128 | for i = 5,8 do | |
129 | if turtle.getItemCount(i) > 0 then | |
130 | turtle.select(i) | |
131 | return | |
132 | - | zcord = tonumber(tArgs[3]) |
132 | + | |
133 | end | |
134 | - | height = tonumber(height) |
134 | + | |
135 | ||
136 | - | if tonumber(tArgs[4]) > 254 then |
136 | + | local function clearTerm() |
137 | - | height = tonumber(height) |
137 | + | |
138 | - | else |
138 | + | |
139 | - | height = tonumber(tArgs[4]) |
139 | + | |
140 | ||
141 | local function p(text) | |
142 | term.clearLine() | |
143 | print(text) | |
144 | end | |
145 | ||
146 | - | if height > ycord and height < 256 then |
146 | + | local function clearLastLines(num) |
147 | - | height = height-ycord |
147 | + | local x,y = term.getCursorPos() |
148 | for i = 1,num do | |
149 | term.setCursorPos(1,y-i) | |
150 | - | if height > 255 then |
150 | + | term.clearLine() |
151 | - | height = 255 |
151 | + | |
152 | end | |
153 | ||
154 | - | -- check if the script is running on a turtle |
154 | + | local function checkFuel() |
155 | - | -- (original code) |
155 | + | --[[ |
156 | Check if we have enough fuel | |
157 | we estimate the fuel usage ((height*2)+70) needed to | |
158 | complete the deoployment and then see if we have enough | |
159 | fuel loaded. If we don't, it checks the first slot for | |
160 | available fuel and tries to fill up on it. If it doesn't | |
161 | have enough fuel in there, it prompts the user for more | |
162 | - | -- move functions |
162 | + | fuel. It allows 30 seconds for the user to add fuel |
163 | - | -- (original code) |
163 | + | (trying to refuel and verify fuel level every second) |
164 | and if it doesn't get it's fill within 30 seconds | |
165 | it exits with a message to the user | |
166 | neonerZ | |
167 | --]] | |
168 | if fuelLevel == "unlimited" then | |
169 | return true | |
170 | end | |
171 | fuelNeed = height*2+120 | |
172 | if turtle.getFuelLevel() < fuelNeed then | |
173 | turtle.select(1) | |
174 | realcoal=math.ceil((fuelNeed-turtle.getFuelLevel())/80) | |
175 | while turtle.getFuelLevel() < fuelNeed do | |
176 | if turtle.getItemCount(1) <= 0 then | |
177 | for i=30,1,-1 do | |
178 | term.setCursorPos(1,4) | |
179 | p("You ran out of fuel in slot 1") | |
180 | p("Please insert "..fuelNeed-turtle.getFuelLevel().." fuel or "..realcoal.." coal to continue") | |
181 | p("Waiting "..i.." seconds for fuel or exiting") | |
182 | sleep(1) | |
183 | if turtle.refuel(1) then | |
184 | clearLastLines(4) | |
185 | print("continuing...") | |
186 | break | |
187 | end | |
188 | if i==1 then | |
189 | term.setCursorPos(1,4) | |
190 | p("Not enough fuel provided") | |
191 | p("Please provide "..fuelNeed-turtle.getFuelLevel().." fuel or "..realcoal.." coal and try again") | |
192 | p("") | |
193 | return false | |
194 | end | |
195 | end | |
196 | - | local base = nil |
196 | + | |
197 | end | |
198 | - | -- Check if we have enough fuel |
198 | + | turtle.refuel(1) |
199 | - | -- we estimate the fuel usage ((height*2)+70) needed to |
199 | + | |
200 | - | -- complete the deoployment and then see if we have enough |
200 | + | |
201 | - | -- fuel loaded. If we don't, it checks the first slot for |
201 | + | |
202 | - | -- available fuel and tries to fill up on it. If it doesn't |
202 | + | |
203 | - | -- have enough fuel in there, it prompts the user for more |
203 | + | |
204 | - | -- fuel. It allows 30 seconds for the user to add fuel |
204 | + | |
205 | - | -- (trying to refuel and verify fuel level every second) |
205 | + | -- ******** MAIN PROGRAM ******** |
206 | - | -- and if it doesn't get it's fill within 30 seconds |
206 | + | |
207 | - | -- it exits with a message to the user |
207 | + | clearTerm() |
208 | - | -- neonerZ |
208 | + | |
209 | - | if type(turtle.getFuelLevel()) == "string" then |
209 | + | -- check if the script is running on a turtle - (original code) |
210 | - | print("No-fuel mode") |
210 | + | |
211 | print("") | |
212 | - | if turtle.getFuelLevel() < (tonumber(height)*2)+70 then |
212 | + | |
213 | - | while turtle.getFuelLevel() < (tonumber(height)*2)+70 do |
213 | + | |
214 | - | turtle.select(1) |
214 | + | |
215 | - | realcoal=(((tonumber(height)*2)+70)-turtle.getFuelLevel())/80 |
215 | + | |
216 | - | if realcoal>=64 then |
216 | + | --[[ |
217 | - | coal=64 |
217 | + | How high up should the satellite be deployed? |
218 | - | else |
218 | + | This is the default value if you don't pass a |
219 | - | coal=math.ceil(realcoal) |
219 | + | value to the script. There is a check down below |
220 | to make sure the user entered values isn't > 254 | |
221 | - | if turtle.refuel(tonumber(coal)) == false then |
221 | + | --]] |
222 | - | fuel=((tonumber(height)*2)+70)-turtle.getFuelLevel() |
222 | + | |
223 | - | print("") |
223 | + | HEIGHT_DEFAULT = 254 |
224 | - | print("You ran out of fuel in slot 1") |
224 | + | height = 0 |
225 | - | print("Please insert "..fuel.." fuel or "..realcoal.." coal to continue") |
225 | + | |
226 | - | print("Waiting 30 seconds for fuel or exiting") |
226 | + | --[[ |
227 | - | i=0 |
227 | + | confirm default height isn't set above 254 |
228 | - | while i<=30 do |
228 | + | Check to see if a minimum of 3 values were |
229 | passed to the script | |
230 | - | realcoal=(((tonumber(height)*2)+70)-turtle.getFuelLevel())/80 |
230 | + | --]] |
231 | - | if realcoal>=64 then |
231 | + | |
232 | - | coal=64 |
232 | + | |
233 | - | else |
233 | + | |
234 | - | coal=math.ceil(realcoal) |
234 | + | |
235 | -- check for modem turtle and activate rednet | |
236 | - | turtle.refuel(tonumber(coal)) |
236 | + | if peripheral.getType("right") == "modem" then |
237 | - | if turtle.getFuelLevel() >= (tonumber(height)*2)+70 then |
237 | + | rednet.open( "right" ) |
238 | - | print("") |
238 | + | |
239 | - | print("Turtle Fueled") |
239 | + | print ("No Modem on Turtle detected, please rerun manually") |
240 | - | i=31 |
240 | + | |
241 | return | |
242 | - | if i==30 then |
242 | + | |
243 | - | fuel=((tonumber(height)*2)+70)-turtle.getFuelLevel() |
243 | + | |
244 | - | print("") |
244 | + | |
245 | - | print("Not enough fuel provided") |
245 | + | |
246 | - | print("Please provide "..fuel.." fuel or "..realcoal.." coal and try again") |
246 | + | |
247 | - | return |
247 | + | |
248 | return | |
249 | - | i=i+1 |
249 | + | |
250 | if tArgs[2] == nil then | |
251 | height = HEIGHT_DEFAULT-ycord | |
252 | else | |
253 | height = math.min(tonumber(tArgs[2]),254-tonumber(ycord)) | |
254 | end | |
255 | - | -- if fs.exists("custom") then |
255 | + | print ("Position: ",xcord,"/",ycord,"/",zcord," Build height: ",height+ycord) |
256 | - | -- print("custom program detected") |
256 | + | |
257 | - | -- print("please Enter base Station number") |
257 | + | if #tArgs < 3 or #tArgs > 4 then |
258 | - | -- local failFlag = false |
258 | + | |
259 | - | -- repeat |
259 | + | |
260 | - | -- if failFlag then |
260 | + | |
261 | - | -- print("Error Not number") |
261 | + | |
262 | - | -- print("try again") |
262 | + | |
263 | - | -- end |
263 | + | zcord = tonumber(tArgs[3]) |
264 | - | -- write(" > ") |
264 | + | |
265 | - | -- base = tonumber(read()) |
265 | + | height = HEIGHT_DEFAULT-ycord |
266 | - | -- failFlag = true |
266 | + | |
267 | - | -- until type(base) == "number" |
267 | + | height = math.min(tonumber(tArgs[4]),254-ycord) |
268 | - | -- end |
268 | + | |
269 | - | -- print("Please Place 4 computers in slot two") |
269 | + | |
270 | - | -- print("4 modems in slot three") |
270 | + | print ("Parameters set to:") |
271 | - | -- print("if mineing turtle then") |
271 | + | print ("Position: ",xcord,"/",ycord,"/",zcord," Build height: ",height+ycord) |
272 | - | -- print("1 disk drive in slot four") |
272 | + | |
273 | - | -- print("if not mineing then") |
273 | + | |
274 | - | -- print("4 disk drive in slot four") |
274 | + | if not checkFuel() then |
275 | - | -- print("blank floopy disk in slot five") |
275 | + | |
276 | - | -- print("press Enter key to continue") |
276 | + | |
277 | - | -- while true do |
277 | + | |
278 | - | -- local event , key = os.pullEvent("key") |
278 | + | --[[ |
279 | - | -- if key == 28 then break end |
279 | + | Ressource Check: |
280 | - | -- end |
280 | + | check if the required quantity of items |
281 | - | -- print("Launching") |
281 | + | are in the appropriate spots. I'm sure |
282 | - | --end |
282 | + | there's a more elegant way of doing this. |
283 | I don't believe there's a way to check if | |
284 | - | -- check if the required quantity of items |
284 | + | the items are correct without using compare |
285 | - | -- are in the appropriate spots. I'm sure |
285 | + | --]] |
286 | - | -- there's a more elegant way of doing this. |
286 | + | |
287 | - | -- I don't believe there's a way to check if |
287 | + | |
288 | - | -- the items are correct without using compare |
288 | + | |
289 | disk=0 | |
290 | print("") | |
291 | if turtle.getItemCount(2) < 1 then | |
292 | print("Please place 1 disk into slot two") | |
293 | disk=1 | |
294 | - | turtle.select(2) |
294 | + | |
295 | - | if turtle.getItemCount(2) < 4 then |
295 | + | if turtle.getItemCount(3) < 4 then |
296 | - | print("Please place at least 4 computers into slot two") |
296 | + | |
297 | modem=1 | |
298 | end | |
299 | - | turtle.select(3) |
299 | + | if turtle.getItemCount(4) < 1 then |
300 | - | if turtle.getItemCount(2) < 4 then |
300 | + | |
301 | print("Please place 4 disk drives into slot four if a -standard turtle-") | |
302 | diskdrive=1 | |
303 | end | |
304 | - | turtle.select(4) |
304 | + | if turtle.getItemCount(5)+turtle.getItemCount(6)+turtle.getItemCount(7)+turtle.getItemCount(8) < 4 then |
305 | print("Please place at least 4 computers distributed over slots five, six, seven or eight") | |
306 | monitor=1 | |
307 | end | |
308 | ||
309 | if monitor == 1 or modem == 1 or diskdrive == 1 or disk == 1 then | |
310 | - | turtle.select(5) |
310 | + | |
311 | return | |
312 | - | print("Please place 1 disk into slot five") |
312 | + | |
313 | ||
314 | -- calculate the coordinates of the 4 satelite arrays | |
315 | ||
316 | newycord=tonumber(ycord)+tonumber(height) | |
317 | ||
318 | if newycord > 254 then newycord = 254 end | |
319 | ||
320 | toycordns=newycord | |
321 | toycordwe=newycord-3 | |
322 | ||
323 | if toycordns >= 255 or toycordwe >= 255 then | |
324 | toycordns=254 | |
325 | - | if newycord > 255 then newycord = 255 end |
325 | + | toycordwe=251 |
326 | end | |
327 | ||
328 | local set = {} | |
329 | set[1] = {x = tonumber(xcord),z = tonumber(zcord)+9,y = tonumber(toycordns)} | |
330 | set[2] = {x = tonumber(xcord)-9,z = tonumber(zcord),y = tonumber(toycordwe)} | |
331 | - | toycordns=255 |
331 | + | set[3] = {x = tonumber(xcord),z = tonumber(zcord)-9,y = tonumber(toycordns)} |
332 | - | toycordwe=252 |
332 | + | set[4] = {x = tonumber(xcord)+9,z = tonumber(zcord),y = tonumber(toycordwe)} |
333 | ||
334 | -- start the climb up | |
335 | for i = 1,height do | |
336 | - | set[1] = {x = tonumber(xcord),z = tonumber(zcord)+3,y = tonumber(toycordns)} |
336 | + | |
337 | - | set[2] = {x = tonumber(xcord)-3,z = tonumber(zcord),y = tonumber(toycordwe)} |
337 | + | |
338 | - | set[3] = {x = tonumber(xcord),z = tonumber(zcord)-3,y = tonumber(toycordns)} |
338 | + | |
339 | - | set[4] = {x = tonumber(xcord)+3,z = tonumber(zcord),y = tonumber(toycordwe)} |
339 | + | --[[ |
340 | once at the correct height, deploy GPS array | |
341 | - | -- start the climb up to the correct ycord |
341 | + | this is a mixture of my own code and the |
342 | - | while not turtle.up() do |
342 | + | original code |
343 | --]] | |
344 | ||
345 | - | term.write("Please get off me") |
345 | + | |
346 | --forward two | |
347 | - | if ycord+tonumber(height) >= 255 then |
347 | + | for i = 1,8 do |
348 | - | while turtle.up() do -- sends it up till it hits max hight |
348 | + | |
349 | end | |
350 | selectComp() | |
351 | - | for i = 3,tonumber(height) do |
351 | + | |
352 | - | turtle.up() |
352 | + | |
353 | turtle.select(3) | |
354 | mov.place() | |
355 | mov.down() | |
356 | - | -- once at the correct height, deploy GPS array |
356 | + | |
357 | - | -- this is a mixture of my own code and the |
357 | + | |
358 | - | -- original code |
358 | + | |
359 | turtle.select(2) | |
360 | turtle.drop() | |
361 | - | for i = 1,2 do |
361 | + | --[[ |
362 | make a custom disk that starts up the gps host application | |
363 | with the correct coordinates and copy it over. also makes | |
364 | makes it a startup script so the computers will | |
365 | start back up properly after chunk unloading | |
366 | --]] | |
367 | ||
368 | fs.delete("disk/startup") | |
369 | file = fs.open("disk/startup","w") | |
370 | -- KaosK: added shell.run command for labeling Computers | |
371 | file.write([[ | |
372 | shell.run("label", "set", "GPS_Host_]]..a..[[") | |
373 | - | turtle.select(5) |
373 | + | |
374 | fs.delete("disk/startup") | |
375 | - | -- make a custom disk that starts up the gps host application |
375 | + | |
376 | - | -- with the correct coordinates and copy it over. also makes |
376 | + | fs.copy("disk/custom","custom") |
377 | - | -- makes it a startup script so the computers will |
377 | + | fs.delete("disk/custom") |
378 | - | -- start back up properly after chunk unloading |
378 | + | |
379 | print("sleep in 10") | |
380 | sleep(10) | |
381 | os.reboot() | |
382 | ]]) | |
383 | file.close() | |
384 | if fs.exists("custom") then | |
385 | - | fs.copy("disk/custom","custom") |
385 | + | |
386 | - | fs.delete("disk/custom") |
386 | + | |
387 | file = fs.open("disk/install","w") | |
388 | file.write([[ | |
389 | if fs.exists("custom") then | |
390 | shell.run("custom","host",]]..set[a]["x"]..","..set[a]["y"]..","..set[a]["z"]..","..(base or "nil")..[[) | |
391 | else | |
392 | shell.run("id") | |
393 | print("") | |
394 | shell.run("gps","host",]]..set[a]["x"]..","..set[a]["y"]..","..set[a]["z"]..[[) | |
395 | end | |
396 | - | file = fs.open("disk/install","w") |
396 | + | |
397 | - | file.write([[ |
397 | + | |
398 | turtle.turnLeft() | |
399 | - | shell.run("custom","host",]]..set[a]["x"]..","..set[a]["y"]..","..set[a]["z"]..","..(base or "nil")..[[) |
399 | + | |
400 | mov.up() | |
401 | - | shell.run("gps","host",]]..set[a]["x"]..","..set[a]["y"]..","..set[a]["z"]..[[) |
401 | + | |
402 | mov.forward() | |
403 | turtle.turnRight() | |
404 | - | file.close() |
404 | + | |
405 | mov.down() | |
406 | turtle.suck() | |
407 | turtle.select(3) | |
408 | turtle.dig() | |
409 | mov.up() | |
410 | -- reboot would be here | |
411 | turtle.turnRight() | |
412 | --back 3 | |
413 | for i = 1,9 do | |
414 | mov.forward() | |
415 | end | |
416 | turtle.turnLeft() | |
417 | mov.forward() | |
418 | if a == 1 or a == 3 then | |
419 | for i = 1,3 do | |
420 | - | for i = 1,3 do |
420 | + | mov.down() |
421 | end | |
422 | elseif a == 2 or a == 4 then | |
423 | for i = 1,3 do | |
424 | mov.up() | |
425 | end | |
426 | end | |
427 | - | mov.down() |
427 | + | |
428 | ||
429 | ||
430 | -- goes back down | |
431 | - | mov.up() |
431 | + | |
432 | for i = 1,height do | |
433 | mov.down() | |
434 | end | |
435 | print("") | |
436 | - | -- goes back down. this is the original code |
436 | + |