Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: robotsquid on Tue 03/11/2015 19:08:27

Title: simple keyboard driven menu
Post by: robotsquid on Tue 03/11/2015 19:08:27
hi, i'm attempting to make an interactive for a museum.  it needs to display a background image and play videos when certain keys are pressed.  so you press 1 and it plays video 1 etc.  while i've found on_key_press and PlayVideo in the wiki i'm none the wiser how to put them together.  if anybody who actually knows what they're doing could give me an example script i could adapt that would save me a lot of head scratching.

i normally stick to the video production but offered to help with the interactive for free as they didn't have the money (£1000s) to hire one of the companies that normally makes these things.  having played with AGS years ago i knew it was capable, just thought the how would be a little simpler.

anyway, posting here is a last resort after a lot of head scratching so any help would be greatly appreciated.
Title: Re: simple keyboard driven menu
Post by: robotsquid on Tue 03/11/2015 19:38:44
this is what i have atm:

Code (ags) Select
function on_key_press eKey1 ()
{
PlayVideo c:\inttest\lq.avi eVideoSkipAnyKey 1
}
Title: Re: simple keyboard driven menu
Post by: Slasher on Tue 03/11/2015 19:40:19
Hi

example in on_key_press  function in the Global when pressing A key:

Code (ags) Select

if (keycode == eKeyA ){
PlayVideo("BLACKNIGHT-GLOBE.mp4", eVideoSkipEscKey, 1); //Escape to stop video
Title: Re: simple keyboard driven menu
Post by: robotsquid on Tue 03/11/2015 19:56:39
so i have the on key press part in room script and the if parts in the global script?
Title: Re: simple keyboard driven menu
Post by: Slasher on Tue 03/11/2015 20:01:30
I have it in the Global so it applies to all rooms. You can add 'conditions' that allow it to run.

example
Code (ags) Select

if (keycode == eKeyA && playvideo1==false){ // and if boolean playvideo1==false
PlayVideo("BLACKNIGHT-GLOBE.mp4", eVideoSkipEscKey, 1); //Escape to stop video
playvideo1=true;
Title: Re: simple keyboard driven menu
Post by: robotsquid on Tue 03/11/2015 20:17:26
okay, got it working.  thanks for your help slasher.
Title: Re: simple keyboard driven menu
Post by: Khris on Wed 04/11/2015 00:21:49
Just for reference, AGS will also look in the current room script for on_key_press() and if found, call it.

So if you want the app to have multiple screens where pressing 1 does something different each time, you can do that easily.

// room script

function on_key_press(eKeyCode k) {

  if (k == eKeyCode1) {
    PlayVideo("lq.avi", eVideoSkipAnyKey , 1);
  }
  if (k == eKeyCode2) {
    PlayVideo("something_else.avi", eVideoSkipAnyKey , 1);
  }
  // ...
}
Title: Re: simple keyboard driven menu
Post by: robotsquid on Thu 05/11/2015 22:43:10
can see that coming in handy.  cheers!