Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jabbage on Sun 02/10/2022 19:35:18

Title: (Solved) Disabling the inventory on a menu screen with VerbCoin template
Post by: Jabbage on Sun 02/10/2022 19:35:18
Hi all! This is my first time asking a question here, so I'm really hoping it's not TOO dumb!  :-D

My game has a beginning room which is a menu screen. I'm using the VerbCoin template, so the inventory appears when the users right clicks. I have also created a custom GUI which contains save, return, quit buttons which appears when the user presses Escape.

I've been trying to find ways to disable the inventory screen and my custom GUI on the title so that this kind of thing doesn't happen!

(https://i.ibb.co/VYHH0wK/glitchy.png)

I found this advice (https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/solved-disable-inventory-in-room-bass-template/) from 2017 but it was for a menu which appears when the user hovers their mouse near the top of the screen.

Any advice is really appreciated, thanks!


Title: Re: Disabling the inventory on a menu screen with VerbCoin template
Post by: Khris on Sun 02/10/2022 20:11:31
Add this to your room_script:

Code (ags) Select
function on_key_press(eKeyCode key) {
  ClaimEvent();
}

function on_mouse_click(MouseButton button) {
  ClaimEvent();
}

This will disable any mouse/keyboard code from other scripts in that room.
Title: Re: Disabling the inventory on a menu screen with VerbCoin template
Post by: Jabbage on Sun 02/10/2022 20:56:37
Thank you, this works brilliantly for the menu screen!

Unfortunately I've realised there's another instance in the game where I'd like to be able to disable the inventory and my save/load menu, but I've set it up so that the user is supposed to be able to use the keyboard and mouse.

When the player starts the game, I've made a few screens featuring introductory text and images - basically like a slide show, briefly introducing the characters and world. I wanted to make sure the player could take their time to read these or skip them if they want to get straight into playing the game, so I set it so they could click to continue, or press a keyboard button to skip.

function on_mouse_click (MouseButton)
{
player.ChangeRoom(302);
}

function on_key_press (eKeyCode)
{
player.ChangeRoom(1);
}

(Room 302 is the next 'slide' in the intro, room 1 is the true beginning of the game)

So, if I 'Claim event' on both keyboard and mouse, this will stop working! I had a try at putting something together which might allow me to disable the escape button and right click, but it doesn't work...


function on_mouse_click(MouseButton button)
{
  if (button == eMouseRight)
{ ClaimEvent();}
  else
  player.ChangeRoom(303);
}

function on_key_press(eKeyCode key)   
  {
  if(eKeyEscape)
  ClaimEvent();
  else
  player.ChangeRoom(1, 150, 150, eDirectionDown);
  }

It's possible I should have a rethink and handle this introductory text in a different way?
Title: Re: Disabling the inventory on a menu screen with VerbCoin template
Post by: Khris on Sun 02/10/2022 23:00:24
Just add the ClaimEvent(); command to your functions. What it does is tell AGS not to run any other script's handler, so there's no need to put it in a conditional. For the key you'd use if (key == eKeyEscape) btw.

Code (ags) Select
function on_mouse_click(MouseButton button)
{
  ClaimEvent();
  player.ChangeRoom(302);
}

function on_key_press(eKeyCode key)
{
  ClaimEvent();
  player.ChangeRoom(1);
}

edit: fixed typos
Title: Re: Disabling the inventory on a menu screen with VerbCoin template
Post by: Jabbage on Mon 03/10/2022 20:06:49
Brilliant, thank you! I think I understand better now ClaimEvent works now.

I'll mark this thread as solved!