Contents Up Previous Next

Mouse functions and properties

ChangeModeGraphic
ChangeModeHotspot
ChangeModeView
DisableMode
EnableMode
IsButtonDown
SaveCursorUntilItLeaves
SelectNextMode
SetBounds
SetPosition (mouse)
Update
UseDefaultGraphic
UseModeGraphic
Mode property (mouse)
Visible property (mouse)


ChangeModeGraphic

(Formerly known as ChangeCursorGraphic, which is now obsolete)

Mouse.ChangeModeGraphic(CursorMode, int slot)
Changes the specified mouse cursor mode's cursor graphic to SLOT. This permenantly changes the specified mode's cursor graphic. This function may be useful if you need more than the maximum number of mouse cursors.

Example:

mouse.ChangeModeGraphic(eModeLook, 120);
will change the cursor’s graphic for look mode to the image that's imported in the sprite’s manager slot 120.

See Also: Mouse.ChangeModeHotspot, Mouse.ChangeModeView, Mouse.Mode


ChangeModeHotspot

(Formerly known as ChangeCursorHotspot, which is now obsolete)

Mouse.ChangeModeHotspot(CursorMode, int x, int y)
Permanently changes the specified mouse cursor mode's hotspot on the cursor graphic to (X,Y). This is the offset into the graphic where the click takes effect. (0,0) is the upper left corner of the cursor graphic.

Example:

mouse.ChangeModeHotspot(eModeWalkto, 10, 10);
will change the cursor’s hotspot for walk mode to coordinates 10,10.

See Also: Mouse.ChangeModeGraphic, Mouse.ChangeModeView


ChangeModeView

Mouse.ChangeModeView(CursorMode, int view)
Changes the specified mouse cursor mode's animation view to VIEW.

You can pass view as -1 to stop the cursor from animating.

This allows you to dynamically change the view used for the cursor's animation while the game is running.

Example:

mouse.ChangeModeView(eModeLook, ROLLEYES);
will change the Look cursor's view to ROLLEYES.

See Also: Mouse.ChangeModeGraphic, Mouse.ChangeModeHotspot


DisableMode

(Formerly known as DisableCursorMode, which is now obsolete)

Mouse.DisableMode(int mode)
Disables the mouse cursor MODE. Any attempts to set the cursor to this mode while it is disabled (such as using UseModeGraphic) will fail. This function also greys out and disables any interface buttons whose left-click command is set as "Set mode X", where X is equal to MODE.

If the current cursor mode is MODE, then the engine will change it to the next enabled standard cursor.

Example:

mouse.DisableMode(eModeWalkto);
will make the walk mode unavailable until it's enabled again.

See Also: Mouse.EnableMode


EnableMode

(Formerly known as EnableCursorMode, which is now obsolete)

Mouse.EnableMode(int mode)
Re-enables the mouse cursor mode MODE. This function also enables any interface buttons which were disabled by the DisableMode command.

Example:

mouse.EnableMode(eModeWalkto);
will enable cursor mode walk which was disabled before.

See Also: Mouse.DisableMode


IsButtonDown

(Formerly known as global function IsButtonDown, which is now obsolete)

Mouse.IsButtonDown(MouseButton)
Tests whether the user has the specified mouse button down. BUTTON must either be eMouseLeft or eMouseRight (the middle button does not work with this function). Returns 1 if the button is currently pressed, 0 if not. This could be used to test the length of a mouse click and similar effects.

Example:

int timer=0;  // (at top of script file)
if (mouse.IsButtonDown(eMouseRight)) {
  if (timer == 40) {
    Display("You pressed the right button for 1 sec");
    timer = 0;
  }
  else {
    timer++;
  }
}
will display the message if the player presses the right button for 1 sec.

See Also: IsKeyPressed


SaveCursorUntilItLeaves

(Formerly known as SaveCursorForLocationChange, which is now obsolete)

Mouse.SaveCursorUntilItLeaves()
Saves the current mouse cursor, and restores it when the mouse leaves the current hotspot, object or character.

This allows you to temporarily change the mouse cursor when the mouse moves over a hotspot, and have it automatically change back to the old cursor when the player moves the mouse away.

NOTE: You must call this BEFORE you change to your new temporary cursor, or the new cursor will be saved by this command.

Example:

mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeTalk;
will change the cursor mode to Talk for as long as the mouse is over the current object

See Also: Mouse.Mode


SelectNextMode

(Formerly known as SetNextCursorMode, which is now obsolete)

