Jibble

Author Topic: Run next line only by click or key  (Read 241 times)

Run next line only by click or key
« on: 01 Jun 2020, 07:53 »
Hi

I'm creating a cutscene and I want it to be partially controlled by the user.
I want one command to be executed (to be completed, not skip ) and wait indefinitely until the user press click or a keyboard (not to wait a time), and then execute the next command and so on.
I have the following function which is doing what I want, but I found a bit awkward to use that big number.
Is this the best way to do? or what can u recommend?

Code: Adventure Game Studio
  1. function cutscene1()
  2. {
  3.   line command 1
  4.   WaitMouseKey(10000);
  5.   line command 2
  6.   WaitMouseKey(10000);
  7.   line command 3
  8. }
  9.  


If this is already solved in other forum, My apologies, have not be able to find it.
« Last Edit: 01 Jun 2020, 09:08 by Andrea1992 »

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Re: Run next line only by click or key
« Reply #1 on: 01 Jun 2020, 09:01 »
If you want the player to skip you would use this in your function:

Code: Adventure Game Studio
  1. StartCutscene(eSkipAnyKeyOrMouseClick); //  Begin skipping stuff after pressing any key or mouse clik.
  2.  
  3. // will skip to here
  4.  
  5.  EndCutscene();  // Skip stuff ends
  6.  
« Last Edit: 01 Jun 2020, 09:08 by Slasher »

Re: Run next line only by click or key
« Reply #2 on: 01 Jun 2020, 09:15 »
Slasher, thanks for you answer, but  StartCutscene() and  EndCutscene() don't do what I want.

I dont want to skip or interrupt the commands in the cutscene.
I need a command to be completed without interruption, then I need a click or key press to execute the next command and so on.

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Run next line only by click or key
« Reply #3 on: 01 Jun 2020, 10:36 »
Yeah, AGS doesn't have a function that does this. (I made a request for one a while back, but it got bogged down in questions about supporting other input devices than mouse and keyboard.)

I've tried to write my own, but found it doesn't work very well, and the API makes it really complicated and tedious. I would honestly recommend just using a really large number and accepting the bug that it will eventually auto-advance.

Re: Run next line only by click or key
« Reply #4 on: 01 Jun 2020, 12:46 »
Thanks Snarky! glad to hear, though it was just me not being able to see the obvious!

Re: Run next line only by click or key
« Reply #5 on: 01 Jun 2020, 13:44 »
I made a request for one a while back, but it got bogged down in questions about supporting other input devices than mouse and keyboard.

It was not bogged down, it was delayed because 3.5.0 was taking too long to complete and now it's in my plans for 3.5.1 update.

I was also considering another kind of Wait that blocks until you call a script command "stop wait", similar to eSkipScriptOnly cutscene mode which is skipped by SkipCutscene(). Supposedly this would let you script custom skipping rules as well.
« Last Edit: 01 Jun 2020, 13:51 by Crimson Wizard »

Intense Degree

  • Cavefish
    • Intense Degree worked on one or more games that was nominated for an AGS Award!
Re: Run next line only by click or key
« Reply #6 on: 01 Jun 2020, 17:22 »
This probably doesn't apply to your situation but I did a similar sort of thing by breaking a cutscene into two separate cutscenes and making a gui visible between them which paused the game when shown. A click on the relevant bit of the gui launched the second cutscene via rep_exec. And hid the gui obviously.

As I say it's probably no good for you for a number of reasons (not least of all triggering by any key or click) but just in case...

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Run next line only by click or key
« Reply #7 on: 01 Jun 2020, 17:24 »
You could also use a full screen clickable GUI with 99% transparency, then set it to close and run the next segment. And you could claim the keyboard entry to close the GUI with anykey I guess.
Of course, you would need to code your cutscene slightly differently, by tracking with an int in which segment the player is at, and then use else ifs to check which segment to run next.

PS: Intense Degree beat me to it, but since I've already wrote it...  (roll)

EDIT: Intense Degree, one can set the GUI to be clickable, no need to make buttons or labels or anything.  ;)

EDIT2: Thought about  it a bit more, and you don't even need a claim event, just on the function on_key_press just check at the start if this GUI is open, and if so then run the cutscene.
This means you are going to call the cutscene from 2 different places, so the best is to create a function/void for the cutscene, and on the key press and GUI click only close the GUI and call the cutscene function/void.
« Last Edit: 01 Jun 2020, 17:36 by Cassiebsg »
There are those who believe that life here began out there...

Intense Degree

  • Cavefish
    • Intense Degree worked on one or more games that was nominated for an AGS Award!
Re: Run next line only by click or key
« Reply #8 on: 01 Jun 2020, 17:35 »
EDIT: Intense Degree, one can set the GUI to be clickable, no need to make buttons or labels or anything.  ;)

Absolutely, but if I'd done that you wouldn't have had to press the 'Penthouse' button on my lift controls GUI. ;)

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Run next line only by click or key
« Reply #9 on: 01 Jun 2020, 17:40 »
I'm pretty sure I would have, even if the click could have been anywhere, we instinctively click on the "button".  (laugh) Unless one is pixel hunting, but your game didn't had that kind of the interface.
My help menu is using this feature, but I often wonder how many of the players actually go and click on the text "click to close".  (laugh)
There are those who believe that life here began out there...