Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FlyRider on Tue 01/11/2005 14:09:12

Title: Script for moving mouse over object
Post by: FlyRider on Tue 01/11/2005 14:09:12
I want the cursor to change mode when it moves over an object, depending on what property value the object has.

For example: If the cursor moves over "object 1"  that has the value of "property 1" set to "0" nothing should happen. But If it moves over "object 2" that has "property 1" set to "1" the cursor mode should change to MODE_LOOK. I've been searching for a function like GetLocationProperty or something but it doesn't appear to exist. There must be another way around!
Title: Re: Script for moving mouse over object
Post by: Ashen on Tue 01/11/2005 14:21:30
You needed to look just a bit harder:
Object.GetProperty (http://www.adventuregamestudio.co.uk/manual/Object.GetProperty.htm)

(You may also want Hotspot.GetProperty and Character.GetProperty.)
Title: Re: Script for moving mouse over object
Post by: FlyRider on Tue 01/11/2005 14:27:09
I've seen that command, but how do I make that function get the property value of the object that is under the mouse pointer?
Title: Re: Script for moving mouse over object
Post by: Ashen on Tue 01/11/2005 14:31:05
Again, read the manual a bit closer:
Object.GetAtScreenXY (http://www.adventuregamestudio.co.uk/manual/Object.GetAtScreenXY.htm)

Also, Hotspot.GetAtScreenXY, Character.GetAtScreenXY, and GetLocationType would probably be useful too.
Title: Re: Script for moving mouse over object
Post by: FlyRider on Tue 01/11/2005 14:45:40
Ok, sorry, I did't know what keywords to use. ;)

So is this what I'm gonna do?:

if (object[(Object.GetAtScreenXY(mouse.x,mouse.y)].GetProperty(1)

SetCursorMode(MODE_LOOK)
Title: Re: Script for moving mouse over object
Post by: SSH on Tue 01/11/2005 14:54:40
Usually an easier way of doing this is to set different interactions for the different types of object/hotspot/etc. and use IsInteractionAvailable

However, if you want to use properties, use:

if (Object.GetAtScreenXY(mouse.x,mouse.y).GetProperty("1"))...

N.B. All properties have string names
N.B.#2 Also, you may find that it doesn't path, in which case you may need to do:

Object *tmp=Object.GetAtScreenXY(mouse.x,mouse.y);
if (tmp.GetProperty("1"))...

Title: Re: Script for moving mouse over object
Post by: Ashen on Tue 01/11/2005 15:01:30
Something like:

// in rep_ex
Object *theObj = Object.GetAtScreenXY(mouse.x, mouse.y);
if (theObj != null) { // Check there is an object there
  if (theObj.GetProperty("property1") == 1) mouse.Mode = eModeLookat;
  // else if ... for other modes, if needed 
}

else mouse.Mode = eModeWalkto; // Or whatever you want to happen with no Object at (mouse.x, mouse.y)


(SSH posted while I was typing, but this is the full version.)
Title: Re: Script for moving mouse over object
Post by: FlyRider on Tue 01/11/2005 21:53:17
Thanks, worked well.