Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

[SOLVED] nested ternary operators violating GM conventions

A topic by bowsette_game created Apr 15, 2019 Views: 161 Replies: 4
Viewing posts 1 to 2
(1 edit)

I'm trying to compile a project using the following command:

haxe -debug -lib sfhx -lib sfgml -cp src -js ../extensions/ -main Class -dce full -D sfgml-assets-path=../ -D sfgml_snake_case -D sf_pretty -D sfgml_local=_

It compiles successfully from Haxe, but the generated code uses ternary operators, which is throwing errors when compiling the GMS1 project. I double checked the build.hxml file and sfgml_next isn't present.

However, if I target a .gml file, the compiler replaces ternary operators with the if;else equivalent code, and it works fine. I've also noticed that targeting the gmx._ file seems to get rid of auxiliary local variables and substitutes them for their values.


What GMS1 version are you using? Ternary operators are supported in extensions from 1.4.1763 and onwards.

If you need to target an ancient version, define sfgml_version=1.4.1700 or whatever

(4 edits)

I'm using 1.4.9999.

This is the error:

Error : got '?' expected ')'

Edit: putting a few more bracers in the generated code solved it. Essentially, there is a statement with multiple ternary operators, and I changed them like that:

(a) ? b : c --> ((a) ? b : c)

And it worked perfectly afterwards. Any idea on why it doesn't work out of the box?


Pushed a fix for that on git.

Wow, thought this was complicated and wasn't expecting a fix that fast. Many thanks!