12 posts
Posted 21 December 2012 - 09:26 PM
Hello I made a turtle mining program but the turtle wont go up to the surface is done mining
here the script:
fuel = turtle.getFuelLevel()
if fuel == 0 then
turtle.select(14)
turtle.refuel(1)
turtle.select(1)
end
check = turtle.getItemCount(13)
if check <= 1 then
print("Put Torches In Slot 13 !")
sleep(1)
os.shutdown()
end
for i = 1,56 do
turtle.digDown()
turtle.down()
if i == 56 then
while true do
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.dig()
turtle.select(13)
turtle.place()
turtle.select(1)
turtle.turnRight()
turtle.down()
invfull = turtle.getItemCount(16)
if invfull == 64 then
turtle.up()
while true do
turtle.back()
while not turtle.back() do
for g = 1,56 do
turtle.up()
sleep(1)
os.shutdown()
end
torch = turtle.getItemCount(13)
if torch <= 1 then
os.shutdown()
fuel = turtle.getFuelLevel()
if fuel == 0 then
turtle.select(14)
turtle.refuel(1)
turtle.select(1)
end
end
end
end
end
end
end
end
please help me
2088 posts
Location
South Africa
Posted 21 December 2012 - 11:17 PM
Why are you making the turtle shutdown?
12 posts
Posted 22 December 2012 - 04:10 PM
when the turtle is at the surface i want him to shutdown
818 posts
Posted 22 December 2012 - 04:23 PM
Please, indent your code. It will be alot more eyepleasing to read that way
12 posts
Posted 22 December 2012 - 04:37 PM
indent?
144 posts
Location
Wellington, New Zealand
Posted 22 December 2012 - 04:51 PM
Please, indent your code. It will be alot more eyepleasing to read that way
indent?
fuel = turtle.getFuelLevel()
if fuel == 0 then
turtle.select(14)
turtle.refuel(1)
turtle.select(1)
end
check = turtle.getItemCount(13)
if check <= 1 then
print("Put Torches In Slot 13 !")
sleep(1)
os.shutdown()
end
for i = 1,56 do
turtle.digDown()
turtle.down()
if i == 56 then
while true do
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.dig()
turtle.select(13)
turtle.place()
turtle.select(1)
turtle.turnRight()
turtle.down()
invfull = turtle.getItemCount(16)
if invfull == 64 then
turtle.up()
while true do
turtle.back()
while not turtle.back() do
for g = 1,56 do
turtle.up()
sleep(1)
os.shutdown()
end
torch = turtle.getItemCount(13)
if torch <= 1 then
os.shutdown()
fuel = turtle.getFuelLevel()
if fuel == 0 then
turtle.select(14)
turtle.refuel(1)
turtle.select(1)
end
end
end
end
end
end
end
end
I tried. Lol :S
EDIT: Edited it and made it worse. Pointless now. :S
12 posts
Posted 22 December 2012 - 04:55 PM
Thanks for the indent
1111 posts
Location
Portland OR
Posted 22 December 2012 - 05:35 PM
Here is some indentation with spaces, the forums handle them better then tabs.
Spoiler
fuel = turtle.getFuelLevel()
if fuel == 0 then
turtle.select(14)
turtle.refuel(1)
turtle.select(1)
end
check = turtle.getItemCount(13)
if check <= 1 then
print("Put Torches In Slot 13 !")
sleep(1)
os.shutdown()
end
for i = 1,56 do
turtle.digDown()
turtle.down()
if i == 56 then
while true do
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.dig()
turtle.select(13)
turtle.place()
turtle.select(1)
turtle.turnRight()
turtle.down()
invfull = turtle.getItemCount(16)
if invfull == 64 then
turtle.up()
while true do
turtle.back()
while not turtle.back() do
for g = 1,56 do
turtle.up() --on the first loop it goes up
sleep(1) --then it sleeps
os.shutdown() --then it shutsdown here, this needs to be outside the loop.
end
torch = turtle.getItemCount(13)
if torch <= 1 then
os.shutdown()
fuel = turtle.getFuelLevel()
if fuel == 0 then
turtle.select(14)
turtle.refuel(1)
turtle.select(1)
end
end
end
end
end
end
end
end
Without going over it to much I think that it is because you do an os.shutdown() during your for loop that is supposed to move the turtle back to the surface. So it moves 1 spot up and shuts itself off. I've put a comment next to what I think is the offending line.
EDIT: Okay it didn't really like the spaces either… I think it may be due to how much indenting is needed due to all the nesting..
Edited on 22 December 2012 - 04:37 PM
2005 posts
Posted 22 December 2012 - 05:55 PM
Yes, remove all the shutdown for now. All of them.
12 posts
Posted 22 December 2012 - 06:38 PM
Thanks !!!
2088 posts
Location
South Africa
Posted 23 December 2012 - 12:00 AM
Thanks !!!
Is it working now?