I’ve been jonesing to put together a little text based adventure program recently, but time constaints have kept me from even playing one. Somehow my mind wandered off to a recollection of the old Doom fielsystem navigation program I ran across years ago… an amusing concept, if not particularly feasible for day-to-day use. Fusing the two ideas, I decided a text-based adventure type interface to the filesystem would be neat, something like the lovechild of bash (or pksh for me) and some nameless MUD tramp. Thus was born STASH, the Super Text Adventure SHell!
It’s not actually a shell, but a script and an aliases file. The aliases file defines actions, like ‘look’ and ‘eat’. If for some reason you come across a conflict on your system, just rename the alias. These aliases all call the perl script, passing whatever arguments (usually keywords and env variables) are appropriate for that action. The script then does its bit, which could be any thing from printing a simple message in response to saving your state to a database file. When you want to play you just source the aliases file (I’d put the commands to open a subshell, source the file, and display a small banner into a script).
The neat thing about this is that you can continue to get work done- it doesn’t change the fact that you are sitting directly in a shell, and it doesn’t even take up extra screen/desktop realestate! When you get bored and need to blow off some steam, just start playing, hopping back when appropriate.
So you’ve got the tools: now what? Well, if we’re using the filesystem and environment for the setting… create a map of the filesystem and start writing descriptions and interactions. If using a perl script, these should go into a module, so that a single script can be used to play, or even combine, modules. If each new directory is given as a package then additions become very easy to plug together using a startup script that pulls together the desired packages via ‘use’ statements. To randomize room contents and encounters, use the directory listing, the environment variables, and the process running at the time.
I’m considering a persistant command filter as well, such that the way you perform your work itself affects the game. What if using sudo spuriously cost MP, cd progressed game time, and ls might cause a random encounter? You might heal according to the value of the commands issued while the filter was in affect, or take damage according to the return value of commands…
$ cd ..
“The door is locked”
$ cd /root
“It’s awfully dark in here…”