Advertisement

Using const global properties in case statements

Started by July 30, 2024 01:30 PM
1 comment, last by WitchLord 3 months, 3 weeks ago

So it appears that using a const global property in a case statement results in the “Case expressions must be literal constants” error being thrown. Is this intentional or a bug?

Edit: nevermind, saw the change log for 2.36.1 which answers that question!

Yes it is intentional. Registered global properties are treated just as normal values, because even though they are const to angelscript the application can still change the value.

I have plans to add support for registering true literal constants, but for now the are two options:

1. Register the constant as an enum value

2. add a script section with the literal constants

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement