IF system recommendation for emulating a command shell

I am working on writing an IF piece that revolves around the player interacting with a computer terminal. Ideally I would like it to feel very much like a Linux command shell (e.g. bash), including variables, command-line flags, command pipes, stream redirects, file creation/manipulation, and command/file permissions. (Graphical output capabilities optional.) This is particularly important because the story involves cognitohazardous data. (The work is based on the SCP Foundation.)
I intend to use certain special characters as part of text in order to mark which areas are cognitohazardous, with the condition that if that character would ever be displayed on-screen, the player dies/loses.

I have considered a large number of possibilities for ways to make this, including using an actual linux virtual machine, modifying it to provide the required functionality. This would be incredibly complicated to pull off, and if possible I would like to avoid that.

Also, if possible, I would like to be able to embed the final result in a WikiDot page, since the SCP Foundation wiki is wikidot-based.

Is there a good IF system that can be used to create something like this?

Every parser-based system that uses an imperative programming language is suitable for this. Inform (v6 is better for this, but I think you can use v6 code in Inform 7), Tads, Hugo, etc. They can all do the job. You only need to decide which language you like better and which interpreters or web systems you want to be used to run your project.

It seems that trying to implement variables, command-line flags, redirects etc. in Inform would be… extremely tedious?

Yes.

Implementing them in any language is a pain in the butt; shells are notoriously ugly balls of hackery. When a fake-shell appears in a game, it’s usually a very minimal subset of “real” shell functionality.

Inform is not great at fine-grained text manipulation. You might get some distance by relying on the regular-expression feature.

I’d say your best bet is to write it in straight Javascript. You’ll still be writing a bunch of text-parsing code, but Javascript is only half-terrible at that (and it has regexps too).

The GlkOte library (eblong.com/zarf/glk/glkote/sample-demobase.html . (It’s part of Inform’s play-on-web-page package.)

I haven’t used this library myself, but if you go with JavaScript you might find Josh.js useful. It seems to do some of what you need.

I would view this as an external extension of the game, so I would manage any state from the game, but the construction and interaction of the terminal would be done in HTML/CSS/JavaScript (although that josh.js lib seems perfect).

I would not try to implement this within any of IF platform.

This is yet another reason to separate UX from game logic. (see fyrevm)

Have you tried Tads 3? It should have adequate text processing routines, including regex:

tads.org/t3doc/doc/sysman/string.htm

tads.org/t3doc/doc/sysman/regex.htm

Well, in this case, the shell interaction is actually the only interaction in the entire game (besides possibly being able to reboot the computer). At this point it looks like it will probably be easier to use a doctored version of linux in an existing javascript x86 emulator, rather than reimplement the shell myself. Something like bellard.org/jslinux/.

Didn’t Cosmoserve do this to some extent?

cf also several text adventures written completely using batch files from the MS-DOS command prompt.

:open_mouth:

Not sure how relevant, but I did encounter this OpenCOBOL for Inform 7 peoplecards.ca/inform7/hello101/source.txt

Hi,

years ago i wrote a game system that actually ran on the command shell.

Consider this, eg under linux;

Your “verbs” are actually program binaries (eg get, drop, give etc.). You write one program that handles options etc and each “verb” is actually the same binary renamed. the verb looks at argv[0] to figure itself. Alternatively, write a common library and each verb is separate.

“objects” are files and the directories are “locations”. Your current working directory is your own location. These objects are simply text files with key:value properties. Verbs look at these to make checks. eg the file “coin” might have a property “value:1”.

For example, “get” works by moving an object (a file) into your home directory (or, eg ~/.moo). drop works by moving an object (a file) from ~/.moo to the current working directory.

symlinks provide routes between locations. “go” changes you cwd, but it also has to drop a temp file in there so that other players can see you!

Which is a really big win, as the whole system is automatically a multi-user game.

You have command like “say” which sends a message to players in the same location and “shout” which sends messages to all players.

Then you add some building commands. eg spend “coins” to build your own locations (works by creating directories) and then you have a MOO, where players can build their own castles and realms.

You have a central bank that issues coins, thats managed by the game (and its mods) to control the growth.

I had this working but ran out of time to finish it properly (work got in the way).

yea, cosmoserve came to my mind reading this debate. and was written with AGT.

Occasionally I toy around the idea of encapsulating some IF under an “shell” (I’m not sure if is a twist or is only twisted, but the general idea is that the PC is an IF player…) and I’m reasonably sure that early 80s OS’s CLI (e.g. CP/M or MS-DOG) can be satisfactorily implemented as this “shell” with practically every IF language.

sadly these days the ratio between the “messing/fooling” and actual WIP in my if/wrk/ directory is alarmingly deteriorating…

Best regards from Italy,
dott. Piergiorgio.