This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
malo13's profile picture

turtle goes to much down

Started by malo13, 02 July 2013 - 06:43 AM
malo13 #1
Posted 02 July 2013 - 08:43 AM
title: turtle goes to much down

i programmed my turtle that it shall dig down and then go one block down. But when there are two blocks space on its path it will take them in once. So for every two blocks space it will get one block less back up.
I don't know wheather it is a bug or a programmmistake. I'm playing on minecraftversion 1.4.7 and here is my code

function load(str)
		lade = fs.open(str,"r")
		geles = lade.readLine()
		lade.close()
end
	
function save(str, text)
		speich = fs.open(str,"w")
		speich.write(text)
		speich.close()  
end
	
function runter()
		while (bedrock == false) do
		    turtle.digDown()
		    os.sleep(0.1)
		    turtle.down()
		    y=tonumber(y)+1
		    save("y", y)
		    print(y)
		    if (turtle.digDown() == false and turtle.down() == false) then
			    bedrock = true
		    end
		end
		zustand="rauf"
		save("zustand", zustand)
end
	
function rauf()
		zustand="rauf"
		save("zustand",zustand)
		while (tonumber(y) > 0) do
				turtle.up()
				y=tonumber(y)-1
			    print(y)
				save("y",y)
		end
		turtle.select(1)
		turtle.placeUp()
		for i=3,16 do
		    turtle.select(i)
			turtle.dropUp()
	    end
		turtle.select(1)
		turtle.digUp()
		turtle.select(2)
		turtle.placeUp()
		turtle.suckUp()
		turtle.refuel()
		turtle.digUp()
end

load("start")
start=geles
print(start)
if (start ~= "true") then
		print("Willst du starten? j/n")
		input = read()
		if (input == "j") then
				start="true"
				zustand = "runter"
				y="0"
				bedrock = false
				save("bedrock",bedrock)
				save("y",y)
				save("zustand",zustand)
				save("start",start)
		end
		if (input=="n")then
				start="0"
				save("start",start)
		end
end
	
while (start == "true") do
		shell.run("clear")
		load("zustand")
		zustand = geles
		print(zustand)
		if (zustand == "runter") then
				load("y")
				y=geles
				runter()
		end
		if (zustand == "rauf") then
				load("y")
				y=geles
				rauf()
		end
		start=0
		save("start",start)
end
print("end")
Cranium #2
Posted 02 July 2013 - 04:33 PM
Split to new topic.

For future reference, please use
 tags for your code. It helps us read it much better. I have edited your post to add them in.
You can find the code tags in the Special BBCode button available on the editor.
Apfeldstrudel #3
Posted 03 July 2013 - 10:11 AM
..eerything is so … German!