Newbie question.
I'm building in a simple health system for my character as he progresses through the story and at certain stages I deduct or add health points.
The trouble is, I don't want there to ever be negative numbers or a number over 100 ever reached. Therefore, I'd like the range or limit be 0 - 100 on the health.
My question is, how do I put that logic into the code?
Comments
You could create a basic Javascript function like the following, it takes four parameters: the current value of the variable, the amount you want to change by, the minimum allowed result, and the maximum allowed result.
Add this to your Story Javascript area.
The following tests show how to increase and decrease the value:
I thought I'd try using some additional code to what I already had to make it work.
It's probably ugly and inelegant but it appears to be working properly.
I figured since when I deduct health points I could check if it was negative and then if it was, set health points to 0. And vice versa to change it to 100 instead of over 100.
It's only slightly more coding and I can just slide it in on the end of what I already have.
This will work for my purposes.
This depends on whether you need or not to check the HP before moving to a passage. If you do, you have to include your check right after the HP change. If you don't, you can forget about it and the next passage will run the check automatically from the header passage.
As it turns out, I don't need to check it very often. Only when adding or subtracting from what it already is. So, in my case, not in very many passages.
But that's useful to know for future reference! Thanks, again.