BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous

Started by Rulaman, Tue 06/01/2009 15:43:47

Previous topic - Next topic

Rulaman

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.

Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Nickydude

Edit: I was wrong, sorry about that.  ::)
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Khris

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:
Code: ags
  if (objAt == oDoorRoom) player.Say("oDoorRoom");


And btw, using "null != something" totally weirds me out. Why not use "something != null"?

monkey0506

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)

Rulaman

@KhrisMUC

if you use in an if-query accidently something like

Code: ags

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

Code: ags

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

Code: ags

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

Code: ags

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


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

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


because oDoor is my object 1.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

monkey0506

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:

Code: ags
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...

Pumaman

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.

Rulaman

Theres already a solution for this.

I looked only for a more 'descriptive way'.

So this thread can be closed.

a little example

Code: ags

	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.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

SMF spam blocked by CleanTalk