Mouse.SelectNextMode()
Selects the next enabled mouse cursor mode. This is useful for Sierra-style right-click cycling through modes. This function will choose the next mode marked as a Standard Mode, and will also use the Use Inventory mode if the player has an active inventory item.

See Also: Mouse.Mode


SetBounds

(Formerly known as SetMouseBounds, which is now obsolete)

Mouse.SetBounds(int left, int top, int right, int bottom)
Restricts the area where the mouse can move on screen. The four parameters are the relevant pixel co-ordinates of that edge of the bounding rectangle. They are in the usual range (0,0) - (320,200).

You can pass (0,0,0,0) to disable the bounding rectangle and allow the mouse to move everywhere, as usual.

NOTE: The effect of this function only lasts until the player leaves the screen, at which point the cursor bounds will be reset.

Example:

mouse.SetBounds(160, 100, 320, 200);
will restrict the mouse cursor to the bottom-right quarter of the screen.

See Also: Mouse.SetPosition


SetPosition (mouse)

(Formerly known as SetMousePosition, which is now obsolete)

Mouse.SetPosition(int x, int y)
Moves the mouse pointer to screen co-ordinates (X,Y). They are in the usual range (0,0) - (320,200/240). The mouse.x and mouse.y variables will be updated to reflect the new position.

NOTE: Only use this command when absolutely necessary. Moving the mouse cursor for the player is a sure way to irritate them if you do it too often during the game.

Example:

mouse.SetPosition(160, 100);
will place the mouse cursor in the centre of the screen.

See Also: Mouse.SetBounds


Update

(Formerly known as RefreshMouse, which is now obsolete)

Mouse.Update();
Updates the global variables "mouse.x" and "mouse.y" with the current position of the mouse. Normally, these variables are set just before each script function is executed. However, if you have a very long script where the mouse may have moved since the start of the function, and you need the exact current location, then this command will update the variables.

Example:

Display("The mouse was at: %d, %d.", mouse.x, mouse.y);
mouse.Update();
Display("The mouse is now at: %d, %d.", mouse.x, mouse.y);
will display the mouse position just before each dialog box is displayed


UseDefaultGraphic

(Formerly known as SetDefaultCursor, which is now obsolete)

Mouse.UseDefaultGraphic()
Changes the appearance of the mouse cursor to the default for the current cursor mode. Use this to restore the cursor picture after you changed it with the UseModeGraphic function.

See Also: Mouse.UseModeGraphic


UseModeGraphic

(Formerly known as SetMouseCursor, which is now obsolete)

Mouse.UseModeGraphic(CursorMode)
Changes the appearance of the mouse cursor to use the specified cursor. Unlike the Mouse.Mode property, this does not change the mode used if the user clicks on a hotspot. This is useful for displaying a "wait" cursor temporarily.

Example:

mouse.UseModeGraphic(eModeWait);
will change the mouse cursor to the cursor 'Wait' specified in the Cursors tab.

See Also: Mouse.ChangeModeGraphic, Mouse.Mode, Mouse.UseDefaultGraphic


Mode property (mouse)

(Formerly known as GetCursorMode, which is now obsolete)
(Formerly known as SetCursorMode, which is now obsolete)

int Mouse.Mode;
Gets/sets the current mode of the mouse cursor. This is one of the cursor modes from your Cursors tab (but with eMode prepended). For example, a cursor mode called "Walk to" on your cursors tab would be eModeWalkto.

Setting this changes both the appearance of the cursor and the Cursor Mode used if the player clicks on a hotspot.

Example:

if (mouse.Mode == eModeWalkto)
{
   // code here
}
will execute the code only if the current cursor mode is MODE 0 (WALK).

See Also: Mouse.SaveCursorUntilItLeaves, Mouse.UseModeGraphic, Mouse.SelectNextMode


Visible property (mouse)

(Formerly known as HideMouseCursor, which is now obsolete)
(Formerly known as ShowMouseCursor, which is now obsolete)

bool Mouse.Visible;
Gets/sets whether the mouse cursor is visible. This is initially true by default, but setting this to false is useful for briefly hiding the cursor on occasions when you don't want it around.

If you want the Lucasarts-style where the mouse cursor is never visible during cutscenes then a much easier solution is simply to import a transparent graphic over the default wait cursor, so that the Wait cursor becomes invisible.

Example:

mouse.Visible = false;
Wait(40);
mouse.Visible = true;
hides the mouse, waits for a second, then turns it back on again

See Also: Mouse.UseModeGraphic

Browser Based Help. Published by chm2web software.
1