I’m trying to work in a cutscene, as it were, where a block of exposition is displayed before the player continues the story. What I’m trying to do is something like this:
[code]Include Basic Screen Effects by Emily Short.
When Cutscene begins:
Clear the screen;
Say “Here is some exposition.”;
Wait for any key;
Say “Here is some more exposition.”;
Wait for any key;
Clear the screen;
Now the player is in The Other Room.[/code]
…And I get an error message saying “Fatal Error: Printing text to a window that is waiting for line or character input is not allowed.”
Which makes sense, since I’m waiting for a key and then printing more exposition… Except that I did the same thing “When play begins” and that works fine. So what’s going on here? What’s the text it’s printing to the window during the cutscene and why is it not printing the same sort of text when play begins? More importantly, how can I make this work?
Well, it’s gratifying to know that my code works. However, since it doesn’t, what else might be causing problems with waiting for any key? I’m trying to call the cutscene when the player enters a certain room, so maybe printing the player’s surroundings to the status bar is interfering with things, or printing the new room description? Except I’ve tried calling the cutscene instead of entering the room as well. Could another scene be interfering with it? A glulx timed event (I’m also including Music by Daniel Stelzer)? Another character? I think I have all of those accounted for, but I’ll check again.
I believe that snippet of code works in isolation, but in the context of my project, it gives me the error message. So right now I’m trying to get pointed in the right direction, because I don’t want to have to comment out each line of my 18,000-word source text individually to see what the conflict is.
Of the things you listed, trying to print text during a timed event or sound completion event looks likeliest to be the problem. (You have to cancel line input before printing anything. I don’t know exactly how that works with any given extension, however.)
Update: It’s definitely a problem with the music - when I comment out all the music the error stops happening, so yeah, it’s a sound completion event I’d say.
So the good news is that now I know what’s wrong. The bad news is that I have absolutely no idea how Glk events work (ooor really what Glk is. I’m definitely working as a writer here, not a programmer).
Would it be too much to ask someone to give me a few pointers?
Glk is an API for a service that provides all of the user interface support that an IF interpreter (virtual machine) needs from its local platform. This encompasses both data going from the program to the player (text and graphics being displayed in windows on the screen, sound output, etc.) and data coming from the player to the program (keyboard and mouse input).
The idea is to split the platform-specific code that could be shared by multiple interpreters on the same platform from the interpreter-specific code that could be shared by the same interpreter on multiple platforms.
The Glulx VM (the default target for compiled Inform 7 games) is specified to use Glk for its I/O, so they’re intertwined and often conflated.
The official Glulx and Glk specs are available online.
You might also find Adam Cadre’s Gull tutorial (about Glulx, but containing a lot of Glk info) to be helpful as an introduction, although it’s written for Inform 6 programmers.
Regarding the Music extension, it depends on Glulx Entry Points by Emily Short. You might want to take a look at that after having familiarized yourself with Glulx/Glk. Specifically, check out the section on Input-Cancelling Rules.
I’m gonna guess Draconis’s Music extension is manipulating the Glulx timer at the same time that you’re asking for input. I guess the thing that surprised me when I pored over the Glk specs is that there is only one Glulx timer to go around a whole project. That’s why this can be a hard problem to deal with when multiple features you want to use all want to use the timer at the same time.
I dealt with this a ton when programming Leadlight Gamma. I had animated graphics, timed music and clickable hyperlinks that had to reset themselves after a tiny blob of time had passed. Ultimately, I had to isolate each of these 3 features – only 1 of the 3 could be operating at any particular time.
That doesn’t mean, for instance, that you can’t ever play music over an animation, but it means the music can’t be using the TIMER while the animation’s running (the animation always used the timer, and had to. So did the self-resetting buttons.) … unless you do a bunch of fancy and difficult timed steps programming. eg To have something happen 2 seconds from now and something else happen 7 seconds from now, if you can wrangle it, you would ask for 2 seconds, then react to thing 1 and then ask for 5 seconds. Logistically, this approach is rarely manageable.
I haven’t looked at Draconis’s Music extension, but I know it’s a lot more sophisticated than the now ageing one I contributed to called Multiple Sounds. If it uses the timer every time a piece of music is played (which my older, dumber one does not) that’s where the workaround will have to take place. Either by Draconis coming up with a schmick update, or by you (Jazzcat) reverting to an older, dumber extension, or something similar : )
I ran into that particular error a lot when setting up glulx sound events using Glulx Entry Points. It was very fiddly to get them to work. At the time I was doing it, you had to be very careful about, for instance, line breaks and such. I don’t know if anything has changed since then.
Question: does setting the volume of music directly work for you? (Try “set the volume of the foreground to 32768” and it should go down to half-intensity.) And do you ever have a fade going to a volume below zero, or a volume above 65536?
Answer: Yes, setting the volume works as expected; no, I’m using your built-in “introduce” function for all of fades (albeit on a couple of extra sound channels I initialized by Frankensteining together code copy-pasted from your extension and Multiple Sounds).