T
Tuxerito
Guest
Hi.
I am trying to access to an array of objects created in an object(persistan) from another object but I can't do it.
For example I have 3 objects(names/variables are just examples not real)
Object 1 (Person)
name = "";
___________________
Object 2 (Game) This is a persistan object on the room 1
person = instance_create(0, 0, Person);
person.name = "Ben";
persons[0] = person;
person = instance_create(0, 0, Person);
person.name = "Tuxerito";
persons[1] = person;
___________________
Object 3 (World) this is on room 2
person = Game.persons[0];
show_message(person.name); //Here I get an error on run time ("Unable to find any instance for object index '100010' name '<undefined>'")
___________________
The problem is that I can´t get a Person object from the array stored in the Game object.
if I try to check the size of the array for example if I show a message with the size I get 2
show_message(string(array_length_1d(Game.persons)));
That work but why I can't get the object?
If I access to that array from the same object(Game) I can do it. In object Game
person = persons[0];
show_message(person.name); //Here I get "Ben"
I have another variables in the Game object and I can access/modify its values from external objects but the only problem is with array objects.
Thanks.
I am trying to access to an array of objects created in an object(persistan) from another object but I can't do it.
For example I have 3 objects(names/variables are just examples not real)
Object 1 (Person)
name = "";
___________________
Object 2 (Game) This is a persistan object on the room 1
person = instance_create(0, 0, Person);
person.name = "Ben";
persons[0] = person;
person = instance_create(0, 0, Person);
person.name = "Tuxerito";
persons[1] = person;
___________________
Object 3 (World) this is on room 2
person = Game.persons[0];
show_message(person.name); //Here I get an error on run time ("Unable to find any instance for object index '100010' name '<undefined>'")
___________________
The problem is that I can´t get a Person object from the array stored in the Game object.
if I try to check the size of the array for example if I show a message with the size I get 2
show_message(string(array_length_1d(Game.persons)));
That work but why I can't get the object?
If I access to that array from the same object(Game) I can do it. In object Game
person = persons[0];
show_message(person.name); //Here I get "Ben"
I have another variables in the Game object and I can access/modify its values from external objects but the only problem is with array objects.
Thanks.