Posted 11 July 2014 - 02:33 AM
First off: this is my first post on this forum and I am about a week into learning lua and computercraft and turtles. I apologize in advance if I fail to use the right terms or go into sufficient detail. I tried to indent using tab (that being the only way to indent that I know of) on the code blocks but couldn't. I tried to substitute it with space but it is somewhat tedious and I would guess that there is an easier way that I do not know of, or perhaps I'm not pressing it in the right window. Would someone please explain to me what I'm doing wrong there?
I'm trying to make a program for a turtle that will cycle through all of the turtle's inventory slots and place the block and mine it until all of the gravel in the entire inventory gets turned into flint. The problem is, however, that the turtle will not keep placing and mining a stack of gravel in a given inventory slot until all of the gravel has become flint, but instead will place and mine blocks from a stack for awhile then, before very much if any of the gravel is converted into flint, move on to the rest of the inventory slots. The code looks like this:
I wrote it this way because I wanted to be able to queue more than one stack of gravel at a time. However, I also tried this:
And I am still running into the same problem. I tried adding another variable, and having the loop add 1 to it each time it ran, and then print the variable at the end to keep track of how many times the loop ran. I found that the loop only ran the original value of the item count, so I'm assuming that the turtle isn't rechecking the item count each time the loop repeats. Can someone please suggest what I should do?
I'm trying to make a program for a turtle that will cycle through all of the turtle's inventory slots and place the block and mine it until all of the gravel in the entire inventory gets turned into flint. The problem is, however, that the turtle will not keep placing and mining a stack of gravel in a given inventory slot until all of the gravel has become flint, but instead will place and mine blocks from a stack for awhile then, before very much if any of the gravel is converted into flint, move on to the rest of the inventory slots. The code looks like this:
x = 1
for i = 1,16 do
turtle.select(x)
for j = 1,turtle.getItemCount(x) do
turtle.place()
turtle.dig()
end
x = x + 1
end
I wrote it this way because I wanted to be able to queue more than one stack of gravel at a time. However, I also tried this:
turtle.select(1)
for i = 1,turtle.getItemCount(1) do
turtle.place()
turtle.dig()
end
And I am still running into the same problem. I tried adding another variable, and having the loop add 1 to it each time it ran, and then print the variable at the end to keep track of how many times the loop ran. I found that the loop only ran the original value of the item count, so I'm assuming that the turtle isn't rechecking the item count each time the loop repeats. Can someone please suggest what I should do?