Problems with the Custom GUI

Started by Jakerpot, Thu 08/01/2009 23:04:24

Previous topic - Next topic

Jakerpot

Hi everybody. I'm stuck into a scripting code. I want to create a script that change the cursor mode when clicked. I have the button of Interact. I want to change the cursor to interact when player click. What script should i use? I already seen the help file, but i didnt get the right code yet. Please help me!



Ghost

#1
First of all, you need to understand that you can set the mouse mode (the mode of interaction, you can say) permanently, or you can make a click be "of a certain mode" without changing the mouse at all. This is how it's done:

1) You can set the cursor mode anywhere in your script with mouse.Mode
In your case, make it

Code: ags

mouse.Mode = eModeInteract;


2) You can also make the buttons of your mouse react differently by changing the on_mouse_click function in the global script.
There you have, by default, the left and right mouse button and can enter someting like

Code: ags

if (button == eMouseLeft)
{
  ProcessClick(mouse.x, mouse.y, eModeWalkto); 
}
else if (button == eMouseRight)
{
  ProcessClick(mouse.x, mouse.y, eModeInteract); 
}


The first example will change the mouse cursor to be "the interact cursor", meaning it changes the icon and, if you don't script it otherwise, stays in that mode.

The second example treat the click as an "interact" no matter what mode the mouse is in, and it doesn't change the mouse mode/cursor.

Jakerpot

thank you ghost! i tryed the mouse.mode but i used it wrong.



Trent R

Also, you don't even need to use scripting if you're just changing mouse modes. In the properties pane (while your button is selected) and find the ClickAction property. Change that from RunScript to SetCursorMode, then set the NewModeNumber property to whichever Interact is (most likely 2).

However, you'd have to use scripting if you're doing something like the default Inventory GUI, which uses interact mode but with the pointer cursor.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk