Using 'If' in Squiffy

if (squiffy.story.seen("Wallet")) alert ("Hey Daniella, what's your phone's password?");{else:"Hey, former boss, what's the password for your phone?"}

Above is the code I use, I'm pretty sure there's something wrong there, but I'm not sure what exactly.


Number of issues. Confusion of semi-colons. Also, you can't just put dialog in JS script.

Here's code where I make them both alerts. If you don't want them alerts, you'll have to use a set command to get the script into your squiffy flow.

[[init]]:

[[Wallet]]

[[test]]

[[Wallet]]:

This is the wallet code.

[[test]]

[[test]]:

    if (squiffy.story.seen("Wallet"))
        { alert ("Hey Daniella, what's your phone's password?");}
    else
        { alert ("Hey, former boss, what's the password for your phone?");}

BTW, I like that squiffy.story.seen trick. Didn't know you could do that.


If you're using the alert function in both cases, you could alternatively use the ternary operator ?: instead of if.

    alert (squiffy.story.seen("Wallet")
      ? "Hey Daniella, what's your phone's password?"
      : "Hey, former boss, what's the password for your phone?");

No, both of those code doesn't seem working, by the way is there a way to change the text instead of using the alert?


I think you'd need to say something like:

    if (squiffy.story.seen("Wallet"))
        { set("outStr","Hey Daniella, what's your phone's password?");}
    else
        { set("outStr","Hey, former boss, what's the password for your phone?");}

...and then use {outStr} inside your squiffy code to print out what you needed.


Which one should you check?

Wallet

Money

Phone

The 'mobile makeup kit'

Or perhaps you should do something else?

You decided to keep the money on the purse, for 'safe keeping'

Phone:⁵ You checked the phone first. Its an Iphone 11 Pro Max, the one with the 3 lens that look like a beard shaver.

Turning it on, you see that it has a number password. You turned your head towards your boss and said

if (squiffy.story.seen("Wallet")) null else null

I tried the code, it doesnt work well.


You can't use JS code in the middle of squiffy code, only at the top. To use it in the middle, try this...

{if seen Wallet: Hey Daniella, what's your phone's password?}
{else: Hey, former boss, what's the password for your phone?}

This is the pure squiffy solution. Let me know if it works.


Thank you Bluevoss, It works perfectly


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums