12.5. Glulx Multimedia Effects

| Chapter 12: Typography, Layout, and Multimedia Effects |

| 12.5. Glulx Multimedia Effects

Glulx is one of the two basic story file formats to which Inform can work. It is the more powerful of the two, but less universally playable: it should be used without fear if it offers a project any worthwhile advantage, but otherwise not.

Among its powers are the ability to display images, play back sound effects, and read and write external files to the disc. With care and a certain amount of fuss, this can even give a playing story file limited Internet connectivity, although it should be stressed that this can only be done if the player sets up his computer just right and runs an auxiliary program beside the game itself. That will mostly be too much to ask, if the player is playing offline, but when the story file is being run on an interpreter running at a server - so that the player simply sends commands to it and sees responses back on a web page - one could easily imagine setting up the server to provide these auxiliary programs, without any extra difficulty for the player.

Many of the more advanced multimedia abilities of Glulx are best unlocked using extensions available from the Inform website. As of this writing, extensions exist to help authors create complex multi-windowed displays (including per-location pictures, visual status bars, and even limited animations and gradually-revealed maps).

There is also work in progress on sound-management to allow the author to play sounds in multiple channels at once, to change sound volumes, and to create fade-in and fade-out effects.

Without extensions, all these abilities are within reach for an author who is willing to do some fairly advanced programming.

434
| Example Flathead News Network Using external files, together with a simple Unix script running in the background, to provide live news headlines inside a story file. |
WI

This example can only work if we have a separate program running in the background while the story file is being played, and as such it will only work if we set things up in a special way. Exactly how to do this will vary from platform to platform. First, the source text for the Inform end of the communication line: "Flathead News Network" The file of RSS Requests is called "rssrequest". The file of RSS Responses (owned by project "RSS-SCRIPT") is called "rssreply". To request (RSS feed address - text): mark the file of RSS Responses as not ready to read; write the RSS feed address to the file of RSS Requests. Newsroom is a room. "This is the secret nerve-centre of FNN, the Flathead News Network." The BBC button is in the Newsroom. Instead of pushing the BBC button: say "Bong!"; request "newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml". The NASA button is in the Newsroom. Instead of pushing the NASA button: say "Bang!"; request "www.nasa.gov/rss/breaking_news.rss". The WHO button is in the Newsroom. Instead of pushing the WHO button: say "Bing!"; request "www.gallifreyone.com/news.xml". A screen is in the Newsroom. Instead of examining the screen: if ready to read the file of RSS Responses, say "From the screen you read:[line break][text of the file of RSS Responses]"; otherwise say "The screen remains blank for now." As far as the story file is concerned, then, it sends a request down the communication line by writing the chosen RSS feed to the file named "rssrequest", and expects a reply to come back down the line by being written to the file "rssreply". However, the story file needs to expect that this might take some time. (Maybe forever, if there is no program responding, or if the Internet connection is not working.) The story file marks the "rssreply" file as not ready before it makes a request; if it subsequently finds that the file is now ready, that must mean that the other program has done the honours, and that all is well. In the mean time, "The screen remains blank for now." Now for the RSS-SCRIPT program. The following provides a crude but workable program suitable for running as a Perl script on a system which provides the standard Internet fetching program "curl": Mac OS X, for instance. (If you have OS X, you can paste the following into a (Unix-format) text file called "rss-script.pl", place it in your home folder, open the Terminal utility, type "perl rss-script.pl", and then hide the Terminal window again.) for (;;) { # repeat forever: system("sleep 1"); # wait 1 second open REQUEST, "rssrequest.glkdata" or next; # the request file has been detected: $header_line = <REQUEST>; # the header line $rss_feed = <REQUEST>; # the actual content - the RSS feed URL close REQUEST; if ($header_line =~ m/^\*/) { # if the request file is marked ready $rss = system("curl $rss_feed >rawrss.txt"); # download the RSS feed # read the RSS XML into a single Perl string: open RAWRSS, "rawrss.txt" or next; $raw = ""; while ($nl = <RAWRSS>) { $raw = $raw." ".$nl; } close RAWRSS; # look for the title and description of the first item: if ($raw =~ m/\<item\>\<title.*?\>(.*?)\<\/title\>.*?\<description.*?\>(.*?)\<\/description\>/) { # write the reply: open REPLY, ">rssreply.glkdata" or next; print REPLY "* //RSS-SCRIPT// rssreply\n", $1, "\n", $2, "\n"; close REPLY; # request safely dealt with, so we can remove it: system("rm 'rssrequest.glkdata'"); } } }

Previous | Contents | Next