Kaikaku

buildHead

Nov 23rd, 2013
1,586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.94 KB | None | 0 0
  1. --{program="bHead",version="1.00",date="2013-12-07",basicFunc="1.11",basicFuncDate="2013-12-07",addFunc="1.00"",addFuncDate="2013-12-07"}
  2. ---------------------------------------
  3. -- buildHead           by Kaikaku
  4. -- 2013-12-07, v1.00   initial
  5. ---------------------------------------
  6. -- basic functions: v1.11, 2013-12-07
  7. -- additional func: v1.00, 2013-12-07
  8. ---------------------------------------
  9.  
  10. ---------------------------------------
  11. ---- PARAMETERS -----------------------
  12. ---------------------------------------
  13. local cSleepTime=10
  14. local cMinFuel=80
  15. local dispLine ="+-------------------------------------+"
  16. local dispEmpty="|                                     |"
  17.  
  18. local tColors={}
  19. tColors[1] ="white " tColors[2] ="orange" tColors[3] ="magent" tColors[4] ="lBlue"
  20. tColors[5] ="yellow" tColors[6] ="lime  " tColors[7] ="pink  " tColors[8] ="grey "
  21. tColors[9] ="lGrey " tColors[10]="cyan  " tColors[11]="purple" tColors[12]="blue "
  22. tColors[13]="brown " tColors[14]="green " tColors[15]="red   " tColors[16]="black"
  23.  
  24. ---------------------------------------
  25. ---- VARIABLES ------------------------
  26. ---------------------------------------
  27. local inputMode = "h" --"v"
  28. local inputHead = 1
  29. local strHead=""
  30. local pat = {}
  31. local blnDone=false
  32.  
  33. local countMats={}
  34. for i=1,16,1 do countMats[i]="  " end
  35. local strMessage=""
  36. local strInput=""
  37.  
  38. local currentSlot=1
  39.  
  40. local blnAskForParameters=true
  41.  
  42. ---------------------------------------
  43. ---- tArgs ----------------------------
  44. ---------------------------------------
  45. local tArgs = {...}
  46. if #tArgs == 2 then -- no error check
  47.   blnAskForParameters=false
  48.   userA=tArgs[1]
  49.   if userA~="v" then userA="h" end
  50.   userB=tonumber(tArgs[2])
  51. elseif #tArgs ~= 0 then
  52.   print("Usage: buildHead [(v/h) (head number)]")  
  53.   return
  54. end
  55.  
  56. ---------------------------------------
  57. -- basic functions for turtle control -
  58. ---------------------------------------
  59. local function mats() -- without changing slots
  60.   while turtle.getItemCount(currentSlot)==0 do
  61.     print("Out of materials, pls restock slot "..currentSlot.."!")
  62.     print("  Sleeping for "..cSleepTime.." sec ...")
  63.     os.sleep(cSleepTime)
  64.   end
  65. end
  66.  
  67. local function gf()  while not turtle.forward()   do end end
  68. local function gb()  while not turtle.back()      do end end
  69. local function gu()  while not turtle.up()        do end end
  70. local function gd()  while not turtle.down()      do end end
  71. local function gl()  while not turtle.turnLeft()  do end end
  72. local function gr()  while not turtle.turnRight() do end end
  73. local function df()  turtle.dig()       end
  74. local function du()  turtle.digUp()     end
  75. local function dd()  turtle.digDown()   end
  76. local function pf()  mats() while not turtle.place()     do end end
  77. local function pu()  mats() while not turtle.placeUp()   do end end
  78. local function pd()  mats() while not turtle.placeDown() do end end
  79. local function sf()  turtle.suck()      end
  80. local function su()  turtle.suckUp()    end
  81. local function sd()  turtle.suckDown()  end
  82. local function Df()  turtle.drop()      end
  83. local function Du()  turtle.dropUp()    end
  84. local function Dd()  turtle.dropDown()  end
  85. local function ss(s) turtle.select(s) currentSlot=s  end
  86.  
  87. local function tp(slot) gb() ss(slot) pf() end
  88. local function tu(slot) gu() ss(slot) pd() end
  89. local function td(slot) gd() ss(slot) pu() end
  90.  
  91. local function waitKey(strText)
  92.   local event, scancode
  93.   write(strText)
  94.   event, scancode = os.pullEvent("key")
  95.   print()
  96. end
  97.  
  98. local function checkFuel()
  99.   local tmp=turtle.getFuelLevel()
  100.   return tmp
  101. end
  102.  
  103. ---------------------------------------
  104. -- additional functions ---------------
  105. ---------------------------------------
  106. local function askForInputText(textt)
  107.   local at=""
  108.   -- check prompting texts
  109.   if textt==nil then textt="Enter text:" end
  110.  
  111.   -- ask for input
  112.   write(textt)
  113.   at=read()
  114.   return at
  115. end
  116.  
  117. local function colorIf(intColor)
  118.   local tmpStr="["..countMats[intColor].."]"
  119.   if countMats[intColor]=="  " then
  120.     if (intColor==4) or (intColor==8) or (intColor==12) or (intColor==16) then
  121.       tmpStr=tmpStr.."     "
  122.     else
  123.       tmpStr=tmpStr.."      "
  124.     end
  125.   else
  126.     tmpStr=tmpStr..tColors[intColor]
  127.   end
  128.   return tmpStr
  129. end
  130.  
  131. ------------------------------------------------------------------------------
  132. -- main ----------------------------------------------------------------------
  133. ------------------------------------------------------------------------------
  134.  
  135. -- step 0 check preconditions
  136. term.clear() term.setCursorPos(1,1)
  137. -- step 0.1 turtle?
  138. local turtleOk, turtleVal = pcall(checkFuel)
  139. if not turtleOk then
  140. print(dispLine)
  141. print("| buildHead, by Kaikaku               |")
  142. print(dispLine)
  143. print("| This is a turtle build program.     |")
  144. print("| Please, execute it with a turtle!   |")
  145. print(dispLine)
  146. return
  147. end
  148.  
  149. -- step 0.2 fuel?
  150. if turtleVal<cMinFuel then
  151. print(dispLine)
  152. print("| buildHead, by Kaikaku               |")
  153. print(dispLine)
  154. print("| Please refuel turtle, it needs a    |")
  155. print("| minimum of ",cMinFuel," fuel units.       |")
  156. print("| Tip: Put some fuel (e.g. coal) in   |")
  157. print("|      slot 1 and enter: refuel all.  |")
  158. print("|      This will consume all(!) fuel  |")
  159. print("|      items in the turtle's inventory|")
  160. print(dispLine)
  161. return
  162. end
  163.  
  164. -- step 1 usage hints
  165. term.clear() term.setCursorPos(1,1)
  166. if blnAskForParameters then
  167. repeat
  168. print(dispLine)
  169. print("| buildHead, by Kaikaku               |")
  170. print(dispLine)
  171. print("| With this turtle program you can    |")
  172. print("| build different 8x8 heads.          |")
  173. print("| 1) select mode: horizontal/vertical |")
  174. print("| 2) select a head                    |")
  175. print("| 3) put in required materials        |")
  176. print("| 4) watch the turtle build :)        |")
  177. print("| hint: turtle stops if sth. blocks   |")
  178. print("|    its way or runs out of materials.|")
  179. print(dispLine)
  180. until askForInputText("Press enter when ready:")==""
  181. end
  182.  
  183. -- step 2 select vertical/horizontal
  184. if blnAskForParameters then
  185. repeat
  186. print(dispLine)
  187. print("| Please select mode:                 |")
  188. print(dispLine)
  189. print("| [h] horizontal build                |")
  190. print("| [v] vertical   build                |")
  191. print(dispEmpty) print(dispEmpty) print(dispEmpty)
  192. print(dispEmpty) print(dispEmpty) print(dispEmpty)
  193. print(dispLine)
  194.   inputMode=(askForInputText("Enter v or h:"))
  195. until inputMode=="h" or inputMode=="v" or inputMode==" h" or inputMode==" v"
  196. else
  197. inputMode=userA
  198. end
  199.  
  200. -- step 3 select head and show mats required
  201. repeat
  202. blnDone=true
  203. if blnAskForParameters then
  204.   print(dispLine)
  205.   print("| Please select head:                 |")
  206.   print(dispLine)
  207.   print("| [1] creeper          [9] pig        |")
  208.   print("| [2] zombie          [10] sheep      |")
  209.   print("| [3] skeleton        [11] cow        |")
  210.   print("| [4] wither skeleton [12] mooshroom  |")
  211.   print("| [5] ender man       [13] octopus    |")
  212.   print("| [6] spider          [14] z.pigman   |")
  213.   print("| [7] ghast           [15] snow golem |")
  214.   print("| [8] slime           [16] iron golem |")
  215.   print(dispLine)
  216.   tmpHead=tonumber(askForInputText("Enter head number:"))
  217. else
  218.   tmpHead=userB
  219.   --print("User selected head "..tmpHead)
  220. end
  221.  
  222.   if tmpHead==1 then
  223.     strHead="Creeper"
  224.     pat={6,6,6,6,6,6,6,6,6,6,6,6,16,16,6,6,16,16,6,6,16,16,6,6,6,16,16,6,6,6,6,6,6,16,16,6,6,6,6,6,16,16,6,6,16,16,6,6,6,6,6,6,16,16,6,6,6,6,6,6,6,6,6,6}
  225.     countMats[6] ="48" -- lime
  226.     countMats[16]="16" -- black
  227.   elseif tmpHead==2 then
  228.     strHead="Zombie"
  229.     pat={14,14,14,14,14,14,14,14,14,14,14,16,14,14,14,14,14,14,14,16,14,14,14,14,14,14, 8,14,14,14,14,14,14,14, 8,14,14,14,14,14,14,14,14,16,14,14,14,14,14,14,14,16,14,14,14,14,14,14,14,14,14,14,14,14}
  230.     countMats[8] =" 2" -- grey
  231.     countMats[14]="58" -- green
  232.     countMats[16]=" 4" -- black
  233.   elseif tmpHead==3 then
  234.     strHead="Skeleton"
  235.     pat={9,9,9,9,9,9,9,9,9,8,9,8,9,9,9,9,9,8,9,8,9,9,9,9,9,8,9,9,9,9,9,9,9,8,9,9,9,9,9,9,9,8,9,8,9,9,9,9,9,8,9,8,9,9,9,9,9,9,9,9,9,9,9,9}
  236.     countMats[8] ="10" -- grey
  237.     countMats[9] ="54" -- light grey
  238.   elseif tmpHead==4 then
  239.     strHead="Wither skeleton"
  240.     pat={8,8,8,8,8,8,8,8,8,8,8,16,8,8,8,8,8,16,8,16,8,8,8,8,8,16,8,8,8,8,8,8,8,16,8,8,8,8,8,8,8,16,8,16,8,8,8,8,8,8,8,16,8,8,8,8,8,8,8,8,8,8,8,8}
  241.     countMats[8] ="56" -- grey
  242.     countMats[16]=" 8" -- black
  243.   elseif tmpHead==5 then
  244.     strHead="Ender man"
  245.     pat={16,16,16, 7,16,16,16,16,16,16,16, 3,16,16,16,16,16,16,16, 7,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 7,16,16,16,16,16,16,16, 3,16,16,16,16,16,16,16, 7,16,16,16,16}
  246.     countMats[3] =" 2" -- magenta
  247.     countMats[7] =" 4" -- pink
  248.     countMats[16]="58" -- black
  249.   elseif tmpHead==6 then
  250.     strHead="Spider"
  251.     pat={16,16, 8, 8,13,15, 8, 8, 8,16,16, 8,13,13, 8,16, 9, 9, 8,13,15, 8,16, 8,16,16, 8,13,13, 8, 8, 8, 8, 8, 8,13,15, 8, 8, 8, 9, 9, 8,13,13, 8,16, 8, 8,16,16, 8,13,15, 8,16,16,16, 9, 8,13,13, 8, 8}
  252.     countMats[8] ="29" -- grey
  253.     countMats[9] =" 5" -- light grey
  254.     countMats[13]="12" -- brown
  255.     countMats[15]=" 4" -- red
  256.     countMats[16]="14" -- black
  257.   elseif tmpHead==7 then
  258.     strHead="Ghast"
  259.     pat={ 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 9, 1, 8, 9, 1, 1, 8, 1, 1, 9, 8, 1, 9, 1, 8, 1, 1, 1, 9, 1, 1, 1, 8, 1, 1, 1, 9, 1, 1, 1, 8, 1, 1, 9, 8, 1, 9, 1, 9, 1, 9, 9, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  260.     countMats[1] ="43" -- white
  261.     countMats[8] =" 4" -- grey
  262.     countMats[9] ="13" -- light grey
  263.   elseif tmpHead==8 then
  264.     strHead="Slime"
  265.     pat={6,6,6,14,6,6,6,6,6,14,14,14,16,16,14,6,6,14,14,14,16,16,14,6,14,14,14,14,14,14,14,14,6,14,16,14,14,14,14,6,6,14,14,14,16,16,14,6,6,14,14,14,16,16,14,6,6,6,14,6,6,6,6,6}
  266.     countMats[6] ="24" -- lime
  267.     countMats[14]="31" -- green
  268.     countMats[16]=" 9" -- black
  269.   elseif tmpHead==9 then
  270.     strHead="Pig"
  271.     pat={ 7, 7, 7, 7,16, 7, 7, 7, 7, 7, 7, 7, 1, 7, 7, 7, 7, 9, 8, 9, 7, 7, 7, 7, 7, 9, 7, 9, 7, 7, 7, 7, 7, 9, 7, 9, 7, 7, 7, 7, 7, 9, 8, 9, 7, 7, 7, 7, 7, 7, 7, 7, 1, 7, 7, 7, 7, 7, 7, 7,16, 7, 7, 7}
  272.     countMats[1] =" 2" -- white
  273.     countMats[7] ="50" -- pink
  274.     countMats[8] =" 2" -- grey
  275.     countMats[9] =" 8" -- light grey
  276.     countMats[16]=" 2" -- black
  277.   elseif tmpHead==10 then
  278.     strHead="Sheep"
  279.     pat={ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,16, 8, 9, 9, 9, 8, 8, 8, 1, 8, 9, 9, 9, 8, 7, 8, 8, 8, 9, 9, 9, 8, 7, 8, 8, 8, 9, 9, 9, 8, 8, 8, 1, 8, 9, 9, 9, 9, 9, 8,16, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}
  280.     countMats[1] =" 2" -- white
  281.     countMats[7] =" 2" -- pink
  282.     countMats[8] ="20" -- grey
  283.     countMats[9] ="38" -- light grey
  284.     countMats[16]=" 2" -- black
  285.   elseif tmpHead==11 then
  286.     strHead="Cow"
  287.     pat={13,13,13,13,16, 9,13,13, 1, 1,13,13, 1, 9,13,13, 9,16, 1,13,13,13,13,13, 8, 9, 1,13, 8, 9, 9, 9, 8, 9, 1,13,13, 9, 9, 9, 9,16, 1,13,13,13, 9, 8, 1, 1,13,13, 1, 9,13, 8,13,13,13,13,16, 9,13,13}
  288.     countMats[1] ="10" -- white
  289.     countMats[8] =" 5" -- grey
  290.     countMats[9] ="15" -- light grey
  291.     countMats[13]="30" -- brown
  292.     countMats[16]=" 4" -- black
  293.   elseif tmpHead==12 then
  294.     strHead="Mooshroom"
  295.     pat={15,15,15,15,16,16,15,15, 1, 1,15,15,16,16,15,15, 9,16, 1,15,15,15,15,15, 8, 9, 1,15, 8, 9, 9, 9, 8, 9, 1,15,15, 9, 9, 9, 9,16, 1,15,15,15, 9, 8, 1, 1,15,15,16,16,15, 8,15,15,15,15,16,16,15,15}
  296.     countMats[1] =" 8" -- white
  297.     countMats[8] =" 5" -- grey
  298.     countMats[9] ="11" -- light grey
  299.     countMats[15]="30" -- red
  300.     countMats[16]="10" -- black
  301.   elseif tmpHead==13 then
  302.     strHead="Octopus"
  303.     pat={12,12,12,12,12,12,12,12,12,12,12, 1,16,12,12,12,10,10, 4, 1, 1,10,12,12,10,10,10, 4, 4, 4,10,12, 4,10,10,10,10,10, 4,12,12, 4,10, 1, 1,10,12,12,12,12,12, 1,16,12,12,12,12,12,12,12,12,12,12,12}
  304.     countMats[1] =" 6" -- white
  305.     countMats[4] =" 7" -- light blue
  306.     countMats[10]="14" -- cyan
  307.     countMats[12]="35" -- blue
  308.     countMats[16]=" 2" -- black
  309.   elseif tmpHead==14 then
  310.     strHead="Zombie pigman"
  311.     pat={ 9, 6, 9, 9,16, 9, 9, 9, 6,14, 9, 9, 1, 9, 9, 6,14, 7, 8, 7, 9, 9, 6, 9, 6, 9, 6, 7,14, 9, 6,14, 6, 9, 6, 9, 7, 6,14,14,14, 9, 8, 9, 7, 7, 7, 7,14, 7, 7, 7, 1, 7, 7, 7,14,14, 7,14,16, 7, 7, 7}
  312.     countMats[1] =" 2" -- white
  313.     countMats[6] ="10" -- lime
  314.     countMats[7] ="18" -- pink
  315.     countMats[8] =" 2" -- grey
  316.     countMats[9] ="19" -- light grey
  317.     countMats[14]="11" -- green
  318.     countMats[16]=" 2" -- black
  319.   elseif tmpHead==15 then
  320.     strHead="Snow golem"
  321.     pat={ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,16,13, 2,16,13, 2, 2,13,16, 2, 2,16,16, 2, 2, 2,16,13, 2, 2, 2, 2, 2,13,16, 2, 2, 2, 2, 2, 2, 2,16,13, 2,16,16, 2, 2,13,16, 2, 2,16,13, 2, 2, 2, 2, 2, 2, 2, 2, 2}
  322.     countMats[2] ="44" -- orange
  323.     countMats[13]=" 8" -- brown
  324.     countMats[16]="12" -- black
  325.   elseif tmpHead==16 then
  326.     strHead="Iron golem"
  327.     pat={ 9, 9, 9, 9,13, 9, 8, 9, 9,13,15,16,13, 9, 8, 9, 9,13,16,16,13, 9, 8, 9, 8, 8, 8, 9,13, 9, 8, 9, 8, 8, 8, 9,13, 9, 8, 9, 9,13,16,16,13, 9, 8, 9, 9,13,15,16,13, 9, 8, 9, 9, 9, 9, 9,13, 9, 8, 9}
  328.     countMats[8] ="14" -- grey
  329.     countMats[9] ="30" -- light grey
  330.     countMats[13]="12" -- brown
  331.     countMats[15]=" 2" -- red
  332.     countMats[16]=" 6" -- black
  333.   elseif tmpHead==17 then
  334.     strHead="Notch"
  335.     pat={ 7, 7, 7, 7, 7, 7, 7, 7,16,16,16, 7, 7,16, 7, 7,16,16, 1,16, 7, 7, 7, 7,16,16, 1,16, 7, 7, 7, 7,16,16, 1,16, 7, 7, 7, 7,16,16, 1,16, 7, 7, 7, 7,16,16,16, 7, 7,16, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}
  336.     countMats[1] =" 4" -- white
  337.     countMats[7] ="40" -- pink
  338.     countMats[16]="20" -- black
  339.   elseif tmpHead==18 then
  340.     strHead="Steve"
  341.     pat={ 7, 7, 7, 7, 7,13,13,13, 7, 7, 7, 1, 7, 7,13,13,13,13, 7,12, 7, 7,13,13,13, 7,13, 7, 7, 7,13,13,13, 7,13, 7, 7, 7,13,13,13,13, 7,12, 7, 7,13,13, 7, 7, 7, 1, 7, 7,13,13, 7, 7, 7, 7, 7,13,13,13}
  342.     countMats[1] =" 2" -- white
  343.     countMats[7] ="34" -- pink
  344.     countMats[12]=" 2" -- blue
  345.     countMats[13]="26" -- brown
  346.   elseif tmpHead==19 then
  347.     strHead="Magma cube"
  348.     pat={13,16,16,16,16,16, 8,16, 8,13,16,16, 2,15,16,16, 8, 8,16,16, 5,15,16, 8,13,16,16, 8,13,16, 8,13,16,16,13,13,16,16,13, 8,16, 8,13, 8, 5,15,13,13, 8,13,13,13, 2,15,16, 8, 8,13, 8,13,16,16,16,16}
  349.     countMats[2] =" 2" -- orange
  350.     countMats[5] =" 2"  --yellow
  351.     countMats[8] ="14" -- grey
  352.     countMats[13]="16" -- brown
  353.     countMats[15]=" 4" -- red
  354.     countMats[16]="26" -- black
  355.   elseif tmpHead==20 then
  356.     strHead="Blaze"
  357.     pat={13,15, 2, 5, 5, 2, 5, 5,15, 2, 5, 5, 1, 5, 5, 2,13,15, 2, 5,16, 5, 2, 5,15,13, 2, 2, 5, 5, 5, 2,13,15,13, 5, 2, 5, 5, 5,15,13, 2, 2,16, 5, 2, 5,13,15,13, 2, 1, 2, 5, 5,13,13,15, 2, 2,13, 2, 5}
  358.     countMats[1] =" 2" -- white
  359.     countMats[2] ="18" -- orange
  360.     countMats[5] ="23"  --yellow
  361.     countMats[13]="11" -- brown
  362.     countMats[15]=" 8" -- red
  363.     countMats[16]=" 2" -- black
  364.   elseif tmpHead==21 then
  365.     strHead="Wither"
  366.     pat={ 4,16,10,16, 4,16, 4,16,10,16,16, 1,10,16, 4,16, 1, 9,16, 1,16,16,10,16, 9, 1,16,16,16,16,16,16, 9, 1,16,16,16,16,16,16, 1, 9,16, 1,16,16,10,16,10,16,16, 1,10,16, 4,16, 4,16,10,16, 4,16, 4,16}
  367.     countMats[1] =" 8" -- white
  368.     countMats[4] =" 8" -- light blue
  369.     countMats[9] =" 4" -- light grey
  370.     countMats[10]=" 8" -- cyan
  371.     countMats[16]="36" -- black
  372.   else
  373.     blnDone=false
  374.     if not blnAskForParameters then
  375.       print("Unknown head number: "..tmpHead)
  376.       tmpHead=1
  377.       print("Set default to: "..tmpHead)
  378.     end
  379.   end
  380. until blnDone
  381.  
  382. -- step 4 display materials required
  383. if blnAskForParameters then
  384. repeat
  385. print(dispLine)
  386. print("| Put wool or equivalent in 4x4 grid: |")
  387. --print(dispLine)
  388. print("| Colors are sorted by block ID and   |")
  389. print("| use same slots for all heads.       |")
  390. print("| Required amount is put in [].       |")
  391. print(dispLine)
  392. print(strHead..":")
  393.  
  394. -- 4x4 material slots
  395. for i=1,16,4 do
  396.   print(colorIf(i),colorIf(i+1),colorIf(i+2),colorIf(i+3))
  397. end
  398. print(strMessage) -- first time ""
  399. strMessage="" --reset
  400.  
  401. strInput=askForInputText("Press enter when ready:")
  402. for i=1,16,1 do
  403.   if countMats[i]~="  " then
  404.     if turtle.getItemCount(i)<tonumber(countMats[i]) then
  405.       strMessage=">>> Please, put "..countMats[i].." blocks in slot "..tostring(i).."!"
  406.       break
  407.     end
  408.   end
  409. end
  410. until strInput=="" and strMessage==""
  411. end
  412.  
  413. -- step 5 Build head
  414. -- random build order
  415. if inputMode==" v" or inputMode=="v" then
  416.   -- vertical
  417.   if math.random(2)==1 then
  418.     -- build vertical 1
  419.     gf() gu() tu(pat[2]) tu(pat[3]) tu(pat[4]) tu(pat[5]) tu(pat[6]) tu(pat[7]) gl()
  420.     tp(pat[8]) tp(pat[16]) tp(pat[24]) tp(pat[32]) tp(pat[40]) tp(pat[48]) tp(pat[56])
  421.     td(pat[64]) td(pat[63]) td(pat[62]) td(pat[61]) td(pat[60]) td(pat[59]) gl() td(pat[58])
  422.     gl() tp(pat[57]) tp(pat[49]) tp(pat[41]) tp(pat[33]) tp(pat[25]) gl() tu(pat[17])
  423.     gl() tp(pat[18]) tp(pat[26]) tp(pat[34]) tp(pat[42]) tu(pat[50]) tu(pat[51])
  424.     tu(pat[52]) tu(pat[53]) gl() tu(pat[54]) gl() tp(pat[55]) tp(pat[47]) tp(pat[39])
  425.     tp(pat[31]) tp(pat[23]) td(pat[15]) td(pat[14]) gl() td(pat[13]) gl() tp(pat[12])
  426.     tu(pat[20]) tu(pat[21]) tp(pat[22]) tp(pat[30]) tp(pat[38]) td(pat[46])
  427.     td(pat[45]) gl() td(pat[44]) gl() tp(pat[43]) tu(pat[35]) tu(pat[36]) tp(pat[37])
  428.     td(pat[29]) td(pat[28]) tp(pat[27]) tp(pat[19]) td(pat[11]) td(pat[10]) tp(pat[9])
  429.     gl() tp(pat[1])
  430.   else
  431.     -- build vertical 2
  432.     gf() gr() gf() gf() gf() gf()gu() gu() gu() tu(pat[36]) tp(pat[37]) td(pat[29])
  433.     gr() td(pat[28]) gr() tp(pat[27]) tp(pat[35]) tu(pat[43]) tu(pat[44]) gr() tu(pat[45]) 
  434.     gr() tp(pat[46]) tp(pat[38]) tp(pat[30]) td(pat[22]) td(pat[21]) td(pat[20])
  435.     gr() td(pat[19]) gr() tp(pat[18]) tp(pat[26]) tp(pat[34]) tp(pat[42])
  436.     tu(pat[50]) tu(pat[51]) tu(pat[52]) tu(pat[53]) gr() tu(pat[54]) gr() tp(pat[55])
  437.     tp(pat[47]) tp(pat[39]) tp(pat[31]) tp(pat[23]) td(pat[15]) td(pat[14]) td(pat[13])
  438.     td(pat[12]) td(pat[11]) gr() td(pat[10]) gr() tp(pat[9]) tp(pat[17]) tp(pat[25])
  439.     tp(pat[33]) tp(pat[41]) tp(pat[49]) tu(pat[57]) tu(pat[58]) tu(pat[59]) tu(pat[60])
  440.     tu(pat[61]) tu(pat[62]) gr() tu(pat[63]) gr() tp(pat[64]) tp(pat[56]) tp(pat[48])
  441.     tp(pat[40]) tp(pat[32]) tp(pat[24]) tp(pat[16]) td(pat[8]) td(pat[7]) td(pat[6])
  442.     td(pat[5]) td(pat[4]) td(pat[3]) td(pat[2]) gl() tp(pat[1])
  443.   end
  444. else
  445.   -- horizontal
  446.   if math.random(2)==1 then
  447.     -- build horizontal 1
  448.     gl() gl() gb() gb() tp(pat[2]) tp(pat[3]) tp(pat[4]) tp(pat[5]) tp(pat[6]) tp(pat[7])
  449.     gr() tp(pat[8]) gr()  tp(pat[16]) tp(pat[15]) gl()  tp(pat[14]) tp(pat[22]) tp(pat[30])
  450.     tp(pat[38]) tp(pat[46]) gl() tp(pat[54]) gl() tp(pat[55]) tp(pat[47]) tp(pat[39])  
  451.     tp(pat[31]) gr() tp(pat[23]) gr() tp(pat[24]) tp(pat[32]) tp(pat[40]) tp(pat[48]) tp(pat[56])
  452.     gr() tp(pat[64]) tp(pat[63]) tp(pat[62]) tp(pat[61]) tp(pat[60]) tp(pat[59]) tp(pat[58])
  453.     gr() tp(pat[57]) gr() tp(pat[49]) tp(pat[50]) gl() tp(pat[51]) gl() tp(pat[43])
  454.     tp(pat[42]) gr() tp(pat[41]) tp(pat[33]) tp(pat[25]) gr() tp(pat[17]) gr() tp(pat[18])
  455.     tp(pat[26]) gl() tp(pat[34]) tp(pat[35]) gr() tp(pat[36]) tp(pat[44]) gl() tp(pat[52])
  456.     gl() tp(pat[53]) tp(pat[45]) tp(pat[37]) tp(pat[29]) tp(pat[21]) gl() tp(pat[13])
  457.     gl() tp(pat[12]) tp(pat[20]) gr() tp(pat[28]) gr() tp(pat[27]) tp(pat[19]) gl() tp(pat[11])
  458.     tp(pat[10]) gr() tp(pat[9]) gl() tp(pat[1])
  459.   else
  460.     -- build horizontal 2
  461.     gf() gl() gb() tp(pat[9]) tp(pat[17]) tp(pat[25]) tp(pat[33]) gl() tp(pat[41]) gl()
  462.     tp(pat[42]) tp(pat[34]) gr() tp(pat[26]) tp(pat[27]) tp(pat[28]) tp(pat[29]) tp(pat[30])
  463.     gr() tp(pat[31]) gr() tp(pat[39]) tp(pat[38]) tp(pat[37]) tp(pat[36]) gl() tp(pat[35]) gl()
  464.     tp(pat[43]) tp(pat[44]) tp(pat[45]) tp(pat[46]) gr() tp(pat[47]) gr() tp(pat[55]) tp(pat[54])
  465.     tp(pat[53]) tp(pat[52]) tp(pat[51]) tp(pat[50]) gl() tp(pat[49]) gl() tp(pat[57]) tp(pat[58])  
  466.     tp(pat[59]) tp(pat[60]) tp(pat[61]) tp(pat[62]) tp(pat[63]) gl() tp(pat[64]) tp(pat[56])
  467.     tp(pat[48]) tp(pat[40]) tp(pat[32]) gl() tp(pat[24]) tp(pat[23]) tp(pat[22]) tp(pat[21])
  468.     tp(pat[20]) tp(pat[19]) gr() tp(pat[18]) gr() tp(pat[10]) tp(pat[11]) tp(pat[12]) tp(pat[13])
  469.     tp(pat[14]) tp(pat[15]) gl() tp(pat[16]) gl() tp(pat[8]) tp(pat[7]) tp(pat[6]) tp(pat[5])
  470.     tp(pat[4]) tp(pat[3]) tp(pat[2]) tp(pat[1])
  471.   end  
  472. end
  473.  
  474. term.clear() term.setCursorPos(1,1)  
  475. print(dispLine)
  476. print("| Done! Check out YouTube for more    |")
  477. print("| turtle programs by Kaikaku :)       |")
  478. print(dispLine)
Advertisement
Add Comment
Please, Sign In to add comment