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

How do I get my turtle to go right after going left last time

Started by skydude92, 07 April 2013 - 10:03 AM
skydude92 #1
Posted 07 April 2013 - 12:03 PM
Basic goal and why. I built a massive building and I made the roof glass but I don't like the glass and thought it would be fun to make turtle break and replace the pieces. So basically what I wanted him to do is start at the right side of the building, do turtle.compare() against stone bricks (outline of glass) then go left and break glass and replace in straight line then when he hit the next border, go right and continue. the problem I ran into is he just loops left. I wanted to run a while loop instead of for. What I was doing is x = x+1 and when x%2 it was a left and anything else was a right. How would I fix this to run.

http://pastebin.com/QLkSapzc
OmegaVest #2
Posted 07 April 2013 - 12:29 PM
Because what you want is x%2 == 0 or not. %, or modulus, is just an operator like + or *.

As you have it written, it's just always true, therefore it is always left.
skydude92 #3
Posted 07 April 2013 - 12:32 PM
ty. for some reason I was trying to make it check for "is divisible by 2" and I thought thats how. but that worked.