Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Rulaman on Tue 06/01/2009 15:43:47

Title: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: Rulaman on Tue 06/01/2009 15:43:47
I think I found a bug.

When I get an objekt or a hotspot and try to get their name i get the Description instead.

   Object *objAt = Object.GetAtScreenXY(mouse.x, mouse.y);
   Hotspot* hotAt = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
   if ( null != objAt ) { o = objAt.ID; player.Say(objAt.Name); }
   if ( null != hotAt ) { h = hotAt.ID; player.Say(hotAt.Name); }

My player says 'Door' instead of 'oDoorRoom'

So I think this is a bug.

It would be better, if there a two properties.
.Name and .Description.

Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: Nickydude on Tue 06/01/2009 15:46:16
Edit: I was wrong, sorry about that.  ::)
Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: Khris on Tue 06/01/2009 16:19:37
Not equal is represented by "!=".

Rulaman:
You're confusing things heavily.

oDoorRoom is the internal scriptname of the object.
After your first line is called, objAt is a new pointer (type Object) pointing at the object oDoorRoom.

Thus, objAt.Name = oDoorRoom.Name = "Door", the descriptive string you've entered into the editor.

In other words, the object is called oDoorRoom (strictly internally) and has a String property called "Name" whose contents is the String "Door".

It's impossible to make the string "oDoorRoom" appear visibly in a game unless you do something completely senseless like:
  if (objAt == oDoorRoom) player.Say("oDoorRoom");

And btw, using "null != something" totally weirds me out. Why not use "something != null"?
Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: monkey0506 on Tue 06/01/2009 16:46:36
Khris is absolutely right about what the Name property contains. It's the same as Hotspot.Name, Character.Name, etc. Although...there is a Character.scrname property... ::) (an undocumented remnant of previous versions which reveals the script name of the Character)
Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: Rulaman on Tue 06/01/2009 18:12:46
@KhrisMUC

if you use in an if-query accidently something like


if ( number = 3 )
{
}

instead of the == term, your compiler does not complain.
But you get the wrong behaviour (behavior).


So i always write the constant thing first


if ( 3 = player)

because this gives me an error if i forgot the second =.

In my upper example an accidently forgotten = is always right, because of


if ( objAt = null )

is always true.

That's why i wrote this lines in such a curious way (for some persons).




@all

Now I understand this.

But my Problem is/was:
I want to use this the GlobalScript and want to query something like this


if ( (room == 1) && ( objAt == oDoor )) ...


but now i know I can't, and use my old solution with

if ( (room == 1) && ( o == 1 )) ...


because oDoor is my object 1.
Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: monkey0506 on Tue 06/01/2009 18:22:43
Actually Rulaman, AGS doesn't support the if (var = const) syntax, it produces an error. So in AGS it's perfectly safe to use the "normal" method.

Further, it is possible to use:

if (objAt == oDoor) { /* ... */ }

Why do you think it's not possible? Just because the Object structure doesn't have a method of revealing the script name directly doesn't mean you can't still compare the pointers...
Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: Pumaman on Tue 06/01/2009 19:25:47
The script name is not exposed as a property, because there's no use for getting it as a string.

Quote from: Rulaman on Tue 06/01/2009 18:12:46
I want to use this the GlobalScript and want to query something like this

if ( (room == 1) && ( objAt == oDoor )) ...

but now i know I can't

Why doesn't that work? As long as you put it in the room script it will work (the oXXXX room objects aren't available in the global script).

More to the point, what are you actually trying to achieve here? There's probably a simpler way if you tell us what you're trying to do.
Title: Re: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous
Post by: Rulaman on Tue 06/01/2009 19:38:56
Theres already a solution for this.

I looked only for a more 'descriptive way'.

So this thread can be closed.

a little example


Object *objAt = Object.GetAtScreenXY(mouse.x, mouse.y);
Hotspot* hotAt = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
if ( null != objAt ) { o = objAt.ID; }
if ( null != hotAt ) { h = hotAt.ID; }

// globig (Strg+F globig springt hierher)
// Eingangsflur Erdgeschoss [entrance hall lower]
       if (( r == 31) && (h == 1)) location = OpenCloseExtension (10, location); // Haustür [main door]
  else if (( r == 31) && (h == 2)) location = OpenCloseExtension (11, location); // Wohnzimmertür [livingroom door


This is from an MMM-Template.