Run next line only by click or key

Started by Andrea1992, Mon 01/06/2020 07:53:34

Previous topic - Next topic

Andrea1992

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: ags

function cutscene1()
{
  line command 1
  WaitMouseKey(10000);
  line command 2
  WaitMouseKey(10000);
  line command 3
}


If this is already solved in other forum, My apologies, have not be able to find it.

Slasher

#1
If you want the player to skip you would use this in your function:

Code: ags

StartCutscene(eSkipAnyKeyOrMouseClick); //  Begin skipping stuff after pressing any key or mouse clik.

// will skip to here

 EndCutscene();  // Skip stuff ends


Andrea1992

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

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.

Andrea1992

Thanks Snarky! glad to hear, though it was just me not being able to see the obvious!

Crimson Wizard

#5
Quote from: Snarky on Mon 01/06/2020 10:36:10I 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.

Intense Degree

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

#7
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.
There are those who believe that life here began out there...

Intense Degree

Quote from: Cassiebsg on Mon 01/06/2020 17:24:13
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

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...

SMF spam blocked by CleanTalk