Bug (?) with Game.GetLocationName

Started by TheMagician, Fri 07/11/2008 00:34:44

Previous topic - Next topic

TheMagician

I noticed a strange behaviour of "Game.GetLocationName()" but I don't know if it classifies as a bug.

Use Game.GetLocationName(player.x, player.y)  to get the name of a character or hotspot at the x- and y-coordinates of the player character.
Now test the game with F5 (which runs the game in a window) and the function works fine.
However, as soon as you move the mouse cursor (without clicking) out of the game window and then check again, the function returns an empty string ("").
As soon as you move the mouse back into the game window the function works again.

The rest of the game continues to work because the game-window doesn't actually lose focus. However this function only seems to work properly when the mouse pointer is within the game window.

Pumaman

This is an interesting spot. As far as I can tell it's nothing to do with moving the mouse out of the window, it happens when the mouse moves over a GUI (which on the default GUI will happen if you move it off the top, but not off the other sides).

Looking at the code, this is deliberate and probably dates back to when GetLocationName only worked with (mouse.x, mouse.y). But now, it does seem like a bug that it will always return blank while the mouse is over a GUI.

The problem is, it has always been like this, so I'd be a bit nervous to change it in case it broke peoples' games. I might fix it but add a backwards compatibility option to keep the old behaviour.

monkey0506

If this behavior does change (including backwards-compatibility option ;)) I would like to ask if my request regarding unnamed locations returning a whitespace string be considered as well. My idea was that since the String type supports both null as well as empty strings ("") that Game.GetLocationName could return null if there is nothing (character/hotspot/object/inventory) at the specified co-ordinates, and an empty string could be used only at times when the actual Name property of the appropriate location is not set. This as opposed to the present behavior of nothing yielding an empty string "" and an unnamed location returning " ".

Dualnames

This might have something with pixel perfect click detection?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

TheMagician

QuoteThe problem is, it has always been like this, so I'd be a bit nervous to change it in case it broke peoples' games.
^^The number of post where you have to say that has increased quite a bit recently ;)  Just shows how complex AGS has become.

It would be great if you could implement the "new" funcionality. My game really depends on it. And I thought the error only occurs in windowed mode. But if the GUIs cause the trouble it also affects fullscreen gameplay.

Pumaman

I've had a think about this, and decided that I will fix the issue that you describe, since it seems to be fairly obviously a bug based on AGS assuming that you'd only use GetLocationName with (mouse.x,mouse.y).

QuoteI would like to ask if my request regarding unnamed locations returning a whitespace string be considered as well. My idea was that since the String type supports both null as well as empty strings ("") that Game.GetLocationName could return null if there is nothing (character/hotspot/object/inventory) at the specified co-ordinates, and an empty string could be used only at times when the actual Name property of the appropriate location is not set. This as opposed to the present behavior of nothing yielding an empty string "" and an unnamed location returning " ".

I will fix the " " issue, so that an un-named object will return an empty string instead of a space.
However, changing GetLocationName to potentially return a null string would break everyone's game, and is unnecessary -- there is GetLocationType if you need to tell the difference.

monkey0506

That's fair but previously you had stated that the whole reason for the whitespace string as opposed to the empty one was to be able to tell the difference. :D

Thanks Chris.

Pumaman

Yeah, originally it was, because originally there wasn't a GetLocationType function. But now there is :)

SMF spam blocked by CleanTalk