Advertisement
Guest User

Untitled

a guest
May 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.46 KB | None | 0 0
  1. rotation = true
  2. start = true
  3. done = false
  4. l = "Noch nicht definiert"
  5. lp = ""
  6. b = "Noch nicht definiert"
  7. bp = ""
  8. t = "Noch nicht definiert"
  9. tp = ""
  10.  
  11.  
  12. -- Bedienoberfläche --
  13.  
  14.  
  15. term.clear() term.setCursorPos(1,1)
  16.  
  17.  
  18. print("+-------------------------------------+")
  19. print("| Programm: Raumausheben 1.0 (1/2)|")
  20. print("| von xXNickBrickXx |")
  21. print("| |")
  22. print("| Programmzweck: |")
  23. print("| beliebig großen, quaderförmigen |")
  24. print("| Raum ausheben |")
  25. print("| Treibstoff: Slot 16 |")
  26. print("| Startpunkt (in Bezug auf Quader): |")
  27. print("| Links oben |")
  28. print("+-------------------------------------+")
  29. print("Press enter to continue:")
  30.  
  31. while start do
  32. event, key = os.pullEvent("char")
  33. if key == "1" then
  34. start = false
  35. print("")
  36. print("+-------------------------------------+")
  37. print("| Maße des Raums (2/2)|")
  38. print("| |")
  39. print("| Länge: "..l.." |")
  40. print("| Breite: "..b.." |")
  41. print("| Tiefe: "..t.." |")
  42. print("+-------------------------------------+")
  43. print("")
  44. print(" Welche Länge soll dieser Raum haben?")
  45. print("")
  46. print("")
  47. print("")
  48. l = tonumber(read())
  49. if l == 10 then
  50. lp = "|"
  51. else
  52. if l < 10 then
  53. lp = " |"
  54. else
  55. lp = "|"
  56. end
  57. end
  58.  
  59.  
  60. print("")
  61. print("+-------------------------------------+")
  62. print("| Maße des Raums (2/2)|")
  63. print("| |")
  64. print("| Länge: "..l.." "..lp.."")
  65. print("| Breite: "..b.." |")
  66. print("| Tiefe: "..t.." |")
  67. print("+-------------------------------------+")
  68. print("")
  69. print(" Welche Breite soll dieser Raum haben?")
  70. print("")
  71. print("")
  72. print("")
  73. b = tonumber(read())
  74. if b == 10 then
  75. bp = "|"
  76. else
  77. if b < 10 then
  78. bp = " |"
  79. else
  80. bp = "|"
  81. end
  82. end
  83.  
  84. print("")
  85. print("+-------------------------------------+")
  86. print("| Maße des Raums (2/2)|")
  87. print("| |")
  88. print("| Länge: "..l.." "..lp.."" )
  89. print("| Breite: "..b.." "..bp.."")
  90. print("| Tiefe: "..t.." |")
  91. print("+-------------------------------------+")
  92. print("")
  93. print(" Welche Tiefe soll dieser Raum haben?")
  94. print("")
  95. print("")
  96. print("")
  97. t = tonumber(read())
  98. if t == 10 then
  99. tp = "|"
  100. else
  101. if t < 10 then
  102. tp = " |"
  103. else
  104. tp = "|"
  105. end
  106. end
  107.  
  108. local minFuelNeeded = l*b*t-1
  109.  
  110. print("")
  111. print("+-------------------------------------+")
  112. print("| Maße des Raums (2/2)|")
  113. print("| |")
  114. print("| Länge: "..l.." "..lp.."")
  115. print("| Breite: "..b.." "..bp.."")
  116. print("| Tiefe: "..t.." "..tp.."")
  117. print("+-------------------------------------+")
  118. print("")
  119. print(" Es wurden alle Maße eingegeben!")
  120. print(" Es werden mindestens "..minFuelNeeded.." Treibstoff-")
  121. print(" einheiten benötigt!")
  122. print(" Starte in 5 Sekunden!")
  123.  
  124. os.sleep(3)
  125.  
  126. end
  127. end
  128.  
  129.  
  130. -- Basisfunctionen --
  131.  
  132.  
  133. local function gf(n)
  134. if n==nil then n=1 end
  135. for i = 1, n, 1 do
  136. while not turtle.forward() do end
  137. end
  138. end
  139.  
  140. local function gb(n)
  141. if n==nil then n=1 end
  142. for i=1, n, 1 do
  143. while not turtle.back() do end
  144. end
  145. end
  146.  
  147. local function gu(n)
  148. if n==nil then n=1 end
  149. for i=1, n, 1 do
  150. while not turtle.up() do end
  151. end
  152. end
  153.  
  154. local function gd(n)
  155. if n==nil then n=1 end
  156. for i=1, n, 1 do
  157. while not turtle.down() do end
  158. end
  159. end
  160.  
  161. local function gl(n)
  162. if n==nil then n=1 end
  163. for i=1, n, 1 do
  164. while not turtle.turnLeft() do end
  165. end
  166. end
  167.  
  168. local function gr(n)
  169. if n==nil then n=1 end
  170. for i=1, n, 1 do
  171. while not turtle.turnRight() do end
  172. end
  173. end
  174.  
  175. local function pf(n)
  176. if n==nil then n=1 end
  177. for i=1, n, 1 do
  178. if i~=1 then gb() end
  179. turtle.place()
  180. end
  181. end
  182.  
  183. local function pu() turtle.placeUp() end
  184.  
  185. local function pd() turtle.placeDown() end
  186.  
  187. local function df() turtle.dig() end
  188.  
  189. local function du() turtle.digUp() end
  190.  
  191. local function dd() turtle.digDown() end
  192.  
  193. local function sf() turtle.suck() end
  194.  
  195. local function su() turtle.suckUp() end
  196.  
  197. local function sd(n)
  198. if n==nil then
  199. while turtle.suckDown() do end
  200. else
  201. for i=1, n do
  202. turtle.suckDown()
  203. end
  204. end
  205. end
  206.  
  207. local function Df() turtle.drop() end
  208.  
  209. local function Du(n)
  210. if n==nil then n=64 end
  211. turtle.dropUp(n)
  212. end
  213.  
  214. local function Dd(n)
  215. if n==nil then n=64 end
  216. turtle.dropDown(n)
  217. end
  218.  
  219. local function ss(s) turtle.select(s) end
  220.  
  221.  
  222. -- Funktionen --
  223.  
  224.  
  225. function printClear()
  226. print("")
  227. print("")
  228. print("")
  229. print("")
  230. print("")
  231. print("")
  232. print("")
  233. print("")
  234. print("")
  235. print("")
  236. print("")
  237. print("")
  238. print("")
  239. print("")
  240. end
  241.  
  242.  
  243. function checkFuel()
  244. local fuelLevel = turtle.getFuelLevel()
  245. local minFuelNeeded = l*b*t-1
  246. if fuelLevel < minFuelNeeded then
  247. ss(16)
  248. if turtle.getItemCount(16) == 0 then
  249. print("Ich brauche mehr Treibstoff für diesen Befehl!")
  250. os.sleep(5)
  251. printClear()
  252. checkFuel()
  253. else
  254. turtle.refuel(1)
  255. fuelLevel = turtle.getFuelLevel()
  256. if fuelLevel < minFuelNeeded then
  257. checkFuel()
  258. else
  259. print("Ich habe mich neu betankt und besitze nun genug Treibstoff für diesen Befehl!")
  260. end
  261. end
  262. else
  263. print("Ich besitze genug Treibstoff für diesen Befehl!")
  264. end
  265. ss(1)
  266. end
  267.  
  268.  
  269. function turn()
  270. if rotation then
  271. gr()
  272. else
  273. gl()
  274. end
  275. end
  276.  
  277.  
  278. function digUpSpace()
  279. for x=1, t, 1 do
  280. for y=1, b, 1 do
  281. for z=1, l-1, 1 do
  282. df() gf()
  283. end
  284. turn()
  285. if y~=b then
  286. df() gf()
  287. end
  288. turn()
  289. rotation = not rotation
  290. end
  291. if x~=t then
  292. dd() gd()
  293. end
  294. rotation = not rotation
  295. end
  296. end
  297.  
  298.  
  299. -- Hauptfunktion --
  300.  
  301.  
  302. printClear()
  303. checkFuel()
  304. digUpSpace()
  305. printClear()
  306. done = true
  307.  
  308. print("+-------------------------------------+")
  309. print("| Programm: Raumausheben 1.0 |")
  310. print("| von xXNickBrickXx |")
  311. print("| |")
  312. print("| Raum fertig ausgehoben! |")
  313. print("| Vielen Dank, für die Wahl dieses |")
  314. print("| Programms! |")
  315. print("| |")
  316. print("| |")
  317. print("| |")
  318. print("+-------------------------------------+")
  319. print("Press enter to reboot:")
  320.  
  321. while start do
  322. event, key = os.pullEvent("char")
  323. if key == "1" then
  324. start = false
  325.  
  326. print("")
  327. print("+-------------------------------------+")
  328. print("| |")
  329. print("| |")
  330. print("| |")
  331. print("| |")
  332. print("| BYE! |")
  333. print("| |")
  334. print("| |")
  335. print("| |")
  336. print("| |")
  337. print("+-------------------------------------+")
  338. print("")
  339.  
  340. os.sleep(4)
  341. os.reboot()
  342. end
  343. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement