Stupid Python Trick #6: Interactive Fiction

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.
Note: posts here are not necessarily endorsed by the community, and may represent amateur or even bad practices.

Stupid Python Trick #6: Interactive Fiction

Postby ichabod801 » Sat Mar 23, 2013 7:20 pm

I have put together a few classes and a cmd.Cmd instance that works as a basic engine for interactive fiction/text adventures. The code is available on my Xenomind website as usual. The zip file that link goes to contains the p_machine package with the engine and, a short sample adventure made with that engine.

Let me be clear about what this is and is not meant to be. This is not meant to be a full featured interactive fiction engine. It needs a lot of work before it can be anything like that: it's own interface, a broader and more flexible lexicon, a simple and embedded way to deal with doors, vehicles, group objects, at least a way to plug in a combat system, and who knows what else. Maybe I'll get around to writing something like that, but not today.

What this is meant to be is an answer to a common question. We are often asked "What's the problem with my text adventure?", and the answer is buried somewhere in a morass of 200 nested if statements. The usual answer is "learn classes." While that answer is correct, it's a bit short on details. We now have three brief tutorials on classes, and by the end of the week I hope to have a explanation here of how I wrote this program. Then we can give the more detailed answer of "read these tutorials on classes and the description of this program." So this is just meant to be a basic interactive fiction engine that a bright beginner could wrap their head around.
Due to the reasons discussed here we will be moving to on October 1st, 2016.
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
Posts: 688
Joined: Sat Feb 09, 2013 12:54 pm
Location: Outside Washington DC

Return to Completed Scripts

Who is online

Users browsing this forum: No registered users and 2 guests