Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TheVolumeRemote on Tue 16/03/2021 21:33:27

Title: Setting mouse mode after combining inventory items
Post by: TheVolumeRemote on Tue 16/03/2021 21:33:27
Hey mates, sorry to ask a second question in a week but I’ve spent a couple of hours searching and trying things I’ve found with no luck.

Long short, after combining inventory items the cursor returns to Walk To. I have a puzzle where you must combine many items so this becomes frustrating for the player. How can I set it so after combining inventory items, the mouse mode returns to
Code (ags) Select
mouse.Mode = eModePointer; instead of Walk To (while gInventory is still open)?

Thank you! :)
Title: Re: Setting mouse mode after combining inventory items
Post by: TheVolumeRemote on Tue 16/03/2021 22:00:12
And I’m just gonna put this here instead of making a topic (I already feel annoying enough lol)

Is there a way to disable skipping text/dialog with the arrow keys? Some testers are telling me they use the arrows to walk and sometimes that causes them to accidentally skip dialog. :)
Title: Re: Setting mouse mode after combining inventory items
Post by: TheVolumeRemote on Wed 17/03/2021 07:24:38
While I’m tempted to delete this in cowardice, in case it helps anyone else, just change the mouse mode in the same line you add/lose the inventory items you’re combining.

Once again I keep looking for overly specific solutions and missing the obvious. Getting there though! Maybe!

Cheers :)

Code (ags) Select
function iClothes_UseInv()
{
    if (player.ActiveInventory == iHat)
  {
    player.LoseInventory(iHat);
    player.LoseInventory(iClothes);
    player.AddInventory(iBoth);
    mouse.Mode = eModeInteract;
  }
Title: Re: Setting mouse mode after combining inventory items
Post by: Crimson Wizard on Wed 17/03/2021 13:03:20
Above is of course the most straightforward, but at the same time tedious solution because you have to put it there everytime.

If this is absolutely necessary, an improvement may be to write a custom function that manages items and then sets cursor:

Code (ags) Select

void MergeItems(InventoryItem* i1, InventoryItem* i2, InventoryItem* result)
{
    player.LoseInventory(i1);
    player.LoseInventory(i2);
    player.AddInventory(result);
    mouse.Mode = eModeInteract;
}


And then you just call it like
Code (ags) Select

if (player.ActiveInventory == iHat)
{
    MergeItems(iHat, iClothes, iBoth);
}


(If there's more than one character who can merge items it's possible to expand it further into Character's extender function, but that's another topic)



However, I'd also question, why does it return to some irrelevant cursor at all. Probably this happens because all cursors are enabled at a time. As you mentioned there's gInventory open, does it mean it covers a screen and pauses the rest of the game? If so another possible solution could be to disable certain cursor modes when player opens gInventory and re-enable them when gInventory  is closed. This will prevent from any similar situations in screen-like GUI.

There are Mouse.EnableMode(mode) and Mouse.DisableMode(mode) for this.
Title: Re: Setting mouse mode after combining inventory items
Post by: Khris on Wed 17/03/2021 13:42:35
Quote from: TheVolumeRemote on Tue 16/03/2021 22:00:12Is there a way to disable skipping text/dialog with the arrow keys? Some testers are telling me they use the arrows to walk and sometimes that causes them to accidentally skip dialog. :)
You can set  Speech.SkipStyle  and  Speech.SkipKey  to fine-tune how speech can be skipped.
Title: Re: Setting mouse mode after combining inventory items
Post by: Crimson Wizard on Wed 17/03/2021 14:20:07
Quote from: Khris on Wed 17/03/2021 13:42:35
Quote from: TheVolumeRemote on Tue 16/03/2021 22:00:12Is there a way to disable skipping text/dialog with the arrow keys? Some testers are telling me they use the arrows to walk and sometimes that causes them to accidentally skip dialog. :)
You can set  Speech.SkipStyle  and  Speech.SkipKey  to fine-tune how speech can be skipped.

Also there's a corresponding option in General Settings, if you want to set it once for all game.