Dialogue Tree : how to check what's going on with "load dialogue state"

Hello,

I’m using Dialogue tree extension in Swamp for months now, without any particular issues. Since few days, idk why i encounter an issue with the “load dialogue state” action. It’s like nothing was loaded, condition to check if a state variable is true or false just act like if nothing was in the saved state (and it was working before…).

So question : is there a way to check, somewhere (cache, local storage, anywhere or with any format), the loaded state variables and determine what is going on ?
Because the structure GVar from where i’m loading datas is totally normal, and i dont have any error on calling “load dialogue state” action.

Usually if you try load a dialogue state from an non existing GVariable (NULL), or non compatible structure Gvar, you get Javascript error in console “Failed to load state from variable” and “TypeError: Cannot convert undefined or null to object”. I dont have such error, so i’m like blind to determine what is going on.

Thank you !

:grin:
image

Proceed with logic. Is the issue project-wide, scene-wide, or variable-specific?

:smiley: project wide. Absolutely none of the actions you screenshoted above work, it’s like I loaded nothing with the action “load state vars”…

I load all states variables from a global variable (previously loaded from local storage, json convert to structure variable). My global variable is ok, when loading it, I don’t get any error. (In case of empty structure to load, or wrong structure, you get JavaScript error in console, wich is not my case).
BUT when I try to check conditions in GDevelop or in yarn dialog, it does work anymore, state variables supposedly loaded are just undefined.

I browsed the whole projected for a mistake from my side, with a “clear state variable” action somewhere, but no. I don’t understand why I encounter issue right now, whereas my logic was working perfectly few weeks ago.

So question :wink:, is it possible to check, somewhere, yarn datas in memory after they were loaded (with developper tools?). And I don’t talk about my own localstorage savegame, the issue is really with “load state variable” actions.

Well, i’ve studied a bit the repo of the extension on github, and now i can check that my loading of state vars is ok by entering in console: console.log(gdjs.dialogueTree.runner.variables.data);

It returns an object where i can check that everything is fine… So i guess this is answering my question from the first post.

Now i have to figure out why conditions on values of states variables aren’t working anymore, nor in Yarn nor in Gdevelop event sheet :sweat:

I’ve probably found a bug, or something weird, related to boolean in yarn and save/load.

When you set a boolean variable in yarn, you just make <<set myVar = true>>.

When you save the state variables, the value “true” of myVar is considered as a string in the structured datas, so saving it into a variable (then in local storage (json conversion)), you’ll get "myVar ": "true".

Then after, when loading the state variable from a structured variable, the var type is different, so, in gdjs.dialogueTree.runner.variables.data, instead of restoring:

myVar: true
The value restored is myVar: "true".

This make fails:

  1. boolean condition in Gdevelop events : the conditon check for true, not “true”. On contrary, if you check it as a string, it will work.
  2. Boolean conditions in Yarn : <<if myVar == true>> will fail, but <<if myVar == “true”>> will return true. So same thing, the type that was boolean is restored as string.

The workaround is to avoid to use any boolean in yarn, and use only string :frowning:, but since Gdevelop use only number and string types, it’s not a big issue.

Before reporting it on github, i have to check deeper if this conversion (boolean to string) is made by the save/load state variables, or by the saving of the structured variables to local storage.

EDIT : i’ve made more test. If i use in Yarn the variable type Number, then save/load it, it’s restored like a number, and not a string. So it seems in my opinion it’s Boolean related only. =>>> I’m reporting to github. Diaogue Tree: save/load, boolean are restored as strings ? · Issue #2254 · 4ian/GDevelop · GitHub

2 Likes