Advertisement
Derek1017

Test House Builder

May 29th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.79 KB | None | 0 0
  1. slot = 1
  2.  
  3. function f()
  4. turtle.forward()
  5. end
  6.  
  7. function cl()
  8. shell.run("clear")
  9. end
  10.  
  11. function b()
  12. turtle.place()
  13. end
  14.  
  15. function bd()
  16. turtle.placeDown()
  17. end
  18.  
  19. function bu()
  20. turtle.placeUp()
  21. end
  22.  
  23. function s(place)
  24. turtle.select(place)
  25. slot = slot+1
  26. end
  27.  
  28. function u()
  29. turtle.up()
  30. end
  31.  
  32. function d()
  33. turtle.down()
  34. end
  35.  
  36. function r()
  37. turtle.turnRight()
  38. turtle.forward()
  39. turtle.turnLeft()
  40. end
  41.  
  42. function l()
  43. turtle.turnLeft()
  44. turtle.forward()
  45. turtle.turnRight()
  46. end
  47.  
  48. function c()
  49. count = turtle.getItemCount(slot)
  50. if count == 0 then
  51. if slot < 9 then
  52. newslot = slot+1
  53. s(newslot)
  54. end
  55. end
  56. end
  57.  
  58. function co()
  59. return turtle.getItemCount()
  60. end
  61.  
  62. function df()
  63. turtle.dig()
  64. end
  65.  
  66. function dd()
  67. turtle.digDown()
  68. end
  69.  
  70. cl()
  71. print "House Builder - Made by Vilsol"
  72. print ""
  73. repeat
  74. write "How wide do you want the house? (Max: 14): "
  75. width = tonumber(read())
  76. if width > 14 then
  77. cl()
  78. print "Too wide!"
  79. print ""
  80. end
  81. until width < 15
  82.  
  83. cl()
  84.  
  85. repeat
  86. write "How deep you want the house?     (Max: 14): "
  87. deep = tonumber(read())
  88. if deep > 14 then
  89. cl()
  90. print "Too deep!"
  91. print ""
  92. end
  93. until deep < 15
  94.  
  95. cl()
  96.  
  97. repeat
  98. write "How high you want the house?     (Max: 3): "
  99. high = tonumber(read())
  100. if high > 3 then
  101. cl()
  102. print "Too high!"
  103. print ""
  104. end
  105. until high < 4
  106.  
  107. cl()
  108.  
  109. repeat
  110. write "Do you want your house above     ground? (y/n): "
  111. lev = read()
  112. if lev == "y" then
  113. lev = true
  114. levt = true
  115. elseif lev == "n" then
  116. lev = false
  117. levt = true
  118. else
  119. levt = false
  120. cl()
  121. print "Choose y OR n!"
  122. print ""
  123. end
  124.  
  125. until levt == true
  126.  
  127. total = ((width * deep * 2) + (((width-1) * 2 * high) + (deep-1) * 2 * high))
  128.  
  129. s(1)
  130. s1 = turtle.getItemCount(1)
  131. s2 = turtle.getItemCount(2)
  132. s3 = turtle.getItemCount(3)
  133. s4 = turtle.getItemCount(4)
  134. s5 = turtle.getItemCount(5)
  135. s6 = turtle.getItemCount(6)
  136. s7 = turtle.getItemCount(7)
  137. s8 = turtle.getItemCount(8)
  138. s9 = turtle.getItemCount(9)
  139.  
  140. totalblocks = s1+s2+s3+s4+s5+s6+s7+s8+s9
  141.  
  142. print ("Theese settings will use " .. total .. " blocks!")
  143. print ("You have provided " .. totalblocks .. " blocks!")
  144. if totalblocks >= total then
  145. print "That is enough!"
  146. else
  147.  
  148. repeat
  149. print "That is not enough!"
  150. needed = total - totalblocks
  151. print ("I need " .. needed .. " more blocks!")
  152. print "Write anything to check!"
  153. check = read()
  154. if check then
  155.  
  156. s(1)
  157. s1 = turtle.getItemCount(1)
  158. s2 = turtle.getItemCount(2)
  159. s3 = turtle.getItemCount(3)
  160. s4 = turtle.getItemCount(4)
  161. s5 = turtle.getItemCount(5)
  162. s6 = turtle.getItemCount(6)
  163. s7 = turtle.getItemCount(7)
  164. s8 = turtle.getItemCount(8)
  165. s9 = turtle.getItemCount(9)
  166.  
  167. totalblocks = s1+s2+s3+s4+s5+s6+s7+s8+s9
  168.  
  169. if totalblocks >= total then
  170. print "That is enough!"
  171. ok = true
  172. end
  173.  
  174. end
  175.  
  176. until ok == true
  177.  
  178. end
  179.  
  180. print "Press any key to start building!"
  181. os.pullEvent("key")
  182.  
  183. if lev == true then
  184. turtle.turnRight()
  185. u()
  186. turn = "left"
  187. for de = 1,deep do
  188. c()
  189. bd()
  190.  
  191. for wi = 2,width do
  192. c()
  193. f()
  194. bd()
  195. end
  196.  
  197. if turn == "left" then
  198. turtle.turnLeft()
  199. f()
  200. turtle.turnLeft()
  201. turn = "right"
  202. else
  203. turtle.turnRight()
  204. f()
  205. turtle.turnRight()
  206. turn = "left"
  207. end
  208.  
  209. end
  210.  
  211. else
  212.  
  213. turtle.turnRight()
  214. turn = "left"
  215. for de = 1,deep do
  216. c()
  217. dd()
  218. bd()
  219.  
  220. for wi = 2,width do
  221. c()
  222. f()
  223. dd()
  224. bd()
  225. end
  226.  
  227. if turn == "left" then
  228. turtle.turnLeft()
  229. f()
  230. turtle.turnLeft()
  231. turn = "right"
  232. else
  233. turtle.turnRight()
  234. f()
  235. turtle.turnRight()
  236. turn = "left"
  237. end
  238.  
  239. end
  240.  
  241. end
  242.  
  243. if turn == "left" then
  244. turtle.turnRight()
  245. turn = "right"
  246. else
  247. turtle.turnLeft()
  248. turn = "left"
  249. end
  250.  
  251. for upe = 1,high+1 do
  252. u()
  253. end
  254.  
  255. f()
  256.  
  257. if turn == "left" then
  258. turtle.turnRight()
  259. else
  260. turtle.turnLeft()
  261. end
  262.  
  263. for de = 1,deep do
  264. c()
  265. bd()
  266.  
  267. for wi = 2,width do
  268. c()
  269. f()
  270. bd()
  271. end
  272.  
  273. if turn == "left" then
  274. turtle.turnLeft()
  275. f()
  276. turtle.turnLeft()
  277. turn = "right"
  278. else
  279. turtle.turnRight()
  280. f()
  281. turtle.turnRight()
  282. turn = "left"
  283. end
  284.  
  285. end
  286.  
  287. if turn == "left" then
  288. turtle.turnRight()
  289. turn = "right"
  290. else
  291. turtle.turnLeft()
  292. turn = "left"
  293. end
  294.  
  295. d()
  296.  
  297. w = "down"
  298.  
  299. for ww = 1,width do
  300.  
  301. if w == "down" then
  302. for wh = 1,high do
  303. d()
  304. b()
  305. end
  306. r()
  307. w = "up"
  308. else
  309. for wh = 1,high do
  310. b()
  311. u()
  312. end
  313. r()
  314. w = "down"
  315. end
  316.  
  317. end
  318.  
  319. wall = "side"
  320.  
  321. for walls = 1,3 do
  322.  
  323. if wall == "side" then
  324. size = deep
  325. wall = "back"
  326. else
  327. size = width
  328. wall = "side"
  329. end
  330.  
  331. f()
  332. f()
  333. turtle.turnLeft()
  334.  
  335. for ww = 1,size-1 do
  336.  
  337. if w == "down" then
  338. for wh = 1,high do
  339. d()
  340. b()
  341. end
  342. r()
  343. w = "up"
  344. else
  345. for wh = 1,high do
  346. b()
  347. u()
  348. end
  349. r()
  350. w = "down"
  351. end
  352.  
  353. end
  354.  
  355. end
  356.  
  357. if math.fmod(width, 2) == 0 then
  358.   even = true
  359. else
  360.   even = false
  361. end
  362.  
  363. if even == true then
  364. go = width/2
  365. for fow = 1,go do
  366. f()
  367. end
  368. turtle.turnLeft()
  369. df()
  370. u()
  371. df()
  372. r()
  373. df()
  374. d()
  375. df()
  376. else
  377. go = math.ceil(width/2)
  378. for fow = 1,go do
  379. f()
  380. end
  381. turtle.turnLeft()
  382. df()
  383. u()
  384. df()
  385. end
  386.  
  387. d()
  388. d()
  389. turtle.turnRight()
  390. f()
  391. turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement