2023-01-27
RED keywords clarifications
Asked on Discord about const:
credits to Technic235
finalmeans the function cannot be altered any moreconstmeans function and/or argument/parameter cannot EVER be altered and will always be the same, but you can obviously set its initial - value (noconstvariables)persistentmeans the values of the variables stay forever, between save games unless manually changed via code. If the variable is - declared inside aclass, the class and variable must both be persistent for it work.staticmeans there will only ever be one instance of the function (no static variables)letis always used for declaring variables regardless of other keywords used
credits to psiberx
Redscript
public const func GREAT(): String = "something great"
credits to jekky
I think const means two things
functions marked with const can be const-evaluated and they're basically inlined locals and parameters can be marked const and I think this means they're immutable
redscript variables are lexically scoped so I think it's more like let and const in python
Redscript
class ActionWeightManagerDelegate extends ScriptBehaviorDelegate
{
const editable var actionsConditions : array< String >;
// ...
you can't have const atm.
you can use it but it has no effect (maybe other than storing a flag in the bytecode).