nml icon indicating copy to clipboard operation
nml copied to clipboard

Add: 'const' keyword to allow users to define new constants

Open glx22 opened this issue 1 year ago • 1 comments

It's possible to use named parameters as constants, but it doesn't always work and it's not very efficient in the resulting GRF when it does work.

Introduce the const keyword and const <name> = <value>; syntax, which will define the constant <name> to the value <value>.

Constants should be usable like any of the predefined constants so I delayed some validations for item and disable_item as they were happening too early.

glx22 avatar Aug 04 '23 20:08 glx22

Found a perfect use case in 030_house.

glx22 avatar Oct 05 '23 20:10 glx22

Have I understand this correctly? When not marked as const, the named parameter may be allocated a GRF parameter which is then dereferenced when used instead of simply storing the value where used.

PeterN avatar Jul 09 '24 23:07 PeterN

Exactly, named parameters are just GRF parameters, with all the implied limitations in usage.

glx22 avatar Jul 10 '24 00:07 glx22