GMS 2.3+ JSON loading problem

So in a nutshell it keeps loading and doesn't stop, I usually set how many times I want an event to happen using "ovalue" but on this occasion, it doesn't work. How would I make the step event happen once?

Player Create event :

GML:
ovalue = 0;
Player Step event :

GML:
if (ovalue == 0){
if (file_exists("savedgame.save"))
                   {
                        var _buffer = buffer_load("savedgame.save");
                        var _string = buffer_read( _buffer, buffer_string);
                        buffer_delete( _buffer);
              
                        var _loadData = json_parse( _string);
              
                        while (array_length(_loadData) > 0)

                        {

                            var _loadEntity = array_pop(_loadData);
                            with (instance_create_layer(0,0,layer,asset_get_index(_loadEntity.obj)))

                            {
                                Object1.x = _loadEntity.player_x+50;
                                Object1.y = _loadEntity.player_y+50;                               
                              
                                show_debug_message( _loadEntity.player_y)

                            }

                        }

                 }
  ovalue = 1; 
}
 

TsukaYuriko

☄️
Forum Staff
Moderator
Exactly like that.

If this doesn't do what you want it to do, find out what changes ovalue back to 0. Put a breakpoint at the ovalue = 1 line and step through your code in debug mode from there.


If you only want the Step event, an inherently repeating event, to happen once, why don't you put this code in the Create event, an event that inherently only runs once?
 
Exactly like that.

If this doesn't do what you want it to do, find out what changes ovalue back to 0. Put a breakpoint at the ovalue = 1 line and step through your code in debug mode from there.


If you only want the Step event, an inherently repeating event, to happen once, why don't you put this code in the Create event, an event that inherently only runs once?
If I put it in a create event I get an error, and I'm still trying to understand how the breakpoint works so I have to learn that but isn't there another way by using alarms?
 

TsukaYuriko

☄️
Forum Staff
Moderator
If you want us to help you with that error message, post the error message, as we can't diagnose what we can't see.

You can read more about breakpoints and debug mode in the manual.

There is indeed another way by using alarms.
I could as well convert the contents of this post to a hexadecimal ASCII representation and make you convert it to read it. But why go through the extra trouble when I can use the more direct way? ;)
 
If you want us to help you with that error message, post the error message, as we can't diagnose what we can't see.

You can read more about breakpoints and debug mode in the manual.

There is indeed another way by using alarms.
I could as well convert the contents of this post to a hexadecimal ASCII representation and make you convert it to read it. But why go through the extra trouble when I can use the more direct way? ;)
UPDATE: I got it to work it was the object parent fault, Object1 (the character) was the child of Object25 (just an object for grouping my Objects) , which was the child of Object2 , I put Object1 as the child object of Object2 and for some reason it worked does anyone know why??

Here's the previous error code :
GML:
___________________________________________
############################################################################################
ERROR in
action number 1
of PreCreate Event
for object Object25:

PerformEvent recursion depth failure - check for infinite loops, check objects for parenting
at gml_Object_Object25_PreCreate_0 (line 1) - event_inherited();
############################################################################################
gml_Object_Object25_PreCreate_0 (line 1)
gml_Object_Object1_PreCreate_0 (line 1)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object18_Step_0 (line 14)
 
Last edited:

TsukaYuriko

☄️
Forum Staff
Moderator
I create a new instance in each room
Then you will be loading the game every time you enter a new room, because every instance of Player will do so once.

Here's the error, it's really confusing
It tells you exactly what to do: "Check for infinite loops".
You have an endless loop of something recursing into itself. In this case, instance creation triggering instance creation triggering instance creation...
There's only one line that creates instances. What is it creating, and what in its code creates more of itself?
 
Then you will be loading the game every time you enter a new room, because every instance of Player will do so once.


It tells you exactly what to do: "Check for infinite loops".
You have an endless loop of something recursing into itself. In this case, instance creation triggering instance creation triggering instance creation...
There's only one line that creates instances. What is it creating, and what in its code creates more of itself?
I updated the previous message :

UPDATE: I got it to work it was the object parent fault, Object1 (the character) was the child of Object25 (just an object for grouping my Objects) , which was the child of Object2 , I put Object1 as the child object of Object2 and for some reason it worked does anyone know why??

Here's the previous error code :
GML:
___________________________________________
############################################################################################
ERROR in
action number 1
of PreCreate Event
for object Object25:

PerformEvent recursion depth failure - check for infinite loops, check objects for parenting
at gml_Object_Object25_PreCreate_0 (line 1) - event_inherited();
############################################################################################
gml_Object_Object25_PreCreate_0 (line 1)
gml_Object_Object1_PreCreate_0 (line 1)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object1_Create_0 (line 22)
gml_Object_Object18_Step_0 (line 14)
 

TsukaYuriko

☄️
Forum Staff
Moderator
The error message's "check for infinite loops, check objects for parenting" pretty much says it all.

A nondescriptly named object created a nondescriptly named object which was the child of a nondescriptly named object. A nondescriptly named object called its nondescriptly named parent's descriptively named inherited Create event via the equally descriptively named event_inherited, either implicitly or explicitly due to the absence of a Create event or presence thereof combined with the usage of said descriptively named function, which caused the nondescriptly named object's nondescriptly named parent to run code which, for reasons I am definitely not going to be able to tell you because I neither have the slightest clue about what each of these nondescriptly named objects are or do nor how I even started this sentence, creates another instance of something that leads to something that is best described as an endless loop of recursive creation.

Now, if you have any idea what on Earth I just said, consider yourself blessed, because I sure don't. If you don't, for the love of whatever is holy to you, consider properly naming your objects... :p

So yeah, let's keep it at this: You created a thing which, upon creation, creates itself. Repeat infinitely.
 
The error message's "check for infinite loops, check objects for parenting" pretty much says it all.

A nondescriptly named object created a nondescriptly named object which was the child of a nondescriptly named object. A nondescriptly named object called its nondescriptly named parent's descriptively named inherited Create event via the equally descriptively named event_inherited, either implicitly or explicitly due to the absence of a Create event or presence thereof combined with the usage of said descriptively named function, which caused the nondescriptly named object's nondescriptly named parent to run code which, for reasons I am definitely not going to be able to tell you because I neither have the slightest clue about what each of these nondescriptly named objects are or do nor how I even started this sentence, creates another instance of something that leads to something that is best described as an endless loop of recursive creation.

Now, if you have any idea what on Earth I just said, consider yourself blessed, because I sure don't. If you don't, for the love of whatever is holy to you, consider properly naming your objects... :p

So yeah, let's keep it at this: You created a thing which, upon creation, creates itself. Repeat infinitely.
Thanks for the help and explanation, I didn't really understand it too well, but I'll name them better next time 😁
 
Top