WurstScript
WurstScript copied to clipboard
Gameplay constants at compiletime
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.
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:
-
Offer some sandboxed compiletime FileIO which allows u to read files inside the project dir. This would keep the current file in imports.
-
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.