This should be so simple.. But I'm having trouble getting my IF formatting to work.
[[Cave]]:
{if CaveVisited=false:You duck down and enter the cave.}
@set CaveVisited=true;
This cave is a natural limestone structure, carved out over centuries by water erosion...
On first visit, the "You duck down and enter the cave" part is not working.
CaveVisited does get set to true after entering the cave.
What am I doing wrong here?
My real goal is to have that top line displayed when you come from outside and enter the cave. But NOT when you come from deep within the cave to the cave entrance. Is there a way to key off of the last room visited before this room?
Thanks!
Hello Cypher, can you post here the sections that changed the CaveVisited attribute?
Hello manowar.
Currently, no section changes it until it is checked in the Cave section. the attribute doesn't exist before it's checked. I'm assuming all attributes, uncreated, start off false?
The only spot it is changed, currently, is the one displayed where it's set to true.
Here's a shortened version of my full program. None of my IF's are working. The If Not Seen's are not working. and the If attribute check is not working. I'm using the Desktop Version.
@title Test
@start Login
[[Login]]:
@set CaveVisited = false;
When you are Ready... [[Start Here]](Start)
[[Start]]:
{if not seen Start:@clear}
{if not seen Start:You Awake... You aren't sure how you got here... }
You find yourself in the middle of a leafy deciduous forest in early fall. It's a warm day...
[[SouthForest]] [[NorthForest]]
[[NorthForest]]:
You travel through the forest, each step crunching lightly on the crisp, fallen leaves...
[[SouthForest]] [[Cave]]
[[SouthForest]]:
Head Back to the [[North]](Start).
[[Cave]]:
{if CaveVisited=false:You duck down and enter the cave.}
@set CaveVisited=true;
This cave is a natural limestone structure, carved out over centuries by water erosion...
Try this code:
@start other
[[other]]:
@set CaveVisited=false
go to the [[Cave]]
[[Cave]]:
window.setTimeout(function(){ squiffy.set("CaveVisited", "true"); }, 500);
{if CaveVisited=false:You duck down and enter the cave.}
This cave is a natural limestone structure, carved out over centuries by water erosion... go to the [[deep]] or [[exit]](other)
[[deep]]:
go to the [[Cave]]
I did a little testing. If I set CaveVisited to true in the NEXT section. It works as intended. But if I set CaveVisited to true in the Cave Section.. even if it's set AFTER the If Attribute check.. it fails. The check thinks CaveVisited is true.
Thanks manowar. I bet that will work... But I wonder why I'd have to put the delay in there? I thought it would parse things linearly, but maybe not? Will it really change a variable after an IF statement even if the If Statement hasn't been evaluated yet?
Weird...
The assignment of the attribute (@set) is being done before it evaluates if so it is never fulfilled, hence we give a delay to the assignment so that just when entering even has its correct value.
Gotcha, thanks. So.. I guess a whole section is read at once, and variable assignments are done instantly, and then the logic and display happens?
just want to make sure I understand it for the future. Coming from a C# background, that's way different than what I'm used to :)