[Solved] Is there a way to save all the child variables of a Structure more easily? + Centering text objects?

So, it’s been a while and I got no responses, BUT I’ve figured out the answer for both of these questions already, gladly! I found the answer for the first one in the Wiki, and the answer for the second one in a thread in this forum.

A way to save Structures more easily in the Storage would be by converting it to a JSON string with an expression and writing it in the Storage as a text, and the way to load it would be by reading the text from the Storage into the string of a scene variable, which is not yet a structure, but rather just the raw JSON string - and parsing it into a Structure variable with the “Convert JSON to Global Variable” action found in Network. It’d look something like this:

// Save //
Write GlobalVarToJSON(YourStructure) on "Structure" of storage "A"

// Load //
Read "Structure" from storage "A" and store as text in "StructureJSON"
Parse JSON string VariableString(StructureJSON) and store it into global variable "YourStructure"

It doesn’t need to be a Global Variable, obviously, the same works for scene variables. It’s really neat and definitely makes things much easier, I love it!

And for the answer of the second question - how to center a text - I’m not yet sure how I can make the text inside the text object to be centered, but I know how to center the text object itself within the screen or within another object.

Centering the Text object within the screen:

Do = SceneWindowWidth() / 2; = SceneWindowHeight() / 2 to the position of Text

Centering the Text object inside another object:

Do = NewObject.X() + (NewObject.Width()/2) - (Text.Width()/2) ; = NewObject.Y() + (NewObject.Height()/2) - (Text.Height()/2) to the position of Text

Both using the “Position of an object” action found in “Common Actions For All Objects > Position”. It’s a good way to keep the Text centered when the text string keeps on changing.
I hope this helps someone at least! I’m loving the program so much so far!

10 Likes