ink icon indicating copy to clipboard operation
ink copied to clipboard

Dynamic tags appear to not update in JS

Open tessaSAC opened this issue 2 years ago • 3 comments

I've been updating CSS based on dynamic tags, but they only appear to interpolate on the inkle side of things and not in the JavaScript.

For example:

~ temp character = "Kirby"
# LABEL: { character }
VAR character = "Kirby"
# LABEL: { character }

In both cases, these populate in Inky/in the gameplay text correctly, but when printing them in the JavaScript, show { character } rather than Kirby.

tessaSAC avatar Jun 23 '23 14:06 tessaSAC

Update: I also tried

~ temp tag = "LABEL: { character }"
# { tag }

and

VAR character = "Kirby"
VAR tag = "LABEL: { character }"
# { tag }

and those didn't work either (first one didn't interpolate, same as before; second one resulted an error about putting logic in a string)

tessaSAC avatar Jun 23 '23 15:06 tessaSAC

So I don't know how it should work. Several years ago, like two (and before 1.0 version of ink, it may not work) we made this code in a game jam

    ~timedActionID1 = "YouR Value"
     #resolveItem: timedActionID1

The timedActionID1 is a VAR that holds your value. After that there is the tag: name of the variable. However it does not work out of the box, and we had to create a special handling for it: the js went to fetch the value of the variable of the name it had. (the following is in the part of the )

        let itemId = window.STORY.story.variablesState[`${value}`];

that's the part where it transform the value of the literal timedActionID1 to the one that was variable from the ink text just over. Because JS. Once you have it, you can do whatever you want with it.

So for it to work, you have to do some logic in the js to handle the tag, and you have to be VERY careful to write exactly the name of the variable you want. But last I checked, it worked.

(especially you may have to rewrite how to read the current variable state, I think that changed., but the trick to interpret the value itself with the [`${value}`] should still work the same, as it's pure js)

Selsynn avatar Jun 23 '23 21:06 Selsynn

This is also happening in C#. For example, # {RANDOM(1, 4)} resolves in the ink player to a number, but when calling story.currentTags in C#, it just gives "{RANDOM(1,4)}"

benjaminpstern avatar Jul 16 '23 20:07 benjaminpstern