Advertisement
Guest User

Untitled

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