0 votes
by (120 points)
Willpower: <<set $pcWill to 10>>\
<<button "-">>
	<<if $pcWill gt 0>>
		<<set $pcWill--, $Stats++>>
		<<replace "#stats-will">>$pcWill<</replace>>
		<<replace "#stats">>$Stats<</replace>>
	<</if>>
<</button>> \
<span id="stats-will">$pcWill</span> \
<<button "+">>
	<<if $pcWill lt 20 and $Stats gt 0>>
		<<set $pcWill++, $Stats-->>
		<<replace "#stats-will">>$pcWill<</replace>>
		<<replace "#stats">>$Stats<</replace>>
<</if>>
<</button>>


<span id="ccwillfeedback">How strong is my willpower?</span>.

<<link "Feedback">>
You have a <span id="ccwillfeedback">$ccWillfeedback</span> Will.


	<<if "#stats-will" lte 5 and gt 0>>
<<replace "#ccwillfeedback">>//Broken//<</replace>>

	<<elseif if "#stats-will" gt 5 and lte 10>>
<<replace "#ccwillfeedback">>//Focused//<</replace>>
	

	<<elseif "#stats-will gt 10 and lte 15>>
<<replace "#ccwillfeedback">>//Resolved//<</replace>>
	

	<<elseif "#stats-will" gt 15 or lte 20>>
<<replace "#ccwillfeedback">>//Tenacious//<</replace>>
	
	<<else>>
	I cannot properly assess this yet.
	<</if>>

<</link>>

 

I am trying to set this up so that, the link will give different feedback depending on the the character's will stat. I am trying to do all of this in one passage. Is it even possible? Whenever I press on the link it sends me an error message saying that there are bad conditional expressions in <<if>>. I'm not sure what I am doing wrong.

 

1 Answer

0 votes
by (159k points)

note: Your exampe doesn't include an HTML element with the ID of stats, I will assume that this element actually exists within the generated page.

There are a number of issues with your example:

1. You are trying to reference the HTML element with an ID of stats-will as if it was a variable.

This won't work, and doing so is unecessary because that element is just displaying the current value of your $pcWill story variable, which is what you should be referencing within the conditional expressions of your <<if>> related macros.

2. The syntax of your multi-part conditional expessions are invalid.

3. The conditional expression of your third <<elseif>> macro contains an or operator instead of an and.

Try replacing the <<if>> related macros with the following.

	<<if $pcWill gt 0 and $pcWill lte 5>>
		<<replace "#ccwillfeedback">>//Broken//<</replace>>

	<<elseif $pcWill gt 5 and $pcWill lte 10>>
		<<replace "#ccwillfeedback">>//Focused//<</replace>>
	
	<<elseif $pcWill gt 10 and $pcWill lte 15>>
		<<replace "#ccwillfeedback">>//Resolved//<</replace>>
	
	<<elseif $pcWill gt 15 and $pcWill lte 20>>
		<<replace "#ccwillfeedback">>//Tenacious//<</replace>>
	
	<<else>>
		I cannot properly assess this yet.
	<</if>>

warning: The above example has not been tested.

by (120 points)
Thank you for the reply! It worked like a charm!
...