How to run a javascript replace function with a string of a variable?


I’m trying to replace a word that appears multiple times in a text variable. Trying a yarn text replacement workaround.
And I think that for now the javascript function replace could be the only way to achieve that while we don’t have any manipulation of text that can do it.
But I don’t understand much about the call for doing that on a variable level.

Can anyone help me with this ?

In Javascript to access variables you do

var variable = runtimeScene.getVariables().get("variable name").getString();
// Do whatever you want to the value
runtimeScene.getVariables().get("variable name").setString(variable);

That was out of memory maybe I’m wrong. Use auto complete to be sure.

1 Like

Ok thank you, I’m gonna try it :slight_smile:

1 Like

I think that was the getString() to getAsString()

I know how to Load dialogue Tree from a scene variable but I don’t know how to store a json file on a scene variable.

Does anyone knows?

Json is just text, aka a string. SetString of the variable to the correct json.

sorry but I didn’t get it ^^’
I’m going to continue trying until I find, sometimes it’s just there, right in front of you and you don’t see it ahah