Hey there everyone -
I'm looking to use a right click to drop an inventory item back into the inventory (in rooms, outside of the inventory GUI itself). I've tried quite a few things and think I must be missing something simple. Right now in on_mouse_click in the global script:
// called when a mouse button is clicked
function on_mouse_click(MouseButton button)
I have this at the end:
// drop item back into the inventory
else if (button == eMouseRight && player.ActiveInventory != null)
{
player.ActiveInventory = null;
}
My inventory GUI is not set to pause.
Here are the contents of on_mouse_click in their entirety:
// called when a mouse button is clicked
function on_mouse_click(MouseButton button)
{
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused())
{
// game is paused, so do nothing (i.e. don't process mouse clicks)
}
// walk anywhere even if walk is not the active mode START
else if ((GetWalkableAreaAtScreen(mouse.x, mouse.y) != 0 || (GetLocationType(mouse.x, mouse.y) == eLocationNothing)) && (button == eMouseLeft))
{
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
}
// walk anywhere even if walk is not the active mode STOP
else if (button == eMouseLeft)
{
// left-click, so try using the current mouse cursor mode at this position
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
else if (button == eMouseRight || button == eMouseWheelSouth){
// right-click or mouse wheel down will cycle the mouse cursor mode forwards
mouse.SelectNextMode();
}
else if (button == eMouseMiddle)
{
// middle-click makes the character walk to clicked area, regardless of cursor mode
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
}
else if (button == eMouseWheelNorth)
{
// mouse wheel up will cycle the cursor mode backwards
mouse.SelectPreviousMode();
}
// drop item back into the inventory
else if (button == eMouseRight && player.ActiveInventory != null)
{
player.ActiveInventory = null;
}
}
Nothing happens. The player is still holding the inventory object they've picked up, whether chosen from already acquired inventory, or from a room.
Hope you all are well!
Thanks in advance... ;-D
That's because you already have this part:
else if (button == eMouseRight || button == eMouseWheelSouth){
// right-click or mouse wheel down will cycle the mouse cursor mode forwards
mouse.SelectNextMode();
}
So the condition for clicking the right button has already been captured and so the last 'else' part will not be checked.
(I haven't checked the codes thoroughly though, so there may be other lines that will clash with this.)
One (not very elegant) solution is to put this inside the above part:
else if (button == eMouseRight || button == eMouseWheelSouth){
// right-click or mouse wheel down will cycle the mouse cursor mode forwards
if (button == eMouseRight && player.ActiveInventory != null) player.ActiveInventory = null;
else mouse.SelectNextMode();
}
The existing code you have is Sierra interface code, where a right click is used to cycle through cursor modes.
If you're planning to use a two button interface instead, you need to rewrite all the on_mouse_click code.
What they said. (nod)
Just wanted to add that to catch mouse clicks on inventory window you have eMouseLeftInv and eMouseRightInv.
Well that was a bit embarrassing. :-[
I've got it working now (separate to eMouseWheelSouth; didn't want to affect cycling through modes).
Thanks very much to you Gilbert, Khris, and Cassie!