2 Second Pause In-Game

While we’re on the subject of delayed text (something I myself was looking for in the form of Emily Short’s Basic Screen Effect’s “wait for any key”), is there an extension that has the text “typed” to you rather than appear as a block?

I just posted an answer to this, but it seems to have been eaten… I’ve added an example to the Real-Time Delay extension that shows how to do this.

–Erik

Got around to trying out your teletype thing, and it won’t work. I even tried directly copy and pasting the “To teletype” method, and it still errors.

The error is:

[code]Problem. The phrase or rule definition ‘To teletype ( text-to-be-printed - an indexed text )’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘repeat with N running from 1 to the number of characters in the text-to-be-printed’ , in case that helps.

This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.
[/code]

This is with the copy and pasted version, so i’m using your indentations.

EDIT: Got it to work. I guess the indents weren’t large enough. Made my own indents with the tab key and now it works. However, it seems as though no matter how low I set the wait number the text is typed extremely slowly, even at 3 milliseconds.

Thanks for the report. I just tested it and it works fine.

You say you’re copying and pasting. That won’t work, whether you’re copying from the original text file or from the “Installed Extensions” page in the IDE. There’s an extra tab in front of every line in the text file, so that will screw up Inform. The Installed Extensions is in HTML, so the tabs are converted to spaces, which will also confuse Inform. You need to press the blue-on-gray paste button next to the title of the example in the installed extension docs–if you do this, Inform will correctly convert spaces to tabs and paste automatically.

Let me know if that works. If it doesn’t, there may be a bug in the IDE (I’m using the Mac IDE).

–Erik

It sounds like you didn’t use the paste button and had to replace the spaces with tabs.

I can see clear differences in speed between 3 and 20 millisecond delays (using Zoom in the Mac IDE), as well as other terps. A 3-millisecond delay is quite fast. What interpreter/IDE are you using? If your computer is very slow, or the interpreter (or the version of the terp that’s in the IDE is slow), you may not get very good response. Try “releasing” a gamefile and opening it in a different interpreter.

EDIT: Gargoyle (pre-release Mac build) is pretty slow whether you set it to 1 or 20 ms. I’ll report this to the Gargoyle devs as a bug.

–Erik

I’m on a pretty powerful Windows PC (I can run Crysis on high settings), and i’m using Inform’s own preview interpreter.

Hm, I believe that would be a modified version of WinGlulxe. It sounds like not some interpreters are just not good at printing text quickly. There’s not much to be done about it except bring it to the attention of the interpreter writers. (It’s interesting to note that both Gargoyle and WinGlulxe are faster at displaying animated graphics than animated text…)

–Erik

I also seem to have another problem.

I teletype one piece of text (20 ms for each letter), I wait for 2000 ms (two seconds), then teletype a second piece of text. During play, the two second delay is nonexistant; it continues to type at 20 ms each letter without stopping.

I even amped the number to 2 million, and the pause is still nonexistant.

I’ve tried using both Glulx interpreters that come with Inform (Glulxe and Git) with no improvement.

You’ll need to post your code, I think.

Not really much to post. The teletype is the same as yours (using the same numbers).

Then during an Instead rule (examining the character of Cheif Buga), I have this happen:

teletype “The great and wise Cheif Buga stands before you on a pedistal, illuminated by the two torches on either side of him.”;
wait 2000 ms before continuing;
teletype " He is a giant of a man (both in height and weight), with hands so large he could crush your skull like a paper cup.".

Inform seems to ignore that two second wait for some reason, yet no error appears.

Hm, I can’t really explain this either. It works fine for me in Zoom and Gargoyle on OS X. What happens at the line breaks in the original example? Do you get the extra pause (400 ms) there?

By the way, I’ve asked David Kinder (who maintains WinGit and WinGlulxe) to peek at this thread, so he may weigh in at some point.

–Erik

It doesn’t slow down at the line break either.

Well I’m out of ideas. All of the pauses work as they should for me in both WinGlulxe and WinGit–both the original line break delays and your 2 second pause–running in Wine (Windows emulator on OS X). I can’t see why this would work in Wine but not on a native machine…

Try downloading my gamefile and testing with that:

dl.dropbox.com/u/947038/Bug%20Report.gblorb

Any difference?

