Legacy GM Cross-referencing multiple objects variables through multiple objects

Psycho_666

Member
Hey.
Uhm... It is as convoluted as it can be an my brain hurts, so bear with me...

I have this 10x10 tiles map.
I have the map controller object, I have each tile as an object (1 tile object and all instances) and I have a database object, basically storing all the data about the map.
Then I have the card system.
I have a card object, I have a card controller object and I have database object that stores the data for each card.

Now here comes the complicated part:
When I play a card, I pull data from the card database, I compare some variables from the map controller, the map database and the tile objects, then set new data in the map database and tile objects.
It becomes a nightmare, because I end up with code like
global.tileatatus[global.mouseover.row,global.mouseover.col] = status_index
And as we all know this doesn't work. But I need to call data from the map database object through the tile I'm pointing my mouse at...

Help me out here...
How can I call variables from one object through another object without ending with multiple global.thing.anotherthing situation...

My brain hurts. I have been thinking about this for a week without writing a single line of code. I have reached the point where I set 7 variables before I reach the point I even call the one thing I must actually change...
 

samspade

Member
Your example code is confusing and seems to be in contradiction to your question. If you're using globals, you don't need to (and shouldn't be) referencing objects or instances of objects. Also, with the exception of global.mouseover.row/col there's no reason that line of code wouldn't work.

The question, "How can I call variables from one object through another object without ending with multiple global.thing.anotherthing" also doesn't make sense. That's not how objects, referencing objects, or globals work.

It might be worth reviewing:
 

Psycho_666

Member
That's not how objects, referencing objects, or globals work
That is why I asked for advice.
Global.instanceid.variable
I need the instance ID for other operations, but then I need the variable as well, and that variable may be just reference to another variable in another object, so should I just use another global variable?

It may be more fruitful just reworking the entire thing...
 
R

robproctor83

Guest
If you dont want to use globals, you can use Macros and also Enums, BUT both of those can't change in any way after running the game so they have a really limited use. BUT, you could simply make a macro that references your global, so if you had global.mylongvariable you could make a macro that references it as just G, so now you just type G instead and it references global.mylongvariable.

Now, your question about pulling object variables from another object. Well, first off, is or is not your code global.mouseover.row,global.mouseover.col correct? If so, then your code should work, if not it meas your variables for row and col are wrong. Maybe your asking how to get those variables? Well, the way I would do it is in the controller object your mousing over just add a mouse enter event and when it fires set the variables you need.
 

samspade

Member
I'm still not exactly sure what you're going for with this line:

Code:
Global.instanceid.variable
That's not valid structure and doesn't mean anything (or is at least redundant unless I'm missing something). Are you trying to link a global variable and an instance variable?
 

Psycho_666

Member
I need the instance ID for multiple changes I want to make in different objects. So global.instanceID and I can access it from all the objects I want.
I need to also change a variable inside the database I have no access to except from the instance itself so I try to change a variable in object A from object B while doing it through the instance I have the ID of ...

Yeah, I definitely need to rework this entire thing...
 

samspade

Member
I need the instance ID for multiple changes I want to make in different objects. So global.instanceID and I can access it from all the objects I want.
I need to also change a variable inside the database I have no access to except from the instance itself so I try to change a variable in object A from object B while doing it through the instance I have the ID of ...

Yeah, I definitely need to rework this entire thing...
If you have the instance id you can access it directly. You don't need to assign it to a global although I guess you could and it might be helpful in some circumstances. Either way, if you have the instance id why not do:

Code:
with (global.instance) {
    //do all the stuff you want
}
 

Psycho_666

Member
with (global.instance) { //do all the stuff you want }
Why didn't I think of that...
Thank you so much.
I was literally going to waste a week to rewrite everything.
I need it in global variable, because I need to access the I'd from multiple different objects.
 
Top