Comments/Ratings for a Single Item
I'm seeing this error
Syntax Error on line 287
A variable name should not begin with a digit.
@Fergus - I have a problem with the following GAME code:
set royal array; // empty array do while < #i count #myroyal: set type elem #i #myroyal; // next royal type set cnt elem #type piececount; // count them if #cnt: set nr + #nr #cnt; push royal #type; endif; inc i; loop;
The purpose was to make (from the array 'myroyal' of royal types) an array 'royal' of royals that are actually present on the board. The problem is that 'cnt' doesn't get the value zero when the key '#type' is not in the array. So the "if #cnt:" is always satisfied, and the non-present royalas get listed in the array 'royal' as well.
How could this be solved?
[Edit] I did find a solution: use "if + 0 #cnt:" instead of "if #cnt:". Apparently dereferencing a variable with value 'undefined' produces a text string, but using it as an arithmetic operand treats it as 0.
@Daniel - It appears this solves the problem in the preset, which was caused by the first piece type mentioned in the 'royal' array being a Pr, which was not present in the initial setup.
I did find a solution: use "if + 0 #cnt:" instead of "if #cnt:". Apparently dereferencing a variable with value 'undefined' produces a text string, but using it as an arithmetic operand treats it as 0.
When you place a hashtag in front of a variable name, it will return the value only if it recognizes the name, and it will otherwise return a string literal of the variable name with a hashtag in front of it. To get around this, use "if var cnt" instead.
that works, thanks
I'm seeing this error
Syntax Error on line 287
A variable name should not begin with a digit.
Can you be more precise about where you see this error? I did not see it when I checked the preset for this game.
Can you be more precise about where you see this error? I did not see it when I checked the preset for this game.
I already fixed this. It was the issue with the hashtag on an undefined variable resulting in a string.
7 comments displayed
Permalink to the exact comments currently displayed.
This preset has a problem with the black sergeants. They are unable to move forward.