When I start the game, it was works correctly: maxHP=30 & maxMP=100. But when I earn the level, and increase END & INT nothing happens (stats grow up BUT maxHP/MP isn’t changes).
Please, help me to work this formula or get another one.
The formulas are fine, but StoryInit only gets run once at the beginning, when the story is initialized. You just need to run them again upon level up. I don’t know SugarCube, so I don’t know the principled way to do subroutines, but if you need a workaround before someone actually knowledgeable replies, you could probably just copy and paste the two last lines.
Thanks! This is could been the temporarily solution!
IDK JavaScript, but I think it is way to get opt there.
Maybe anyone can suggest the better way with JS code?
and that would make sure that, after adding in _additionalHP, the player’s hitpoints remains within a range from 0 HP to the return value of maxHP(), inclusive.
Hope that helps!
P.S. You probably didn’t do this in your actual code, but within your generic objects make sure you don’t have a comma after the last item, like you did in your sample above with “INT: 10,”. There are a couple of older browsers which don’t like that, IIRC.
That will clamp any changes to the player’s HP/MP to between 0 and their maximum value.
Also. Since you’d no longer be using the within function, you don’t need to define it within your JavaScript section either, so you could reduce the code they supplied to just the definitions of maxHP() and maxMP().