# Adding Variable Values

This might have been asked before and I’ve missed it, but I’m wondering if there’s a way to add the maximum/minimum values of a variable automatically? For example, if I have a variable called ‘strength’ and certain options increase it, is it possible to see the maximum strength that I’ve put in the game thus far? I know there’s a way to set a maximum, I’m just wondering if there’s a way to see the maximum and minimum from options already in the story. I’ve got a notebook where I’m adding it manually so it isn’t a pressing issue; it’s just something I was curious if it’s possible.

Thanks!

So you want to automatically compute the maximum/minimum that are possible to achieve in the game? I don’t know that there’s a good way to do that. You’d have to somehow run all the passages that can change the variable, and what if you can visit some of them more than once, or some of the code is inside an `if` statement or is otherwise conditional on something else?

If all of your changes are unconditional (and positive), and all passages can only be visited once, you could probably have a special passage that you use only for testing: do the following and then print out the values of the variables. But if your stats can go up and down, or any changes can happen more than once, or only sometimes happen, then…yeah, dunno.

``````<<set _allPassages to Story.lookupWith(p => p.title !== "Whatever This Passage Is Called")>>
<<for _i, _passage range _allPassages>><<include _passage>><</for>>
``````

There are also some potential ways to design around the problem of “how big can this stat get?” which may or may not work for your game.

ChoiceScript games sometimes use Fairmath which uses a 0-100 value between two extremes, where 50/50 is neutral. It limits your value to stay between 0 and 100, and makes changes toward neutral “stronger” than ones that make you more extreme, so it’s hard to get a really extreme value of a stat: the player has to be very consistent.

Inkle studios likes to use two values per stat, sort of counting negative choices and positive choices. And then the “value” of that stat is the percent of the time (or fraction) that you chose one direction versus the other. So again, you know that the value is between 0 and 100 (or 0 and 1) and you also know that both extremes are possible. But this method solidifies the player’s position over time: the first few choices will make a big difference, but after a while your character will settle into an attitude that’s harder to change.

And probably other ways as well…

2 Likes