WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Gameplay constants at compiletime

Open GetLocalPlayer opened this issue 4 years ago • 1 comments

I know that the constants are just a text file that can be placed in imports folder but Wurst does not allow us to read data from external files, does it? So we have to copy-paste the data in a wurst package to use it in runtime. So may be we can have a proper compiletime function? Something like

constant DEF_PER_AGI = compiletime(setGameplayConstant("AgiDefenseBonus", 0.15))
constant DAMAGE_NORMAL = compiletime(setGameplayConstant("DamageBonusNormal", "1.00,1.00,1.00,1.00,1.00,1.00,0.00,1.00")).split(",").map(t -> t.toReal())

Which returns the set value.

GetLocalPlayer avatar Feb 04 '20 09:02 GetLocalPlayer

In some form I should probably be added, but I'm unsure about the method. I think the setter will cause some confusion with execution order, overriding, default values and such. I think there are 2 main ideas:

  1. Offer some sandboxed compiletime FileIO which allows u to read files inside the project dir. This would keep the current file in imports.

  2. Add some package to stdlib which contains all values with defaults as configurable constants. Now we would prolly have to ignore/forbid the file in imports, since it will be overriden by wurst.

Frotty avatar Feb 04 '20 11:02 Frotty