Script for moving mouse over object

Started by FlyRider, Tue 01/11/2005 14:09:12

Previous topic - Next topic

FlyRider

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!

Ashen

You needed to look just a bit harder:
Object.GetProperty

(You may also want Hotspot.GetProperty and Character.GetProperty.)
I know what you're thinking ... Don't think that.

FlyRider

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?

Ashen

#3
Again, read the manual a bit closer:
Object.GetAtScreenXY

Also, Hotspot.GetAtScreenXY, Character.GetAtScreenXY, and GetLocationType would probably be useful too.
I know what you're thinking ... Don't think that.

FlyRider

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)

SSH

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"))...

12

Ashen

Something like:
Code: ags

// 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.)
I know what you're thinking ... Don't think that.

FlyRider


SMF spam blocked by CleanTalk