How to compare two variables in Squiffy?

0 votes
167 views
asked Apr 19 in Authoring by Natas (17 points)

What would be the best way to compare two variables?

{ if varOne == varTwo: [blah blah]}{else: }

This doesnt seem to work for me in Squiffy. It pulls up an error.

1 Answer

+1 vote
answered Apr 20 by Alex (486 points)
selected Apr 21 by Natas
 
Best answer

You need to use JavaScript for this. You could set a new attribute to true or false to tell you if the two attributes are the same. For example:

@set a=2
Try two variables the [same](next, b=2) or [different](next, b=3).

[next]:
    set("same", get("a") == get("b"));

a = {a}, b = {b}, same = {same}.

This sets the value of "same" to true or false, depending on whether the values of "a" and "b" are the same.

Live example: http://docs.textadventures.co.uk/squiffy/scratchpad/?gistid=68b9556d84d3ffc127e4&filename=same.squiffy

commented Apr 21 by Natas (17 points)
I wish I could give you a bonus for teaching me the neat (next, b=3) trick as well.
commented Apr 21 by Natas (17 points)
There is a bit of a problem. Why doesnt the code.

{if same=true: Placeholder text}{else: } not works?
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...