I haven't been able to find anything already in the forum or the internet to answer my question, so I'm sorry if this has already been answered. I also don't know if this is even possible--but that's why I'm asking.
What I'm aiming to do is add two numerical variables together to create a third variable. An example of how I'm trying to make it work: there will be both strength ($str) and constitution ($con) checks throughout the story, and have both of these influence the reader's health ($health = $str + $con). As the player progresses through my tale, they will have the opportunity to increase these base attributes and thus their maximum health.
I have tried several combinations that I thought would work, from ($health eq ($con+$str)) to attempting to create a dataset. The best result that I've achieved thus far is (set: $health to ($con+$str)), which Twine produces 0 (even though I have both $con and $str defined earlier in the "init" passage).
Is this even possible with Harlowe? If not, I'll come up with a different method of determining health and the like. If, on the other hand, it is possible and I just overlooked the method, would someone be willing to point me in the right direction?
Comments
The following shows how to add two numerical values together: The following shows how to use the is operator to compare two values for equality:
(set: $health to ($con + $str))
with different styles (plus/minus spaces around the plus sign, with and without the parentheses, ect) in the first passage of my Twine story. The initial values were at zero because the reader's first choice was what gender they were, and values would change based on that. (I know, I'm being sexist. Oh well...) The passage after choosing gender shows the different values.
In other words, my story looks like this (while simplified greatly)...
Starting passage ($str and $con set at 0; $health=$con+str)
Passage where player chooses gender (for male characters, $str set at 12, $con set at 8; for female characters, $str set at 8, $con set at 12; no mention of $health)
Passage to make and see changes
When I test the story at this point, the third passage says that the player's health equals 0. Does that mean that I need to update the passage every time that a character's strength or constitution increases/decreases?
When I next get the chance, I'll try setting all the initial code from my starting passage into a startup-tagged passage and see if that resolves the issue.
a. A startup tagged passage (named Startup) that initializes the story's variables.
b. A First passage that asks the gender question.
c. A Second passage the displays the outcomes of the gender selection.
d. The CSS (in the Story Stylesheet area) needed to hide the output of the startup tagged passage.
Download the archive file and use Twine's Import From File option to add it's contents to your Story List.
My test code is:
Result:
12 = 12 ? NO
12 = 12 ? YES
Debug says:
12 $target = 1 $num1 2 $num2 $current
12 $target = 12 $test
soooo... Problem is obvious. But how can I solve it?