Context Sensitive Cursor.

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Fallen
Posts: 36
Joined: Mon Jul 17, 2006 3:41 pm
Location: Waxhaw, NC

Context Sensitive Cursor.

Post by Fallen »

I am trying to make my cursor/crosshair context sensitive ... I've kind of gotten it to work...

What my intentions are is when I look at something my cursor changes to an icon that tells me the type of interaction "using" that object will achieve. Picking it up, talking to it, examining it and so on.

So far i made a script that uses:

Code: Select all

SetPlayerWeapon(int WeaponSlot# );
To change weapon types when certain triggers are true ... I don't know if this is the best way, but it is how I've come up with doing it. (please suggest better ways if you have them).

The issue I have is I can't get the triggers to turn true when my cursor is over the entity in question. Only when I touch it or use it. Which defeats the purpose to a certain extent.

I thought using some of the distance options like:

Code: Select all

bool CheckArea(char *FromEntityName, char *ToEntityName, bool DistanceMode, float MinScreenX, float MaxScreenX, float MinDistance/MinScreenY, float MaxDistance/MaxScreenX, bool IgnoreX, bool IgnoreY, bool IgnoreZ);
might be useful ... but haven't seemed to have any luck so far ... I'll keep trying, just thought i'd ask.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

To change weapon types when certain triggers are true ... I don't know if this is the best way, but it is how I've come up with doing it. (please suggest better ways if you have them).
That's a good way, unless you want to have more than one weapon... You would have to make several versions of every weapon and that's a lot of work!

A better way is to define the different cursors as hud elements and then use the ActivateHudElement() command to activate them.
Another way is to define the bitmaps in a flipbook and then draw them on the screen with the DrawFlipBookImage() command.



The MouseSelect() command comes handy here too. It's supposed to return the EntityName of the entity over which the mouse cursor is (I've never gotten it to work...). You could name your entitys like "button1_use" and use the new RightCopy() command like this:

Code: Select all

if(RightCopy(MouseSelect(false),3) = "use")
{
     ActivateHudElement("usecursor",true);
}
So it checks if the last 3 letters of the entity, that the mouse points at, are "use" and then activates the right hud element.
Pain is only psychological.
User avatar
Fallen
Posts: 36
Joined: Mon Jul 17, 2006 3:41 pm
Location: Waxhaw, NC

Post by Fallen »

hmm ... awesome feeback! I will go try to put it to work as soon as I can ... hope I can get MouseSelect to work better than the distance functions.
User avatar
Fallen
Posts: 36
Joined: Mon Jul 17, 2006 3:41 pm
Location: Waxhaw, NC

Post by Fallen »

Wow ... that was quick and painless ... works like a charm! Thanks Juutis!
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

Juutis wrote:The MouseSelect() command comes handy here too. It's supposed to return the EntityName of the entity over which the mouse cursor is (I've never gotten it to work...)
I think the MouseSelect() command only works when the thing the mouse is over; is either a pawn, an attribute, or a staticentityproxy - but it is important that it does has collision applied (because i figured all it does is a TraceLine() command from the camera in rotation xyz)


Also remember i had got some problems which cause i don't know when i specified less than 2 parameters.
Everyone can see the difficult, but only the wise can see the simple.
-----
Post Reply