Inspecting a Structure

I’m using the GPS extension, but my issues are to do with HOW does one inspect a structure. Writing it to the logger just puts [Structure]

I save the result of the GPS position call to a Scene Variable called gps result.

I want to discover what the, er, structure of the Structure is…what the children are called…

I discovered I can sort of browse the item in the debugger, (which is cool) but is the path the value …


If I do this I get this error

A bit stuck…

I’ve never used the GPS but to use the variable you need to either setup the variable as a structure and add the children names or use Variable(gpsResult.latitude) or VariableString(gpsResult.latitude) to display it in the text box. It’s weird that it doesn’t have built-in expressions to return the value.

You can only use the shortened version if the variable and its children are set up.

Variable screen

The value doesn’t matter, the extension will set it. I just wanted to be sure it was working. So, I used 123. You would need to use the variable name and add all of the children. It would probably be easier just to use Variable() depending on how often you used the variable.

You can inspect a structure easily by converting it to its JSON representation: ToJSON(gpsResult)
As keith said, if you want to use a variable directly, it must be defined. If you want to use it without declaring the variable, you must get them using the Variable()/VariableString() expressions.

Ah thanks both…

Somewhere it said if a sub attribute of structure wasn’t there, it would get created, but maybe not it seems… But with ToJSON → logged out, I can then see what the attributes are and pre-prepare my structure… I think.

I’ve found a way to make this work, but I have to give a sizeable deley between sending the call for gps position (10 seconds) and then using the structure… like this…

This is fine, but is there a way to make an Action block, or wait until it is finished perhaps? Actually this would stop any animation whilst it waited wouldn’t it?



I suppose you may be looking into converting an event to an asynchronous event Asynchronous events - GDevelop documentation

Ah, thank you… I haven’t got to those yet… still learning and trying to implement every feature to find out what it does before I build something bigger.