OnLashoc
Member
Hello GM'ers!
So I need a better / short way to write this. This code is currently working as intended but it's super ugly and super long. Is it already as good as it gets or can it be written better and still remain within the draw event of my oCursor object?
Basically, when the oGUI object is present, and the smaller menu items oTech, oArmy, oCouncil, oVillages, and oMap (smaller windows within the oGUI window) are not present, & a node (grid square) is being hovered over, I need the selection square to be drawn. When the mouse is over the the oGUI I don't want the selection sprite drawn because it was drawing over the oGUI. With the code above, it is no longer drawing over the oGUI or the other windows as stated above so it's working, but in my mind probably not the most efficient use of GML lol, it's ugly long but it works, but could it be shortened?
Can multiple objects be passed through the !instance_exists(); statement? i.e. !instance_exists(oTech || oArmy || oCouncil || oVillages || oMap) ? *EDITED TO ADD Nope this doesn't work...
I'm sure there is the professional smartest guy in the room way, but Im self taught and still learning after a year + some months lol. Thanks in advance!
Onnie
So I need a better / short way to write this. This code is currently working as intended but it's super ugly and super long. Is it already as good as it gets or can it be written better and still remain within the draw event of my oCursor object?
Code:
if instance_exists(oGUI) && !instance_exists(oTech) && !instance_exists(oArmy) && !instance_exists(oCouncil) && !instance_exists(oVillages) && !instance_exists(oMap) && (mouse_x > oGUI.x - 463 && mouse_x < oGUI.x + 235) && (mouse_y > oGUI.y - 340 && mouse_y < oGUI.y + 250) && (hoverNode != noone){
draw_sprite (sSelected, -1, gridX * GRID_SIZE, gridY * GRID_SIZE);
}
Can multiple objects be passed through the !instance_exists(); statement? i.e. !instance_exists(oTech || oArmy || oCouncil || oVillages || oMap) ? *EDITED TO ADD Nope this doesn't work...
I'm sure there is the professional smartest guy in the room way, but Im self taught and still learning after a year + some months lol. Thanks in advance!
Onnie
Last edited: