Posted 29 January 2013 - 04:16 PM
hey everyone,
so the api i have made so far works except for one thing… i want to reset the value of the variables within the loops back to what they were originally declared as.
here is my code… the issue should be stated towards the bottom of the code.
Edit: My code requires my variables that are stated to be 0 (example: i = 0 etc..) to be reset to zero after the loop has been completed.. thats what i dont know how to do.
so the api i have made so far works except for one thing… i want to reset the value of the variables within the loops back to what they were originally declared as.
here is my code… the issue should be stated towards the bottom of the code.
Spoiler
function test2()
--Length/Width
print("Lenth/ Width:")
x = tonumber(read())
--Height
print("Height:")
y = tonumber(read())
i = 0
j = 0
k = 0
l = 0
turtle.refuel(1)
--First Horizontal
while i < x do
turtle.dig()
turtle.forward()
i = i + 1
end
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
--The remainder of Horizontal
while j < x do
while k < x - 1 do
turtle.dig()
turtle.forward()
k = k + 1
end
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
k = k + 1
while l < x - 1 do
turtle.dig()
turtle.forward()
l = l + 1
end
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
--Must reset variables somehow before repeat
end
end