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

For loop trouble. [solved]

Started by Thomasoien, 01 January 2013 - 04:54 PM
Thomasoien #1
Posted 01 January 2013 - 05:54 PM
i feel kind of stupid just posting this but i just cant figure for loops out, ive tried many ways setting it up but it just wont do what i want so now im here asking for help…

i highlighted what i think the problem is.



count = 0	-- Counting each dig
length = 0  -- How long it should be
rows = 0	 -- How many rows between each branch
config = 0   -- If rows and length have been configured

local function forward()
while not turtle.forward() do
turtle.dig()
sleep(0.4)
end
end
-----------------------------------
function rows()
  print "How many rows between each line?"
  write(": ")
  rows = read()
  end
-----------------------------------
function distance()
print "How long would you like the tunnel to be?"
write(": ")
length = read()
end
---------------------------------------
while true do
---------------------------------------
if config == 0 then
rows()
distance()
end
turtle.digUp()
turtle.digDown()
forward()
count = count + 1
---------------------------------------
if count == length /  2 then
turtle.turnRight()
turtle.digUp()
turtle.digDown()
forward()
---------------------------------------
-------------how many rows-------------
for rows= rows, rows do------------------------------------------------------------<<<<<<Help me
turtle.digUp()
turtle.digDown()
forward()
end
---------------------------------------
turtle.digUp()
turtle.digDown()
forward()
turtle.turnRight()
end
---------------------------------------
if count == length/1 then  --wont turn without the /1  kind of strange...
turtle.turnLeft()
turtle.digUp()
turtle.digDown()
forward()
---------------------------------------
-------------how many rows-------------
for rows= rows, rows do------------------------------------------------------------<<<<<<Help me
turtle.digUp()
turtle.digDown()
forward()
end
---------------------------------------
turtle.digUp()
turtle.digDown()
forward()
turtle.turnLeft()
---------------------------------------
count = 0
end
end
zekesonxx #2
Posted 01 January 2013 - 06:23 PM

for i = 1, rows