poryscript icon indicating copy to clipboard operation
poryscript copied to clipboard

Support `true` and `false` as valid comparison values for `var` operator

Open PCG06 opened this issue 1 year ago • 2 comments

Title.

I created a new macro and added its case to AutoVar, and then used it in my pory script. But it gave me an error because of == true.

-        if(islevelcapactive == true) {
+       if(islevelcapactive) {
            setvar(B_LEVEL_CAP_VARIABLE, 17)
        }

Error if used == true:

data/maps/CastbellePath/scripts.pory: Assembler messages:
data/maps/CastbellePath/scripts.pory:246: Error: non-constant expression in ".if" statement
data/maps/CastbellePath/scripts.pory:81:  Info: macro invoked from here

PCG06 avatar Oct 23 '24 15:10 PCG06

This is actually not a bug--Poryscript has always worked this way with var comparisons. Lowercase true only works with flag and defeated.

image

There may be an argument to automatically detect true/false and handled them gracefully, though. I'll re-purpose this issue to handle that. I'm surprised nobody has ever complained about this.

huderlem avatar Nov 05 '24 01:11 huderlem

This is actually not a bug--Poryscript has always worked this way with var comparisons. Lowercase true only works with flag and defeated.

image

There may be an argument to automatically detect true/false and handled them gracefully, though. I'll re-purpose this issue to handle that. I'm surprised nobody has ever complained about this.

My bad! I thought true also worked for vars!

PCG06 avatar Nov 07 '24 12:11 PCG06