[1.21] Config Equations
SomewhatDamaged opened this issue · 2 comments
Describe the solution you'd like
I had a thought about a possibly better way to handle things like level-up equations and possibly death equations.
You could use String.format
to basically build an equation and then evaluate it as the level-up/death equations.
So, for the exponential leveling curve in 1.20.1:
String levelFunction=String.format("250 * 1.104088404342588^(1.1 * %d)",level);
Or the linear one:
String levelFunction=String.format("250 + 500 * %d",level);
Then use javax.script.ScriptEngine
to evaluate it and cache the value.
Then all the config would need is that string: "250 * 1.104088404342588^(1.1 * %d)"
Rather than the multiple variables needed, and the switch between leveling type.
Why is this feature needed
To make equations a little more friendly to edit and a lot more powerful.
Describe alternatives you've considered
Hugging Blåhaj.
Additional context
natural.1.mp4
Ah, more safe than eval. There's a java eval for math only posted over here, with a waived-rights license on it: https://stackoverflow.com/a/26227947/19846989
I don't know that i'll do a parser. The main issued (not that it's a big one) is that the expression would need to take in variables from the running game, so users would need to include those tokens in their configs. It feels easy to break from a user perspective.
I'm not going to close this though because i feel like i could safely make a custom formula through Kube/CT where the user passes in an anonymous function that takes the variables and produces a new xp value. that will take some redesign though, so not a high priority.