Wait for typewriter to finish before running script?

OurJud

I know this can be done by manually timing how long it takes the 'typewriter' effect to display its message, and then adding a run script after number of seconds script, but is there any way to simply have the game 'wait' for the typewriter to finish before running the next message, so that the timing is exact and won't be affected by game size/internet speeds, etc?


Xilefenko

I have the same Problem. I have dozens of timers for long scripted narration and that's just more complicated than it should be.


Father

I suppose you could add an 'await key press ' script . The player could continue after the typewriter stops. I do think it would be better if typewriter stopped the action until it finishes.


The Pixie

No. The text should appear at a predictable speed, so it should be predicable. It does it all on the PC, so once it starts, internet speed will not be an issue. Rather than timing it, you can calculate it (`LengthOf (text) * speed / 1000), but I must admit, when I tried it that was not very accurate.

If you just want to add a second paragraph, you should be able to do it as one long string, with <br/> to mark the paragraph break.


Pertex

I played with the typewriter some years ago. The problem is, that the writing speed decreases with the amount of text. I tried to create a game only typewriting text but it became so slow that you couldn't play it.
If you want to get the end of a typewriting text you can extract the Javascript code from playercore.js and create your own typewriter effect . In playercore.js you can find the function typewriter. If you add the line

ASLEvent("EndScript","1");	

as shown below it calls the ASLX function EndScript in your game file when the effect ends. But, as said, you must create your own JS file, add the necessary code from playercore.js and enhance it

    $.fn.typewriter = function (speed) {
        this.each(function () {
            var $ele = $(this), str = $ele.text(), progress = 0;
            $ele.text('');
            var timer = setInterval(function () {
                $ele.text(str.substring(0, progress++) + ((progress & 1) && progress < str.length ? '_' : ''));
                if (progress >= str.length) {
					clearInterval(timer);
					ASLEvent("EndScript","1");	
				}	
            }, speed);
        });
        return this;
    };

OurJud

The Pixie
If you just want to add a second paragraph, you should be able to do it as one long string, with <br/> to mark the paragraph break.

Are you saying a </br> tag will somehow force the second (non typewriter) paragraph to wait for the typewriter to finish before it displays?

I failed to make it clear that I'm just using the typewriter for the occasional heading, like at the start of a new game day. So something like 'The following day' or 'One week later' would be typed, and then the rest of the normal text pops up after the effect has run its course.

I did consider the 'wait for keypress' option, but I hide the default 'Continue...' link for this so it may not be clear what's going on.

Looks like Pertext's JS is the only option, but I don't think the effect is quite that precious to the project and I can easily live without it (or just go with the timer).


Groctel

I'm actually interested in the orinigal request too!

It would be great to have a function that waits until the last script line is executed to run the one below, since Quest just runs the whole script at once if it doesn't find any wait commands.


The Pixie

In some situations, on ready will do that (not with the text effects though).
http://docs.textadventures.co.uk/quest/scripts/on_ready.html


Log in to post a reply.

Support

Forums