larsiusprime / polymod

Atomic modding framework for Haxe
MIT License
161 stars 62 forks source link

Abstracts cannot be passed as constants #80

Closed DotWith closed 2 years ago

DotWith commented 2 years ago

Error Log: C:/HaxeToolkit/haxe/lib/polymod/git/polymod/hscript/HScriptMacro.hx:258: characters 44-50 : Cannot use abstract as value

EliteMasterEric commented 2 years ago

For context, @DotWith was attempting to pass FlxColor into a script's context.

However, FlxColor cannot be passed to the HScript at runtime for a simple reason; FlxColor doesn't exist.

To clarify, FlxColor is not a class; it is an abstract type, which wraps the Int class. At runtime, all instances of FlxColor are replaced inline with Int values and FlxColor is basically scrubbed from existance.

One possible workaround could be to define your own static class which includes these values; this would create a constant identifier you could pass to your context.