0 votes
by (870 points)

I attempted to create a setup so that passages tagged with #meditate, #meditate5, #meditate10, and #meditate20 boosted the player's focus level by 1, 5, 10, and 20 points respectively. I'm having two issues with that, however. Firstly, it would double the added value for some reason (which is why in the code below I have weird values that don't match the tag number) and secondly, after it reached the #meditate20 tag, everything would increase by twenty, regardless of what the tag was. I'm not entirely sure what's wrong.

:: StoryInit

<<set $focus to 100>>

:: StoryCaption

<<nobr>><<if visitedTags("meditate")>>
<<set $focus to $focus += 1>>
<</if>>

<<if visitedTags("meditate5")>>
<<set $focus to $focus += 4>>
<</if>>

<<if visitedTags("meditate10")>>
<<set $focus to $focus += 5>>
<</if>>

<<if visitedTags("meditate20")>>
<<set $focus to $focus += 10>>
<</if>><</nobr>>

focus: $focus

 

1 Answer

0 votes
by (23.6k points)
selected by
 
Best answer

That's not how visitedTags() works. visitedTags() returns the number of all passages in the players history that have a certain set of tags. . In your case all of your <<if>> clauses will be triggered if the player has been to all of the passages in question, giving them a focus boost of 1+4+5+10=20.

Youre looking for something like this:

<<if tags(passage()).includesAny("meditate5")>>
    <<set $focus +=5>>
<</if>>

 

by (870 points)

Ohh, I see. Thank you for the explanation! I was actually just coming back to edit my post and say I'd managed to make it work, haha. I did something different, though. I've cycled through it a few times and it hasn't given me any odd addition.

<<if tags().includes("meditate")>>
<<set $focus to $focus += 1>>
<</if>>

<<if tags().includes("meditate5")>>
<<set $focus to $focus += 5>>
<</if>>

<<if tags().includes("meditate10")>>
<<set $focus to $focus += 10>>
<</if>>

<<if tags().includes("meditate20")>>
<<set $focus to $focus += 20>>
<</if>>\

 

by (23.6k points)
Now you should also be able to fuse all of your single <<if>> statements into a single one - unless your passages can have more than one of these tags.
by (870 points)
Oh, sweet! Okay, I wasn't sure if that would bork everything up, but I don't plan on using multiples of those tags on the same passage. Ty again!
...