Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jakerpot on Thu 08/01/2009 23:04:24

Title: Problems with the Custom GUI
Post by: Jakerpot on Thu 08/01/2009 23:04:24
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!
Title: Re: Problems with the Custom GUI
Post by: on Thu 08/01/2009 23:22:21
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


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


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.
Title: Re: Problems with the Custom GUI
Post by: Jakerpot on Thu 08/01/2009 23:47:00
thank you ghost! i tryed the mouse.mode but i used it wrong.
Title: Re: Problems with the Custom GUI
Post by: Trent R on Fri 09/01/2009 00:00:16
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