Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.53 KB | None | 0 0
  1.  
  2. ---------------------------------------
  3. ---- DESCRIPTION ----------------------
  4. ---------------------------------------
  5. -- One turtle builds a mansion.
  6. -- Details see information during program
  7. --   execution or YouTube video.
  8.  
  9.  
  10. ---------------------------------------
  11. ---- PARAMETERS -----------------------
  12. ---------------------------------------
  13. local cVersion  ="v1.00"
  14. local cMinFuel  =128
  15.  
  16.  
  17. ---------------------------------------
  18. ---- VARIABLES ------------------------
  19. ---------------------------------------
  20. local blnAskForParameters = true
  21. local blnShowUsage   = false
  22.  
  23. ---------------------------------------
  24. ---- tArgs ----------------------------
  25. ---------------------------------------
  26. local tArgs = {...}
  27. if #tArgs == 1 then -- no error check
  28.   blnAskForParameters=false
  29.   if tArgs[1]=="help" then blnShowUsage=true end
  30.   -- any other parameter will start program
  31. end
  32.  
  33. if blnShowUsage then
  34.   print("Usage: bMansion [anyParameter]")
  35.   print("If anyParameter exists, then the program")
  36.   print("  starts without need to press a key.")
  37.   print("If anyParameter is 'help', then this")
  38.   print("  info is displayed.")
  39.   return  
  40. end
  41.  
  42. ---------------------------------------
  43. -- BASIC FUNCTIONS FOR TURTLE CONTROL -
  44. ---------------------------------------
  45. local function gf(n)
  46.   if n==nil then n=1 end
  47.   for i=1,n,1 do while not turtle.forward() do end end
  48. end
  49. local function gb(n)
  50.   if n==nil then n=1 end
  51.   for i=1,n,1 do while not turtle.back() do end end
  52. end
  53. local function gu(n)
  54.   if n==nil then n=1 end
  55.   for i=1,n,1 do while not turtle.up() do end end
  56. end
  57. local function gd(n)
  58.   if n==nil then n=1 end
  59.   for i=1,n,1 do while not turtle.down() do end end
  60. end
  61. local function gl(n)
  62.   if n==nil then n=1 end
  63.   for i=1,n,1 do while not turtle.turnLeft() do end end
  64. end
  65. local function gr(n)
  66.   if n==nil then n=1 end
  67.   for i=1,n,1 do while not turtle.turnRight() do end end
  68. end
  69. local function pf(n)
  70.   -- moves backwards if n>1
  71.   if n==nil then n=1 end
  72.   for i=1,n,1 do if i~=1 then gb() end turtle.place() end
  73. end
  74. local function pu()  turtle.placeUp()   end
  75. local function pd()  turtle.placeDown() end
  76. local function df()  turtle.dig()       end
  77. local function du()  turtle.digUp()     end
  78. local function dd()  turtle.digDown()   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)   end
  86. local function spd(s)
  87.     ss(s)
  88.     pd()
  89. end
  90.  
  91. local function askForInputText(textt)
  92.   local at=""
  93.   -- check prompting texts
  94.   if textt==nil then textt="Enter text:" end
  95.  
  96.   -- ask for input
  97.   write(textt)
  98.   at=read()
  99.   return at
  100. end
  101.  
  102. local function checkFuel()
  103.   local tmp=turtle.getFuelLevel()
  104.   return tmp
  105. end
  106.  
  107.  
  108. ------------------------------------------------------------------------------
  109. ---- MAIN --------------------------------------------------------------------
  110. ------------------------------------------------------------------------------
  111.  
  112. -- step 0 usage hints
  113. if blnAskForParameters then
  114. term.clear() term.setCursorPos(1,1)
  115. repeat
  116. print("+-------------------------------------+")
  117. print("| Ensure turtle is in position of     |")
  118. print("|  northmost white-section energy     |")
  119. print("|  condenser facing south before      |")
  120. print("|  continuing.                        |")
  121. print("|                                     |")
  122. print("|                                     |")
  123. print("|                                     |")
  124. print("|                                     |")
  125. print("|                                     |")
  126. print("+-------------------------------------+")
  127. until askForInputText("Press enter for next page:")==""
  128.  
  129. term.clear() term.setCursorPos(1,1)
  130. repeat
  131. print("+-------------------------------------+")
  132. print("| Put in turtle slots these materials:|")
  133. print("|  1: 44 mk2 energy condensers        |")
  134. print("|  2: 12 red matter relays            |")
  135. print("|  3: 8 grey glass                    |")
  136. print("|  4: 8 green glass                   |")
  137. print("|  5: 8 magenta glass                 |")
  138. print("|  6: 8 red glass                     |")
  139. print("|  7: 4 energy condensers             |")
  140. print("+-------------------------------------+")
  141. until askForInputText("Press enter for next page:")==""
  142.  
  143. term.clear() term.setCursorPos(1,1)
  144. repeat
  145. print("+-------------------------------------+")
  146. print("| Put in turtle slots these materials:|")
  147. print("|  8: 4 filters                       |")
  148. print("|  9: 17 pneumatic tubes              |")
  149. print("|  10: 29 stone covers                |")
  150. print("|                                     |")
  151. print("|                                     |")
  152. print("|                                     |")
  153. print("|                                     |")
  154. print("+-------------------------------------+")
  155. until askForInputText("Press enter for next page:")==""
  156.  
  157. term.clear() term.setCursorPos(1,1)
  158. repeat
  159. print("+-------------------------------------+")
  160. print("| Additional items needed to complete:|")
  161. print("|  4 mk2 energy condensers            |")
  162. print("|  4 red matter relays                |")
  163. print("|  4 stone covers                     |")
  164. print("|  17 red alloy wires                 |")
  165. print("|  wrench                             |")
  166. print("|                                     |")
  167. print("|                                     |")
  168. print("|                                     |")
  169. print("+-------------------------------------+")
  170. until askForInputText("Press enter to start:")==""
  171. end
  172.  
  173. -- start building
  174.  
  175. term.clear() term.setCursorPos(1,1)
  176. print("Working on pipe section")
  177. print("Pipe section layer 1")
  178. spd(10) spd(9) gf() spd(9) gl() gf() spd(10) spd(9) gf() spd(10) spd(9) gr() gf() spd(10) spd(9)
  179. gf() gr() gf(5) gl(2) spd(9) gf() spd(10) spd(9) gf() spd(10) spd(9) gf() spd(10) spd(9) gf() spd(10) spd(9) gf() spd(10) spd(9) gr()
  180. gf() spd(9) gf() spd(10) spd(9)
  181. gf() gr() gf(3) gl(2) spd(9) gf() spd(10) spd(9) gf() spd(10) spd(9) gf() spd(10) spd(9)
  182. gl() gf(5) gl() gf(2) gr() gf() gl(2)
  183. print("Pipe section layer 2")
  184. gu() spd(10) gf() spd(10) gl() gf() spd(10) gf() spd(10) gf() spd(10) gr() gf() spd(10)
  185. gf() gr() gf(5) gl(2) spd(10) gf() spd(10) gf() spd(10) gf() spd(10) gf() spd(10) gf() spd(10) gr()
  186. gf() spd(10) gf() spd(10)
  187. gf() gr() gf(3) gl(2) spd(10) gf() spd(10) gf() spd(10) gf() spd(10)
  188. gl() gf(5) gl() gf(2) gr() gf() gl(2)
  189. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement