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

Cleaning area Turtle, can't figure out error in my code

Started by Maxiride, 02 June 2013 - 06:50 AM
Maxiride #1
Posted 02 June 2013 - 08:50 AM
Hi all I've made this program http://pastebin.com/AjwDykNK to flatten a certain area.

The turtle start from the bottom left corner of the rectanle and goes in a shape like and S on each layer and then goes up one block to start a new layer.

I get the bios 338 string "test":66: ')' expected but on line 66 all the () are right. Or at least I can't see the error..
A part from the formal error the code should be right but I didn't managed to run it properly..

Thanks in Advance.
Lyqyd #2
Posted 03 June 2013 - 12:39 PM
Split into new topic.
Engineer #3
Posted 03 June 2013 - 05:02 PM
We cant define an elseif statement in one go. For that, we use the and keyword. Replace line 66 with this and you should be fine:

elseif o == 1 and not j == wid then

However, if you are comparing to variables, you could use the ~= operator. It is the same as you are intending:

elseif o == 1 and j ~= wid then
--# read it like: elseif o is equal to one and j is not equal to wid, then 

:)/>

Edit: I made a small mistake in my story :P/>
Lyqyd #4
Posted 03 June 2013 - 05:07 PM
Those two lines are different. The first inverts j prior to the comparison.
GopherAtl #5
Posted 03 June 2013 - 05:13 PM
indeed, the parenthesis in "not (j==wid)" in the op's pastebin code were rather important, and got dropped in Engineer's first version. Without them, it is evaluated as "(not j)==wid"

I suspect from glancing at the code that Maxiride is unfamiliar with ~=, which is the "not equals" operator in lua, and can be used instead of "not(a==B)/>" in general.