Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lefele = 0
- local jobbra = 0
- local elore = 0
- local y = 0
- local x = 0
- local z = 0
- local fakja = 0
- local c = turtle.compare()
- local cu = turtle.compareUp()
- local cd = turtle.compareDown()
- function refuel()
- local fuel = turtle.getFuelLevel()
- local uthossz = jobbra + lefele + elore * 2
- if fuel - 10 < uthossz then
- print("keves az uzemanyag az utra")
- print("uzemanyag: ", fuel)
- sleep(1)
- end
- while fuel < 1 do
- print("keves az uzemanyag: ", fuel)
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(1) then
- print("tankoltam ennyituzemanyagot: ", turtle.getFuelLevel()) sleep(1)
- return
- else
- if i == 16 then
- print("nem volt mit tankolni") sleep(1)
- end
- end
- end
- end
- end
- refuel()
- function install()
- if not fs.exists("/z") then
- iteminstall()
- print("/x2 file letrehozasa")
- sleep(.2)
- file = fs.open("/x2","w")
- file.writeLine("0")
- file.close()
- print("kesz")
- sleep(.6)
- print("/y2 file letrehozasa")
- sleep(.2)
- file = fs.open("/y2","w")
- file.writeLine("0")
- file.close()
- print("kesz")
- sleep(.6)
- print("/z2 file letrehozasa")
- sleep(.2)
- file = fs.open("/z2","w")
- file.writeLine("0")
- file.close()
- print("kesz")
- sleep(.6)
- print("/x file letrehozasa")
- sleep(.2)
- file = fs.open("/x","w")
- file.writeLine("0")
- file.close()
- print("kesz")
- sleep(.6)
- print("/y file letrehozasa")
- sleep(.2)
- file = fs.open("/y","w")
- file.writeLine("0")
- file.close()
- print("kesz")
- sleep(.6)
- print("/z file letrehozasa")
- sleep(.2)
- file = fs.open("/z","w")
- file.writeLine("0")
- file.close()
- print("kesz")
- sleep(.6)
- return miner()
- else
- miner()
- end
- end
- function iteminstall()
- local fakjadarab = turtle.getItemCount(1)
- while fakjadarab < 16 do
- cls()
- fakjadarab = turtle.getItemCount(1)
- fakjakell = 16 - fakjadarab
- print("Elso sor, elso slotba, rakj 16db fakjat.")
- print("Meg ennyi kell: ".. fakjakell)
- print("Ha beraktad, folytatodik a program")
- sleep(0.4)
- cls()
- end
- end
- function load()
- file = fs.open("z2", "r")
- if file then
- jobbra = file.readLine()
- file.close()
- print("z2: ", jobbra)
- sleep(.2)
- jobbra = jobbra + 0
- end
- file = fs.open("x2", "r")
- if file then
- elore = file.readLine()
- file.close()
- print("x2: ", elore)
- sleep(.2)
- elore = elore + 0
- end
- file = fs.open("y2", "r")
- if file then
- lefele = file.readLine()
- file.close()
- print("y2: ", lefele)
- sleep(.2)
- lefele = lefele + 0
- end
- file = fs.open("x", "r")
- if file then
- x = file.readLine()
- file.close()
- print("x: ", x)
- sleep(.2)
- x = x + 0
- end
- file = fs.open("y", "r")
- if file then
- y = file.readLine()
- file.close()
- print("y: ", y)
- sleep(.2)
- y = y + 0
- end
- file = fs.open("z", "r")
- if file then
- z = file.readLine()
- file.close()
- print("z: ", z)
- sleep(.2)
- z = z + 0
- end
- end
- function cls()
- term.clear()
- term.setCursorPos(1,1)
- end
- function dropall() --Chestnel minden slotot kiurit kiveve az egyest.
- for i = 4, 16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function kiut()
- refuel()
- if turtle.compare(2) then
- local slot = turtle.getSelectedSlot()
- turtle.select(3)
- while turtle.getItemCount(3) > 1 do
- turtle.drop(1)
- end
- turtle.select(slot)
- end
- turtle.select(2)
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- if fakja==16 then
- turtle.select(1)
- turtle.placeDown()
- turtle.select(2)
- fakja = 0
- end
- fakja = fakja + 1
- end
- function zback()
- refuel()
- while not turtle.forward() do
- if turtle.detect() == true then
- cls()
- print("blokkot talaltam")
- turtle.dig()
- else
- refuel()
- print("mob van elottem. Tamadok!")
- turtle.attack()
- end
- end
- end
- function digdown()
- refuel()
- while not turtle.down() do
- if turtle.detectDown() then
- if turtle.digDown() then
- cls()
- print("blokkot talaltam alattam")
- else
- cls()
- print("bedrockba utkoztem")
- end
- else
- refuel()
- print("mob van alattam")
- end
- end
- end
- function digforward()
- refuel()
- while not turtle.forward() do
- if turtle.detect() == true then
- cls()
- print("blokkot talaltam")
- kiut()
- else
- refuel()
- print("mob van elottem. Tamadok!")
- turtle.attack()
- end
- end
- end
- function back()
- refuel()
- while not turtle.forward() do
- if turtle.detect() == true then
- cls()
- print("blokkot talaltam")
- kiut()
- else
- refuel()
- print("mob van elottem. Tamadok!")
- turtle.attack()
- end
- end
- end
- function digup()
- refuel()
- while not turtle.up() do
- if turtle.detectUp() == true then
- cls()
- print("blokk van felettem")
- turtle.digUp()
- else
- refuel()
- print("mob van felettem")
- end
- end
- end
- function miner()
- load()
- cls()
- if jobbra<1 and lefele<1 and elore<1 and x<1 and y<1 and z<1 then
- print("mennyit menjek jobbra")
- jobbra = tonumber(read())
- if jobbra == nil then
- cls()
- print("Jobbra csak szamot lehet megadni!")
- return miner()
- end
- if jobbra<2 then
- print("min 2")
- sleep(1)
- return miner()
- end
- if jobbra>50 then
- print("max 50")
- sleep(1)
- return miner()
- end
- file = fs.delete("z2")
- file = fs.open("/z2","w")
- file.writeLine(jobbra)
- file.close()
- jobbra = jobbra + 0
- end
- if jobbra>0 and lefele<1 and elore<1 then
- print("mennyit menjek le")
- lefele = tonumber(read())
- if lefele == nil then
- cls()
- print("lefele csak szamot lehet megadni!")
- return miner()
- end
- if lefele>60 then
- print("max 60")
- sleep(1)
- return miner()
- end
- file = fs.delete("y2")
- file = fs.open("/y2","w")
- file.writeLine(lefele)
- file.close()
- lefele = lefele + 0
- end
- if jobbra>0 and lefele>0 and elore<1 then
- cls()
- print("mennyit menjek elore")
- elore = tonumber(read())
- if elore == nil then
- cls()
- print("Elore csak szamot lehet megadni!")
- return miner()
- end
- if elore>50 then
- print("max 50")
- sleep(1)
- return miner()
- end
- file = fs.delete("x2")
- file = fs.open("/x2","w")
- file.writeLine(elore)
- file.close()
- elore = elore + 0
- end
- if jobbra>0 and lefele >0 and elore >0 then
- turtle.select(1)
- if z<1 and x<1 and y<1 then
- local fakjadarab = turtle.getItemCount(1)
- while fakjadarab < 16 do
- cls()
- fakjadarab = turtle.getItemCount(1)
- fakjakell = 16 - fakjadarab
- print("Elso sor, elso slotba, rakj 16db fakjat.")
- print("Meg ennyi kell: ".. fakjakell)
- print("Ha beraktad, folytatodik a program")
- sleep(0.4)
- cls()
- end
- end
- for i = 1, jobbra do
- if z<1 then
- turtle.turnRight()
- end
- digforward()
- jobbra = jobbra - 1
- file = fs.delete("z2")
- file = fs.open("/z2","w")
- file.writeLine(jobbra)
- file.close()
- z = z + 1
- file = fs.delete("z")
- file = fs.open("/z","w")
- file.writeLine(z)
- file.close()
- print("z:", z)
- end
- end
- if jobbra<1 and lefele>0 then
- for i = 1, lefele do
- if y<1 then
- turtle.turnLeft()
- end
- digdown()
- lefele = lefele - 1
- file = fs.delete("y2")
- file = fs.open("/y2","w")
- file.writeLine(lefele)
- file.close()
- y = y + 1
- file = fs.delete("y")
- file = fs.open("/y","w")
- file.writeLine(y)
- file.close()
- print("lefele: ", lefele)
- print("y:", y)
- end
- end
- if lefele<1 and elore>0 then
- for i = 1, elore do
- digforward()
- elore = elore - 1
- file = fs.delete("x2")
- file = fs.open("/x2","w")
- file.writeLine(elore)
- file.close()
- x = x + 1
- file = fs.delete("x")
- file = fs.open("/x","w")
- file.writeLine(x)
- file.close()
- print("elore", elore)
- print("x:", x)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- if elore<1 and x>0 then
- for i = 1, x do
- back()
- x = x - 1
- file = fs.delete("x")
- file = fs.open("/x","w")
- file.writeLine(x)
- file.close()
- print("x", x)
- end
- end
- if x<1 and y>0 then
- for i = 1, y do
- digup()
- y = y - 1
- file = fs.delete("y")
- file = fs.open("/y","w")
- file.writeLine(y)
- file.close()
- print("y:", y)
- end
- if y<1 and z>0 then
- turtle.turnRight()
- end
- end
- if y<1 and z>0 then
- for i = 1, z do
- zback()
- z = z - 1
- file = fs.delete("z")
- file = fs.open("/z","w")
- file.writeLine(z)
- file.close()
- print("z:", z)
- if z<1 then
- dropall()
- turtle.turnRight()
- end
- end
- end
- end
- while true do
- install()
- sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement