0 votes
by (170 points)
(I'm using a Sugarcube format for this, if that helps!) The problem seems to be that when I use <<if visited>> functions, and add the <<else>>, the <<else>> version works fine, but the <<if visited>> version gets this error message: Error: <<if>>: bad conditional expression in <<if>> clause: Unexpected string. Then it won't display the written text for the version. I"ve made sure to close it with the <<endif>>, and I'm not sure what's causing it. It'd be great if someone has a sugeestion for fixing! Thank you!

2 Answers

+2 votes
by (159k points)
selected by
 
Best answer

note: You need to include the open and close parentheses when you call a function, even when you're not passing an argument to it.
eg.
with no argument: visited()
with an argument: visited("Library")

The visited() function returns the number of times (a) specific passage(s) has/have been visited, the integer value returned will be between zero and the largest integer supported by the web-browser.

If no argument is passed to the function then it will default to the number of times the current passage has been visited, in which case the returned integer will be between one and the largest integer. Because of this fact the following example will always show "Welcome back".

<<if visited()>>Welcome back.<<else>>Welcome newcomer.<</if>>


If you want use the visited() function to determine if this is the first time that the Reader has visited the current passage then you will need to check the interger returned by the function. The following shows one way to do this.

<<if visited() is 1>>Welcome newcomer.<<else>>Welcome back.<</if>>

 

by (170 points)
thank you, I had totally forgotten to include parentheses! Guess I've been looking at the game too long :) I really appreciate it!
–2 votes
by (68.6k points)
We aren't omniscient.  Please show an actual example of the code you're having issues with.
...