20 posts
Posted 20 May 2012 - 02:24 AM
I wish to have a turtle execute a program a specific number of times. It will dig a tunnel 1000 blocks. Would we call the "function" command or is there some other way to do it? This is the code I have thus far:
turtle.dig()
turtle.forward()
turtle.digUp()
As you can see I have the turtle API section down (the amateur section!). Your help is greatly appreciated.
474 posts
Posted 20 May 2012 - 02:28 AM
Use:
print("How many times would you like to run the code? (type it in)")
local amountOfTimes = tonumber(read())
for DoNotChangeThis=1,amountOfTimes do
turtle.dig()
turtle.forward()
turtle.digUp()
end
59 posts
Location
Washington, United States
Posted 21 May 2012 - 03:40 PM
Problem: How do you run a program a set amount of times?
Solution: Use:
print("How many times would you like to run the code? (type it in)")
local amountOfTimes = tonumber(read())
for DoNotChangeThis=1,amountOfTimes do
turtle.dig()
turtle.forward()
turtle.digUp()
end
1604 posts
Posted 21 May 2012 - 08:08 PM
Problem: How do you run a program a set amount of times?
Solution: Use:
print("How many times would you like to run the code? (type it in)")
local amountOfTimes = tonumber(read())
for DoNotChangeThis=1,amountOfTimes do
turtle.dig()
turtle.forward()
turtle.digUp()
end
I think it was pretty obious in the other two posts, you don't need to (and you shouldn't) repost someone else's solution.
20 posts
Posted 22 May 2012 - 08:55 PM
Thank you for your help.