tLoader.lua

740 lines · 22.3 KB

Open raw

{program="tLoader",version="1.10",date="2024-10-22"}

Copy & run

wget https://perlytiara.github.io/turtles.tips/raw/programs/Kaikaku/tLoader.lua
1--{program="tLoader",version="1.10",date="2024-10-22"}
2---------------------------------------
3-- tLoader by Kaikaku
4-- 2024-10-22, v1.10 UI fix
5-- 2021-04-02, v1.01 tClear added
6-- 2021-03-20, v1.00 initial
7-- TUAPv1FU (tLoader)
8---------------------------------------
9
10---------------------------------------
11---- DESCRIPTION ----------------------
12---------------------------------------
13-- Loader program to pastebin get
14-- all the other releazed programs.
15-- If in-program info is insufficient
16-- check out YouTube for more details.
17
18
19---------------------------------------
20---- ASSUMPTIONS ----------------------
21---------------------------------------
22-- Atm mainly meant for turtles
23--
24
25
26---------------------------------------
27---- VARIABLES: template --------------
28---------------------------------------
29local cVersion ="v1.10"
30local cPrgName ="tLoader"
31local cMinFuel =110
32local cSleepTime=0.4
33local cMaxTurns =-1
34local turnCounter =0
35local turnsRemaining =cMaxTurns
36local harvestedStuff=0
37local harvestedStuffTotal=0
38
39local blnAskForParameters =true
40local blnShowUsage =false
41local blnDebugPrint =false
42local blnTurtle
43local isComputer =false
44local baseColor=colors.blue
45
46
47---------------------------------------
48---- VARIABLES: specific --------------
49---------------------------------------
50local blnAll = false
51local blnAllA = false
52local blnAllT = false
53local blnAllB = false
54local blnDelete = false
55local singleProg1 = ""
56local singleProg2 = ""
57local singleProg3 = ""
58local counter = 0
59
60---------------------------------------
61---- Data: specific -------------------
62---------------------------------------
63
64-- id, name, pastebin, applicability[t/c/b]
65local array={}
66array={
67 "a","AESeeds", "stXEtJ6C","t",
68 "a","CabReactor", "knYniUQx","t",
69 "a","EndoFeeder", "bMHsGY06","t",
70 "a","FlowerPot", "EiBtxqUT","t",
71 "a","Harvester", "ZVc6H649","t",
72 "a","MilkPower", "e8bs7VnN","t",
73 "a","TreeFarm", "Qn008fPa","t",
74
75 "b","9x9", "a5nWDnK6","t",
76 "b","Dome", "jEAYUJdZ","t",
77 "b","DonkeySanctuary","Xc98RnqU","t",
78 "b","Door2x3", "BvavMNTW","t",
79 "b","Drone", "A35d84ge","b",
80 "b","Chandelier", "bMky9MzP","t",
81 "b","HalfTimberHouse","hxeZ5Wui","t",
82 "b","Head", "HP3AW3sd","t",
83 "b","Mansion", "PfdurUkb","t",
84 "b","MobFarm", "unPPhDpQ","t",
85 "b","Shuttle", "L1UQ3he3","t",
86 "b","TownHouse", "FHw76UHP","t",
87
88 "t","Clear", "07653J4E","t",
89 "t","Fireworks", "UYm0CCQ7","t",
90 "t","Loader", "TUAPv1FU","b",
91 "t","Platform", "fbyxVzSX","t",
92 "t","Send", "h3xcC9S1","b",
93 "t","WaitFor", "9vzPCd4T","b"}
94
95---------------------------------------
96---- Early UI functions ---------------
97---------------------------------------
98local function swapColors()
99local backColor=term.getBackgroundColor()
100local textColor=term.getTextColor()
101
102term.setBackgroundColor(textColor)
103term.setTextColor(backColor)
104end
105
106local function printUI(strInput)
107if strInput==ni then strInput="" end
108
109 if strInput=="header" then
110 term.write("+-------------------------------------") print("+")
111 elseif strInput=="line" then
112 term.write("+-------------------------------------") print("+")
113 elseif strInput=="footer" then
114 term.write("+-------------------------------------") print("+")
115 else
116 term.write("|")
117 strInput=strInput.." "
118 term.write(string.sub(strInput,1,37))
119 print("|")
120 end
121end
122
123local function coloredTextAt(inputText,outputRow,outputCol,textColor,backColor)
124-- writes and colors text to coordinates
125local oldRow, oldCol = term.getCursorPos()
126local oldTextColor=term.getTextColor()
127local oldBackColor=term.getBackgroundColor()
128if textColor==nil then textColor=term.getTextColor() end
129if backColor==nil then backColor=term.getBackgroundColor() end
130
131 term.setTextColor(textColor)
132 term.setBackgroundColor(backColor)
133 term.setCursorPos(outputRow,outputCol)
134 term.write(inputText)
135 term.setCursorPos(oldRow, oldCol)
136 term.setTextColor(oldTextColor)
137 term.setBackgroundColor(oldBackColor)
138end
139
140---------------------------------------
141---- tArgs ----------------------------
142---------------------------------------
143local tArgs = {...}
144term.clear() term.setCursorPos(1,1)
145
146-- header
147if #tArgs~=0 then
148 blnAskForParameters=false
149 term.clear() term.setCursorPos(1,1)
150 printUI("header")
151 printUI(""..cPrgName..", "..cVersion..", by Kaikaku. Enjoy!")
152 printUI("line")
153 coloredTextAt(cPrgName,2,2,baseColor)
154 print("Starting...")
155end
156
157for t=1,#tArgs do
158 if string.lower(tArgs[t])=="all" then
159 blnAll=true
160 elseif string.lower(tArgs[t])=="a" then
161 blnAllA=true
162 elseif string.lower(tArgs[t])=="t" then
163 blnAllT=true
164 elseif string.lower(tArgs[t])=="b" then
165 blnAllB=true
166 elseif string.lower(tArgs[t])=="del" then
167 blnDelete=true
168 elseif string.lower(tArgs[t])=="delte" then
169 blnDelete=true
170 elseif singleProg1=="" then
171 singleProg1 = tArgs[t]
172 elseif singleProg2=="" then
173 singleProg2 = tArgs[t]
174 else
175 singleProg3 = tArgs[t]
176 end
177end
178
179
180---------------------------------------
181-- basic functions for turtle control -
182---------------------------------------
183
184local function spd(s,blnForward)
185 if s==nil then s=turtle.currentSlot() end
186 if blnForward==nil then blnForward=true end
187 ss(s) pd() if blnForward then gf() end
188end
189local function spu(s,blnForward)
190 if s==nil then s=turtle.currentSlot() end
191 if blnForward==nil then blnForward=true end
192 ss(s) pu() if blnForward then gf() end
193end
194local function spf(s,blnBack)
195 if s==nil then s=turtle.currentSlot() end
196 if blnBack==nil then blnBack=true end
197 ss(s) pf() if blnBack then gb() end
198end
199
200local function waitKey(strText)
201 local event, scancode
202 write(strText)
203 event, scancode = os.pullEvent("key")
204 print()
205end
206
207local function askForInputText(textt)
208 local at=""
209 -- check prompting texts
210 if textt==nil then textt="Enter text:" end
211
212 -- ask for input
213 write(textt)
214 at=read()
215 return at
216end
217
218local function askForNumber(askText, minValue, maxValue)
219-- gets entered data, ensures it's a number and returns it
220-- keeps asking if entry is not a number
221-- adapts to min and max values
222-- allways writes in screen line 13 (last for turtles)
223-- calls askForInputText
224local blnReask=true
225local returnNumber=nil
226if minValue==nil then minValur=1 end
227if maxValue==nil then maxValue=100 end
228if askText==nil then askText="Key in number and press Enter: " end
229 while blnReask do
230 term.setCursorPos(1,13)
231 returnNumber=askForInputText(askText)
232 if returnNumber==nil then
233 blnReask=true
234 else
235 returnNumber=tonumber(returnNumber)
236 if returnNumber==nil then
237 blnReask=true
238 else
239 returnNumber=math.floor(returnNumber)
240 if returnNumber>maxValue then returnNumber=maxValue end
241 if returnNumber<minValue then returnNumber=minValue end
242 blnReask=false
243 end
244 end
245 end
246 return returnNumber
247end
248
249local function pressKeyNoSpecials(askText)
250-- excludes ctrl / alt / shifts
251-- catches windows
252-- retruns the key number (if needed at all)
253local tmpEvent, tmpKey
254if askText==nil then askText="Press key to START! (stop w/ ctrl+t) " end
255 tmpKey=341
256 while tmpKey>=340 and tmpKey<=346 do -- ctrls, alts, shifts
257 term.write(askText) tmpEvent, tmpKey = os.pullEvent("key")
258 if tmpKey==nil then tmpKey=341 end -- win
259 end
260 return tmpKey
261end
262
263local function checkFuel()
264 local tmp=turtle.getFuelLevel()
265 return tmp
266end
267
268local function checkTurtle(blnOnlyIdentify)
269if blnOnlyIdentify==nil then blnOnlyIdentify=false end
270-- turtle?
271 local turtleOk, turtleVal = pcall(checkFuel)
272 if not turtleOk then
273 blnTurtle=false
274 if not blnOnlyIdentify then
275 term.clear() term.setCursorPos(1,1)
276 printUI("header")
277 printUI(""..cPrgName..", "..cVersion..", by Kaikaku ("..iPage.."/"..iPageMax..")")
278 printUI("line")
279 printUI("This is a turtle program.")
280 printUI(" Please, execute it with a turtle!")
281 printUI("footer")
282
283 coloredTextAt(cPrgName,2,2,colors.red)
284 error()
285 end
286 else
287 blnTurtle=true
288 end
289end
290
291local function sleepDots(sec, duration)
292if sec==nil then sec=10 end
293if sec<1 then return end
294if duration==nil then duration=1 end -- shorten durtation for more dots
295
296 for i=1,sec-1 do
297 sleep(1*duration)
298 term.write(".")
299 end
300
301 sleep(1)
302 print(".")
303end
304
305local function debugPrint(str)
306 if blnDebugPrint then print(str) end
307end
308
309local function inspectFor(blockArray, strDirection)
310if strDirection==nil then strDirection="f" end
311local blnOk, data
312
313 -- inspect
314 if strDirection=="d" then blnOk, data = turtle.inspectDown()
315 elseif strDirection=="u" then blnOk, data = turtle.inspectUp()
316 elseif strDirection=="f" then blnOk, data = turtle.inspect()
317 else
318 print("Warning: Unknown direction '",strDirection,"' in inspectFor, taking (f)orward instead.")
319 strDirection="f"
320 blnOk, data = turtle.inspect()
321 end
322 if data.name~=nil then debugPrint("Found:"..string.lower(data.name)) end
323 -- compare
324 local i=1
325 while blockArray[i]~=nil do
326 debugPrint("Compare to:"..string.lower(blockArray[i]))
327 if data.name~=nil then
328 if string.lower(data.name) == string.lower(blockArray[i]) then return true end
329 end
330 i=i+1
331 end
332
333 return false -- reached a nil value
334end
335
336local function handleReport()
337 print(" Harvested items this turn: "..harvestedStuff)
338 harvestedStuffTotal=harvestedStuffTotal+harvestedStuff
339 harvestedStuff=0
340 print(" Harvested items total: "..harvestedStuffTotal)
341end
342
343local function handleTurnCounter()
344-- return true if cMaxTurns is reached, else false
345 handleReport()
346 if turnsRemaining==0 then return true end
347 turnCounter=turnCounter+1
348 if cMaxTurns>=0 then
349 turnsRemaining=turnsRemaining-1
350 term.write("Turn "..turnCounter.."/"..cMaxTurns..":")
351 else
352 term.write("Turn "..turnCounter..":")
353 end
354 return false
355end
356
357
358local function getFirstEmptySlot(startAt)
359if startAt==nil then startAt=1 end
360if startAt>16 or startAt<1 then return nil end
361
362 for i=startAt,16,1 do
363 if gic(i)==0 then return i end
364 end
365 for i=1,startAt,1 do
366 if gic(i)==0 then return i end
367 end
368 return nil
369end
370
371local function identifyTool(toolSide)
372-- returns name of tool at side toolSide
373-- returns no_tool if there is none
374-- requires at least one empty slot for tool check (throws error)
375if toolSide==nil then toolSide="right" end
376if toolSide~="right" and toolSide~="r" then toolSide="left" end
377local slotNumber = getFirstEmptySlot()
378local slotSelected=turtle.getSelectedSlot()
379local toolName="no_tool"
380
381 if slotNumber==nil then error("Couldn't find empty slot to check tool on side '"..toolSide.."'!") end
382 ss(slotNumber)
383 -- step 1: get name
384 if toolSide=="right" or toolSide=="r" then
385 turtle.equipRight()
386 else
387 turtle.equipLeft()
388 end
389 -- step 2: get name
390 local data = turtle.getItemDetail()
391 if data~=nil then toolName=data.name end
392 -- step 3: re-equipget name
393 if toolSide=="right" or toolSide=="r" then
394 turtle.equipRight()
395 else
396 turtle.equipLeft()
397 end
398 ss(slotSelected)
399 return toolName
400end
401
402
403-- pre description ------------------------
404local function arrangeArray(inputArray, startAt, endAt, widthAt, maxRows, maxCharacters, numSpacers)
405-- prints array in two columns
406if widthAt==nil then widthAt=4 end -- how many array itmes belong to one "object"
407if widthAt<1 then widthAt=4 end
408if startAt==nil then startAt=1 end -- start with this "object"
409if startAt<1 then startAt=1 end
410if endAt==nil then endAt=#inputArray/widthAt end -- end at this "object"
411if endAt>#inputArray*widthAt then endAt=#inputArray/widthAt end
412if maxRows==nil then maxRows=10 end -- so many rows to display
413if maxRows<1 then maxRows=5 end
414if maxCharacters==nil then maxCharacters=19 end -- so many chars in one column (rest is cut off)
415if maxCharacters<1 then maxCharacters=19 end
416local fillerA=" "--"-"
417if numSpacers==nil then numSpacers=0 end -- so many spaces between both columns
418if numSpacers<1 then numSpacers=0 end
419local fillerB=" "--"x"
420
421local outputArray={}
422local j=1
423local tmpString=""
424local tmpSpaces=""
425local tmpSpacer=""
426
427 for i=1,maxCharacters,1 do
428 tmpSpaces=tmpSpaces..fillerA
429 end
430 for i=1,numSpacers,1 do
431 tmpSpacer=tmpSpacer..fillerB
432 end
433
434 for i=startAt*widthAt-(widthAt-1),endAt*widthAt,widthAt do
435
436 --print(inputArray[i]..inputArray[i+1])
437 tmpString=inputArray[i]..inputArray[i+1]..tmpSpaces
438 tmpString=string.sub(tmpString,1,maxCharacters)
439 if outputArray[j]==nil then outputArray[j]="" tmpString=tmpString..tmpSpacer end
440 outputArray[j]=outputArray[j]..tmpString
441 j=j+1
442 if j>maxRows then j=1 end
443 end
444
445 return outputArray
446end
447
448local function printArray(iArray)
449 for i=1,#iArray,1 do
450 term.write(i)
451 if iArray[i]~=nil then print(iArray[i]) else print() end
452 end
453
454end
455
456local function countProgramTypes()
457local countA=0
458local countB=0
459local countT=0
460
461 for i=1,#array,4 do
462 if array[i]=="a" then
463 countA=countA+1
464 elseif array[i]=="b" then
465 countB=countB+1
466 elseif array[i]=="t" then
467 countT=countT+1
468 end
469 end
470 return countA,countB,countT,countA+countB+countT
471
472end
473
474
475
476------------------------------------------------------------------------------
477-- main: description ---------------------------------------------------------
478------------------------------------------------------------------------------
479checkTurtle(true)
480
481local iPage=0
482if blnAskForParameters then
483term.clear() term.setCursorPos(1,1)
484local iPageMax=3
485local event, key, isHeld
486local blnLoop=true
487
488term.clear() term.setCursorPos(1,1) iPage=iPage+1
489printUI("header")
490printUI(""..cPrgName..", "..cVersion..", by Kaikaku ("..iPage.."/"..iPageMax.."+)")
491printUI("line")
492-- 1234567890123456789012345678901234567
493printUI("This program can load all other")
494printUI(" programs released by Kaikaku.")
495printUI("No need to remember any other")
496printUI(" pastebin codes than: TUAPv1FU")
497printUI("You can select single programs")
498printUI(" or groups of programs (e.g. all")
499printUI(" builder programs). Or load by ")
500printUI(" paramter call: tLoader bDrone")
501printUI("footer")
502
503coloredTextAt(cPrgName,2,2,baseColor)
504coloredTextAt("TUAPv1FU",25,7,baseColor)
505coloredTextAt("tLoader bDrone",19,11,baseColor)
506pressKeyNoSpecials("Press key for next (stop w/ ctrl+t) ")
507
508
509
510term.clear() term.setCursorPos(1,1) iPage=iPage+1
511printUI("header")
512printUI(""..cPrgName..", "..cVersion..", by Kaikaku ("..iPage.."/"..iPageMax.."+)")
513printUI("line")
514-- 1234567890123456789012345678901234567
515printUI("How to remember TUAPv1FU?")
516printUI(" T = To It took ")
517printUI(" U = YOU quite a ")
518printUI(" A = All while ")
519printUI(" P = Programs and a ")
520printUI(" v = version temp ban")
521printUI(" 1 = one to get ")
522printUI(" FU = FU**?! this  ")
523-- 1234567890123456789012345678901234567
524printUI("footer")
525
526coloredTextAt(cPrgName,2,2,baseColor)
527coloredTextAt("TUAPv1FU",18,4,baseColor)
528coloredTextAt("T",4,5,baseColor) coloredTextAt("T",9,5,baseColor)
529coloredTextAt("U",4,6,baseColor) coloredTextAt("YOU",9,6,baseColor)
530coloredTextAt("A",4,7,baseColor) coloredTextAt("A",9,7,baseColor)
531coloredTextAt("P",4,8,baseColor) coloredTextAt("P",9,8,baseColor)
532coloredTextAt("v",4,9,baseColor) coloredTextAt("v",9,9,baseColor)
533coloredTextAt("1",4,10,baseColor) coloredTextAt("one",9,10,baseColor)
534coloredTextAt("FU",4,11,baseColor) coloredTextAt("FU",9,11,baseColor)
535
536
537pressKeyNoSpecials("Press key for next (stop w/ ctrl+t) ")
538
539
540term.clear() term.setCursorPos(1,1) iPage=iPage+1
541local aa,bb,tt,ss = countProgramTypes()
542printUI("header")
543printUI(""..cPrgName..", "..cVersion..", by Kaikaku ("..iPage.."/"..iPageMax.."+)")
544printUI("line")
545-- 1234567890123456789012345678901234567
546printUI("Select load mode:")
547printUI(" 1 = select one from list (1)")
548printUI(" 2 = all automation programs ("..aa..")")
549printUI(" 3 = all building programs ("..bb..")")
550printUI(" 4 = all tool programs ("..tt..")")
551printUI(" 5 = all programs ("..(#array/4)..")")
552printUI(" ")
553printUI(" d = delete old programs (off)")
554printUI("footer")
555term.write("Press key 1,2,3,4,5 to select mode")
556
557coloredTextAt(cPrgName,2,2,baseColor)
558coloredTextAt("Select load mode",2,4,baseColor)
559coloredTextAt("1",4,5,baseColor) coloredTextAt("list", 24,5,baseColor)
560coloredTextAt("2",4,6,baseColor) coloredTextAt("a", 12,6,colors.green)
561coloredTextAt("3",4,7,baseColor) coloredTextAt("b", 12,7,colors.red)
562coloredTextAt("4",4,8,baseColor) coloredTextAt("t", 12,8,baseColor)
563coloredTextAt("5",4,9,baseColor) coloredTextAt("all", 8,9,baseColor)
564coloredTextAt("d",4,11,baseColor) coloredTextAt("(off)",28,11,baseColor)
565
566while blnLoop do -- option selection example --<< example to check for 1,2,3,4
567 event, key, isHeld = os.pullEvent("key")
568 if key~=nil then
569 if keys.getName(key)=="one"
570 or keys.getName(key)=="two"
571 or keys.getName(key)=="three"
572 or keys.getName(key)=="four"
573 or keys.getName(key)=="five" then
574 blnLoop=false
575 elseif keys.getName(key)=="d" then
576 if blnDelete then
577 blnDelete=false
578 coloredTextAt("(off)",28,11,baseColor)
579 else
580 blnDelete=true
581 coloredTextAt("(on) ",28,11,baseColor)
582 end
583 end
584 end
585end
586
587if keys.getName(key)=="two" then blnAllA=true
588elseif keys.getName(key)=="three" then blnAllB=true
589elseif keys.getName(key)=="four" then blnAllT=true
590elseif keys.getName(key)=="five" then blnAll=true
591end
592
593if keys.getName(key)=="one" then
594local cRowCount=8
595local iNumber
596local iNumberLast
597local blnSelectionDone=false
598
599--local function arrangeArray(inputArray, startAt, endAt, widthAt, maxRows, maxCharacters, numSpacers)
600 local testArray = arrangeArray(array,1,nil,4,#array/4,16,1)
601 local numberPages = math.ceil(#testArray/cRowCount)
602 iPageMax=iPageMax+numberPages
603 for j=1,#array/4,cRowCount do
604 term.clear() term.setCursorPos(1,1) iPage=iPage+1
605 printUI("header")
606 printUI(""..cPrgName..", "..cVersion..", by Kaikaku ("..iPage.."/"..iPageMax..")")
607 printUI("line")
608 coloredTextAt(cPrgName,2,2,baseColor)
609
610 iNumber=1
611 iNumberLast=1
612 for i=j,j+cRowCount-1,1 do
613
614 if testArray[i]~= nil then
615 printUI(" "..iNumber.." = "..testArray[i])
616 coloredTextAt(iNumber,4,3+iNumber,baseColor)
617 if string.sub(testArray[i],1,1)=="a" then coloredTextAt("a" ,8,3+iNumber,colors.green)
618 elseif string.sub(testArray[i],1,1)=="b" then coloredTextAt("b" ,8,3+iNumber,colors.red)
619 elseif string.sub(testArray[i],1,1)=="t" then coloredTextAt("t" ,8,3+iNumber,colors.blue)
620 end
621 iNumberLast=iNumberLast+1
622 else
623 printUI()
624 end
625 iNumber=iNumber+1
626 end
627 printUI("footer")
628 if iPage<iPageMax then
629 term.write("Select program (1-"..(iNumberLast-1).."), other key = next ")
630 else
631 term.write("Select program (1-"..(iNumberLast-1).."), other key = EXIT ")
632 end
633
634 blnLoop=true
635 local iArray
636 while blnLoop do
637 event, key, isHeld = os.pullEvent("key")
638 if key~=nil then
639 if keys.getName(key)=="one" and iNumberLast>1 then
640 iArray=1
641 iArray=iArray+(iPage-3-1)*4*cRowCount
642 singleProg1=array[iArray]..array[iArray+1]
643 blnSelectionDone=true
644 elseif keys.getName(key)=="two" and iNumberLast>2 then
645 iArray=1+1*4
646 iArray=iArray+(iPage-3-1)*4*cRowCount
647 singleProg1=array[iArray]..array[iArray+1]
648 blnSelectionDone=true
649 elseif keys.getName(key)=="three" and iNumberLast>3 then
650 iArray=1+2*4
651 iArray=iArray+(iPage-3-1)*4*cRowCount
652 singleProg1=array[iArray]..array[iArray+1]
653 blnSelectionDone=true
654 elseif keys.getName(key)=="four" and iNumberLast>4 then
655 iArray=1+3*4
656 iArray=iArray+(iPage-3-1)*4*cRowCount
657 singleProg1=array[iArray]..array[iArray+1]
658 blnSelectionDone=true
659 elseif keys.getName(key)=="five" and iNumberLast>5 then
660 iArray=1+4*4
661 iArray=iArray+(iPage-3-1)*4*cRowCount
662 singleProg1=array[iArray]..array[iArray+1]
663 blnSelectionDone=true
664 elseif keys.getName(key)=="six" and iNumberLast>6 then
665 iArray=1+5*4
666 iArray=iArray+(iPage-3-1)*4*cRowCount
667 singleProg1=array[iArray]..array[iArray+1]
668 blnSelectionDone=true
669 elseif keys.getName(key)=="seven" and iNumberLast>7 then
670 iArray=1+6*4
671 iArray=iArray+(iPage-3-1)*4*cRowCount
672 singleProg1=array[iArray]..array[iArray+1]
673 blnSelectionDone=true
674 elseif keys.getName(key)=="eight" and iNumberLast>8 then
675 iArray=1+7*4
676 iArray=iArray+(iPage-3-1)*4*cRowCount
677 singleProg1=array[iArray]..array[iArray+1]
678 blnSelectionDone=true
679 end
680 blnLoop=false
681 end
682 end
683 if blnSelectionDone then break end
684 end
685end
686end
687
688
689---------------------------------------
690---- MAIN -----------------------------
691---------------------------------------
692term.clear() term.setCursorPos(1,1)
693
694---- step 1: pastebin get ----
695print("step 1: pastebin get...")
696local i=1
697
698while array[i]~=nil do
699 if blnAll
700 or (blnAllA and array[i]=="a")
701 or (blnAllT and array[i]=="t")
702 or (blnAllB and array[i]=="b")
703 or string.lower(singleProg1)==string.lower(array[i]..array[i+1])
704 or string.lower(singleProg2)==string.lower(array[i]..array[i+1])
705 or string.lower(singleProg3)==string.lower(array[i]..array[i+1]) then
706 print("-- "..array[i]..array[i+1].." --")
707 if blnDelete then
708 print("Deleting current version")
709 shell.run("delete "..array[i]..array[i+1])
710 end
711 print(shell.run("pastebin get "..array[i+2].." "..array[i]..array[i+1]))
712 counter=counter+1
713 sleep(cSleepTime)
714 end
715 i=i+4
716end
717
718if counter~=0 then
719 sleepDots(6,0.2)
720 ---- step 2: finishing stuff / report ----
721 term.clear() term.setCursorPos(1,1)
722 print("step 2: report")
723 if counter==1 then
724 print("1 program downloaded/updated/tried :)")
725 else
726 print(counter.." programs downloaded/updated/tried :)")
727 end
728end
729
730print()
731printUI("header")
732 --1234567890123456789012345678901234567
733printUI("If in-program info is insufficient,")
734printUI("you can check out YouTube for further")
735printUI("explanations. Just search for the")
736printUI("program name and ComputerCraft.")
737printUI("Enjoy! Kaikaku ")
738coloredTextAt("Kaikaku",9,9,baseColor)
739printUI("footer")
740