-
Notifications
You must be signed in to change notification settings - Fork 5
Description
uhmn
I’m trying to modify values inside a static variable defined in Haxe.
Haxe does not report any error during compilation, so the code appears valid on the Haxe side.
However, the generated GDScript throws an error in Godot when incrementing a field inside that static object.
Minimal example:
Haxe Source
class GlobalGame {
public static var niz_stats = {
hp: 60
}
}
public function get_heal(heal:Int = 1):Void {
GlobalGame.niz_stats.hp += heal;
}GDScript... uh file?
var fh: Variant = GlobalGame.niz_stats
fh.get("hp") += heal # ❌ Godot throws an error here
Godot does not allow using += on the result of get(), so this generated code is invalid.
Expected GDScript (valid)
Something like:
var fh = GlobalGame.niz_stats
fh.hp += healor:
var tmp = fh.get("hp")
tmp += heal
fh["hp"] = tmpCurrent result:
Godot raises an error because it’s trying to perform += on the result of get(), which is not a settable value.
Expected result:
Valid GDScript that properly increments the field within the static object.
Additional notes:
– No errors appear on the Haxe compiler side.
– The issue only shows up once the code is translated to GDScript.
– Likely affects not only += but also -=, *=, /=, etc. (THEORETICALLY)