Can I use expression literals with squiffy attributes?

Hello, I just found squiffy today and have no experience with JS, so I don't know where the problem is. I have an attribute P1 which depends on the character the player chooses, and I was wondering if I could something like

[[start]]:
    var event1  = [`${P1} claims he is almost a God`];
    squiffy.set("text", event1[0]);

{text}

to print a string in my array with the name of the character. I want it to be an array because I want to randomly select one of the entries to print (a problem for another time, but is this possible?).
I guessed it something like this would work by looking at some posts in this forum, but nothing happens when I get to the first line after [[start]]. If I remove the $ it just prints "{P1} claims..."

Any help would be appreciated :)


Hello.

Try something like this:

@set P1 = Deacon Frost

[[test]]

[[test]]:
    var event1  = [`${squiffy.get("P1")} claims he is almost a God.`];
    squiffy.set("text", event1[0]);

{text}

image


Hey, it worked!
And very fast reply too, wasn't expecting it, thanks a lot! You actually are almost a God :D


KV is. I'm only a minor demon who shows up late to the action. Anyway, welcome to Squiffy!


Whoops...

I originally posted @set P1 = KV, just because my name happened to be the first one that came to mind to put in example code.

After I posted it, I realized it ended up saying, "KV claims he is almost a god," and I would never claim such a thing, as I do not believe in gods (although goddesses are a different story altogether, but I digress). So, I edited the post and changed KV to Deacon Frost (for those who don't get the reference, Deacon Frost is the villain in the first Blade movie, but I digress again).

Anyway, carlsagan (not to be confused with Carl Sagan (R.I.P.)) replied to my original post sometime between me clicking "Edit" and me clicking "Post Reply". So, carlsagan was actually referencing my original post when posting that I actually am almost a god.

So, my post-editing sort of messed up the joke. (Doh!)


You could also do something like:

[[start]]:
    var event1  = ["{P1} claims he is almost a God"];
    squiffy.set("text", squiffy.ui.processText(event1[0]));

{text}

using Squiffy's attribute interpolation rather than raw JS. This could be useful in some situations, for example if you might want to change the value of P1 later.

Silly example:

[[start]]:
    window.event1  = ["{P1} claims he is almost a God"];

[[page2]].

[[page2]]:
    squiffy.set("text", squiffy.ui.processText(event1[0]));

@set P1 = KV
{text}

[[page3]].

[[page3]]:
    squiffy.set("text", squiffy.ui.processText(event1[0]));

@set P1 = Richard Tater

{text}

Log in to post a reply.

Support

Forums