0 votes
by (2.4k points)

Alright so I think my issue is not too hard to resolve, and I'm pretty sure the answer exists already somewhere within this Q&A. I just couldn't find it. 

Here's the thing; I created a widget <<seen>>

 

<<nobr>><<widget 'seen'>>

<<if $seen.contains($args[0])>>
$args[2]
<<elseif $seen.contains($args[1])>>
$args[3]
<</if>>

<</widget>><</nobr>>

 

Basically, I wanted it to check what's inside my $seen array between two choices, and output text accordingly. 

That way, if I write up

<<seen 'OptionOne' 'OptionTwo' 'TextOne' 'TextTwo'>>

, if there's OptionOne in the array, it will display TextOne, and if there's OptionTwo, it will display TextTwo. 

Now the thing is, I write quite long texts within this widget, and sometimes I have to enter a character's name, contained within a variable $name.

So I tried something like 

<<seen "OptionOne' 'OptionTwo' '$name ! You fool!' '$name, you chose OptionTwo'>> 

And it doesn't print out what's inside the variable. It prints "$name ! You fool" !
I read somewhere that putting the variable within "" may work. But I tried it, and it didn't for me...
So I'm a bit lost, what can I do ? :( 

Thanks a lot,

1 Answer

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

That should have worked, so I'm going to assume that your $name variable is undefined, so try giving it a value.  The naked variable markup does not replace variables that are undefined.

And no, using double or single quotes makes no difference.  They're effectively the same thing.

 

PS:  You should be using <Array>.includes(), rather than the derecated <Array>.contains().

by (2.4k points)
Thanks a lot, indeed $name wasn't defined, and I never tried to start my story from the start with it. (In debug mode, $bfName didn't appear as a variable, so I thought it wasn't working)

What's the issue with contains(). ?
I'll use includes then, but I'd like to understand haha
...