Author Topic: BUG: Hotspot.GetAtScreenXY(mouse.x, mouse.y); Object.GetAtScreenXY(mouse.x, mous  (Read 1213 times)

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

  • The boy done good.
    • I can help with web design
    •  
Edit: I was wrong, sorry about that.  ::)
« Last Edit: 06 Jan 2009, 16:36 by Nickydude »
Best Regards,
Nickydude
www.madladdesigns.co.uk

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

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
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: Adventure Game Studio
  1.   if (objAt == oDoorRoom) player.Say("oDoorRoom");

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

monkey0506

  • AGS Project Tracker Admins
  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    •  
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)

@KhrisMUC

if you use in an if-query accidently something like

Code: Adventure Game Studio
  1. if ( number = 3 )
  2. {
  3. }
  4.  
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: Adventure Game Studio
  1. if ( 3 = player)
  2.  
because this gives me an error if i forgot the second =.

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

Code: Adventure Game Studio
  1. if ( objAt = null )
  2.  
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: Adventure Game Studio
  1. if ( (room == 1) && ( objAt == oDoor )) ...
  2.  

but now i know I can't, and use my old solution with
Code: Adventure Game Studio
  1. if ( (room == 1) && ( o == 1 )) ...
  2.  

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

monkey0506

  • AGS Project Tracker Admins
  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    •  
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: Adventure Game Studio
  1. 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

  • Creator of AGS
  • Administrator
  • Mittens Monarch
  • I sense danger.
    • Lifetime Achievement Award Winner
    •  
The script name is not exposed as a property, because there's no use for getting it as a string.

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.

Theres already a solution for this.

I looked only for a more 'descriptive way'.

So this thread can be closed.

a little example

Code: Adventure Game Studio
  1.         Object *objAt = Object.GetAtScreenXY(mouse.x, mouse.y);
  2.         Hotspot* hotAt = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  3.         if ( null != objAt ) { o = objAt.ID; }
  4.         if ( null != hotAt ) { h = hotAt.ID; }
  5.  
  6.         // globig (Strg+F globig springt hierher)
  7.         // Eingangsflur Erdgeschoss [entrance hall lower]
  8.        if (( r == 31) && (h == 1)) location = OpenCloseExtension (10, location); // Haustür [main door]
  9.   else if (( r == 31) && (h == 2)) location = OpenCloseExtension (11, location); // Wohnzimmertür [livingroom door
  10.  

This is from an MMM-Template.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.