huderlem / poryscript

High-level scripting language for gen 3 pokemon decompilation projects
https://www.huderlem.com/poryscript-playground/
MIT License
197 stars 22 forks source link

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

Open PCG06 opened 1 month ago

PCG06 commented 1 month ago

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
huderlem commented 2 weeks ago

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.

PCG06 commented 2 weeks ago

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!