–Erik

P.S. Here’s the code used to create the gamefile:

Include Real-Time Delays by Erik Temple.

When play begins:
	say "Type TURN ON COMPUTER to see animated text display. The desired delay in milliseconds between the printing of each character is initially 20 ms. You can change this by typing DELAY 2, for example, which would change the desired delay to 2 ms."

The Lab is a room. The computer is a device in the Lab.

Delay is a number variable. Delay is 20.

To teletype (text-to-be-printed - an indexed text):
	repeat with N running from 1 to the number of characters in the text-to-be-printed:
		if character number N in the text-to-be-printed is "[line break]":
			wait 400 milliseconds before continuing;
		say "[character number N in the text-to-be-printed][run paragraph on]";
		wait (delay) milliseconds before continuing, strictly.

Instead of switching on the computer:
	say "[line break]";
	teletype "The great and wise Cheif Buga stands before you on a pedistal, illuminated by the two torches on either side of him.";
	say line break;
	wait 2000 ms before continuing;
	teletype " He is a giant of a man (both in height and weight), with hands so large he could crush your skull like a paper cup.";
	say line break.
	
Setting the delay is an action applying to one value. Understand "Set delay at [number] ms" or "delay [number]" as setting the delay.

Carry out setting the delay:
	change the delay to the number understood;
	say "Delay is now [delay] milliseconds."

The way that the interpreter in the Inform 7 application works means that it’ll never respond that quickly to short timer events: Inform 7 runs the interpreter in a separate process so that it can recover if the interpreter crashes, but a side effect of that is that communication between the two is generally only checked about once every 100ms or so. In normal use this is fine, but the teletype effect makes it rather obvious.

There isn’t much that can be easily done about this without compromising the stability of the Inform 7 front-end or quite a lot of re-working. At the moment there’s too many other more important things to work on for this to be a priority, sorry.

I admit I haven’t tested this myself, but it seems like even 10 FPS would be OK for teletype? Or is it unbearably too slow?

I’m not sure about the performance BishyT is getting, whether it was 1/100ms or even worse. However, David’s explanation suggests that one ought to see an increase in speed by “releasing” the gamefile and opening it in an external interpreter. Like David, I don’t think this is a big deal–if performance is acceptable in the end user’s experience, it doesn’t really matter whether there’s a bit of a lag in the IDE. (And there is some lag in most multimedia functions in the IDE, whether on Mac and Windows).

On to your question about 1/100ms. I think it is pretty slow, but it’s not excrutiating; certainly it ought to be good enough for testing. You can try it with the gamefile I posted upthread. Type DELAY 100 to see what it looks like…

What I’ve found testing other terps was that Zoom was able to get significantly better speed than any of them (hence the name?). I estimate Gargoyle (Mac OS X) prints one letter every 50-90 ms, whereas Zoom seems to be able to do significantly better than 1/20ms, maybe even better than 1/5ms.

UPDATE: David Kinder has explained that the resolution of the timer for Windows Glk (which powers the WinGlulxe & WinGit interpreters) is such that the best possible temporal resolution is about 20ms, and for a “teletype” effect like this where the entire display must be re-rendered every time the timer “ticks”, the best resolution will probably be around 50 ms. So there’s an explanation for the lag on those interpreters.

–Erik

Well whaddaya know, it works! With the teletype set to 50 ms all the other waits work now.

What was your setting before? Could you post the full code of the failed game? As I said, I couldn’t replicate what you were seeing, but if there’s a bug with timers in Windows Glk, I’d like to be able to track it down and submit it.

Thanks,
Erik

Strange, it seems to have fixed itself. Now the pauses happen even if the teletype is set to 1 (though of course the teletype itself doesn’t run that fast in the preview).

Also, I tried running my project in WinGlulxe, and everything worked perfectly fine (no lag).

If the timer limitations in other interpreters have turned you off from using this or other Glulx multimedia tricks, there is a cross-platform solution with very nice performance coming:

Ben Cressey (the driving force behind the Gargoyle interpreter) has been working on new timer code solutions as well as display-speed enhancements for both text and graphics. The beta Mac build (see here) showcases both of these improvements, but I think you can expect to see them expand to the Windows and Linux versions of Gargoyle before too awfully long.

–Erik