Hey Juju, thanks for this awesome extension! I added a feature in __snap_to_json_parser() right after the "if (alphabetise)" part that looks like:
if (variable_struct_exists(_struct, "var_names")) {
_names = _struct.var_names;
_count = array_length(_names);
}
I'm exporting JSON files for players to edit (settings, custom levels, etc) and this lets me add a line to ensure the JSON file is nice & organized for the player to play with in Notepad like:
map_data = {
var_names: ["title", "difficulty", "width", "height", "monsters"],
//^^^since "var_names" isn't in the _names[] array this line gets left out of the JSON string!
title: "Dungeon of Doom",
difficulty: 3,
width: 200,
height: 100,
monsters: [
{
var_names: ["type", "x", "y", "hp", "speed"],
//^^^never seen in final string, it's just in my monster constructor code
type: "skeleton",
x: 100,
y: 200,
hp: 30,
speed: 10
},
{
type: "zombie",
x: 100,
y: 200,
hp: 40,
speed: 20
}
]
};
...instead of some random order GML comes up with every time which would annoy players manually editing things to have to keep re-locating them, and using the alphabetical sort ends up splitting things unintuitively where height is above a big 100 object list but width ends up way at the bottom:
map_data = {
difficulty: 3,
height: 100,
monsters: [
{
hp: 30,
speed: 10
type: "skeleton",
x: 100,
y: 200,
},
{
hp: 40,
speed: 20
type: "zombie",
x: 100,
y: 200,
}
],
theme: "graveyard",
title: "Dungeon of Doom",
width: 200
};
Makes it easier to write up documentation for the player too, like "here's the explanation for each variable" and the order in the file will match the doc. Thought you might want to include this!