Legacy GM set object name to variable

V

VansiusProductions

Guest
hi
I have a code:
Code:
if (position_meeting(mouse_x,mouse_y,obj_air)) {
    global.elementHover = "air"
}
if (position_meeting(mouse_x,mouse_y,obj_earth)) {
    global.elementHover = "earth"
}
if (position_meeting(mouse_x,mouse_y,obj_fire)) {
    global.elementHover = "fire"
}
if (position_meeting(mouse_x,mouse_y,obj_water)) {
    global.elementHover = "water"
}
Is there anyway to simplify it so that i can do:
Code:
if (position_meeting(mouse_x,mouse_y,obj_<name>)) {
    global.elementHover = <name>
}
 
B

BeastyBoy

Guest
you could set a variable in each of the object events that is the name, but other than that I don't see a reason why you would need to simplify this, it looks like it's as simple as it gets.
 
V

VansiusProductions

Guest
you could set a variable in each of the object events that is the name, but other than that I don't see a reason why you would need to simplify this, it looks like it's as simple as it gets.
Because I have tons of them
 
B

BeastyBoy

Guest
if it helps, then making each one of the element objects have a create event with a variable called like "element" and making it whatever string you want it to be, like:

Code:
///obj_air create event

element="Air"
And same with the others.
 
V

VansiusProductions

Guest
if it helps, then making each one of the element objects have a create event with a variable called like "element" and making it whatever string you want it to be, like:

Code:
///obj_air create event

element="Air"
And same with the others.
So I still have to manually set the variable value for each one? Alright then :p
I am using the parenting system
 
Top