Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --sideTunel by djPtica v0.1.4
- --SETUP
- --put turtle in front of your desired tunel on head level, not ground level
- --put chests in slot 15
- --put torches in slot 16
- --make sure that slot 14 is empty
- local tArgs = {...}
- local duljina = 0
- duljina = tonumber(tArgs[1])
- function kopaj()
- turtle.dig()
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- end
- turtle.digDown()
- end
- function kopajStrane()
- turtle.turnLeft()
- for o=1, 4 do
- kopaj()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- povratak(4)
- for o=1, 4 do
- kopaj()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- povratak(4)
- turtle.turnRight()
- end
- function povratak(dist)
- for i=1, dist do
- while not turtle.forward() do
- turtle.attack()
- end
- end
- end
- function provjeraBaklje()
- torch = duljina / 5
- torch = math.floor(torch)
- while true do
- j = turtle.getItemCount(16)
- if j<torch then
- print("Nedovoljno baklji.")
- print("Stavi jos ", torch-j, " baklji u slot 16. (donji desni slot)")
- else
- print("Baklje: OK")
- break
- end
- sleep(3)
- end
- end
- function provjeraGorivo()
- gorivo = duljina * 20
- while true do
- k = turtle.getFuelLevel()
- if k<gorivo then
- print("Nedovoljno goriva.")
- print("Stavi gorivo (coal, wood) u slot 1. (gornji lijevi slot)")
- l=0
- l = turtle.getItemCount(1)
- turtle.refuel(l)
- else
- print("Gorivo: OK")
- break
- end
- sleep(3)
- end
- end
- function provjeraSkrinje()
- chest = duljina / 10
- chest = math.floor(chest)
- while true do
- p = turtle.getItemCount(15)
- if p<chest then
- print("Nedovoljno skrinja.")
- print("Stavi jos ", chest-p, " skrinja u slot 15. (donji treci slot)")
- else
- print("Skrinje: OK")
- break
- end
- sleep(3)
- end
- end
- function provjeraFull()
- if turtle.getItemCount(14)>0 then
- turtle.select(15)
- if turtle.placeDown() then
- for s=1, 14 do
- turtle.select(s)
- turtle.dropDown()
- end
- else
- turtle.turnLeft()
- turtle.turnLeft()
- while not turtle.forward() do
- turtle.attack()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.placeDown()
- for s=1, 14 do
- turtle.select(s)
- turtle.dropDown()
- end
- end
- turtle.forward()
- end
- turtle.select(1)
- end
- --GLAVNI PROGRAM
- provjeraGorivo()
- provjeraBaklje()
- provjeraSkrinje()
- print("")
- print("Zapocinjem razgranati tunel.")
- if duljina>0 then
- for i=1, duljina do
- kopaj()
- if i%3==0 then
- kopajStrane()
- end
- if i%5==0 then
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- end
- provjeraFull()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- povratak(duljina)
- print("Tunel uspjesno napravljen!")
- else
- print("Nije zadana ili pogresno zadana duljina. (e.g.: sideTunel 15)")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement