88 posts
Posted 05 April 2013 - 02:49 PM
Hi as many of you guys may know i finally finished my tunnel program (thanks to so many of you guys that helped me =D)
I want to add a way to handel gravel?? I have no clue how i would do that here so my current code
local tArgs = {...}
local times = tArgs[1] and tonumber(tArgs[1]) or 1
turtle.select(1)
for i = 1, times do
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
if turtle.getItemCount(16) > 0 then
turtle.select(1)
turtle.placeUp()
turtle.select(3)
for i = 3, 14 do
turtle.select(i)
turtle.dropUp()
end
turtle.select(1)
turtle.digUp()
end
end
function home()
for i = 1, times do -- notice the loop
turtle.forward()
end
end
function turn()
turtle.turnLeft()
turtle.turnLeft()
end
turn()
home()
oh ya and how do i handle lava because currently it messes up my home function
18 posts
Posted 05 April 2013 - 03:02 PM
There are multiple ways to do this. Probably one of the simplest is to check if your turtle.foward() has returned a true value. So a simple way is to write a little function
function move()
while not turtle.forward() do --this loop runs as long as turtle.forward() return false
turtle.dig() --dig its way through
sleep(0.8) --i think this is falling time of gravel
end
end
and replace all turtle.forward() with move()
88 posts
Location
Toulouse, France
Posted 05 April 2013 - 03:05 PM
There are multiple ways to do this. Probably one of the simplest is to check if your turtle.foward() has returned a true value. So a simple way is to write a little function
function move()
while not turtle.forward() do --this loop runs as long as turtle.forward() return false
turtle.dig() --dig its way through
sleep(0.8) --i think this is falling time of gravel
end
end
and replace all turtle.forward() with move()
Falling time of gravel is 0.4 ! ;)/>
88 posts
Posted 05 April 2013 - 03:18 PM
@Ninetainedo it workds great =D thanks once again because if you werent helping me i wouldnt even be close to having to tunnel i have now =D.
Thank you :)/>
88 posts
Location
Toulouse, France
Posted 05 April 2013 - 03:28 PM
@Ninetainedo it workds great =D thanks once again because if you werent helping me i wouldnt even be close to having to tunnel i have now =D.
Thank you :)/>
You're welcome ! I also did a tunnel program so I have to help you !
97 posts
Posted 06 April 2013 - 01:15 AM
There are multiple ways to do this. Probably one of the simplest is to check if your turtle.foward() has returned a true value. So a simple way is to write a little function
function move()
while not turtle.forward() do --this loop runs as long as turtle.forward() return false
turtle.dig() --dig its way through
sleep(0.8) --i think this is falling time of gravel
end
end
and replace all turtle.forward() with move()
Falling time of gravel is 0.4 ! ;)/>
Acutally I don't even think you need the sleep 0.4 as I just tested out my flatten area or room creating underground program and I didn't put the sleep in. it just waited for the gravel to fall to dig it again as it couldn't move forward.
18 posts
Posted 06 April 2013 - 03:52 AM
Acutally I don't even think you need the sleep 0.4 as I just tested out my flatten area or room creating underground program and I didn't put the sleep in. it just waited for the gravel to fall to dig it again as it couldn't move forward.
No you don't, it will still work, although it wouldn't work any faster. I would advise you to have some sort of sleep in there, otherwise you would risk a "too long without yielding" error.
15 posts
Posted 06 April 2013 - 11:07 AM
With my experiences on
while not turtle.forward() do
turtle.dig()
end
You don't need to sleep at all. The turtle can't move forward since that block space has been reserved for falling gravel. I may be wrong, but I run my bot many times a day, no issues in the desert (My testing area)
88 posts
Location
Toulouse, France
Posted 06 April 2013 - 11:17 AM
With my experiences on
while not turtle.forward() do
turtle.dig()
end
You don't need to sleep at all. The turtle can't move forward since that block space has been reserved for falling gravel. I may be wrong, but I run my bot many times a day, no issues in the desert (My testing area)
Does it dig all sand ? If I did so, my turtle would go forward before the sand to fall !
8543 posts
Posted 06 April 2013 - 12:22 PM
Without the sleep, you can occasionally get into weird situations where the turtle will be moving as the gravel starts to fall, or even move into the space completely before it can fall. This is especially noticeable on slower servers, so it is a good idea to keep the sleep in. You should also probably incorporate a turtle.attack() call.
97 posts
Posted 06 April 2013 - 03:47 PM
ah ok.
15 posts
Posted 09 April 2013 - 07:47 AM
With my experiences on
while not turtle.forward() do
turtle.dig()
end
You don't need to sleep at all. The turtle can't move forward since that block space has been reserved for falling gravel. I may be wrong, but I run my bot many times a day, no issues in the desert (My testing area)
Does it dig all sand ? If I did so, my turtle would go forward before the sand to fall !
Like I said, I've not had that issue. I don't play on many multiplayer servers, so lag may be the cause. It handles sand/gravel very well while on single-player.