Advertisement
Guest User

Untitled

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