I had a bit of time to tinker yesterday. I'm not sure what made me think of the old Infocom text adventures but here we are.
If you're familiar with Text Adventures (or Interactive Fiction) you may know that one of—maybe the—most popular tool for creating them has been the Inform language. The current version is Inform 7 but waaaaay back when I was first learning, it is was Inform 6.
Anyway, I decided to throw together a quick little IF authoring API loosely based on Inform 6. It is by no means complete or particularly advanced. Basically, I followed the first tutorial for the game Heidi from The Inform Beginner's Guide and implemented just enough to make it work. But work it does! Mostly. I think...
The command parser is extremely simple so don't expect too much from it. All commands should be in the form:
verb [noun] [noun] |
Where the nouns are optional depending on what you're trying to do. So east
or e
to walk to the east; take object
to pick up an object; and put object target
to put an object on/in something else. There are enough verbs, including synonyms, to complete this game and the API even lets you add new ones but don't try to be too creative with your commands. It was mostly just something to do on a Saturday afternoon so I may or may not develop it further.
The API clocks in at 926 tokens while the example game itself is only 173.
For simplicity's sake here's the code for just the game itself if you're interested in how it works. You can find the original in Appendix B of The Inform Beginner's Guide linked above if you want to see how the two versions compare.
Walkthrough
I can't enter the cottage, @jasondelaat.
Tried 4-different ways.
go cottage enter cottage in cottage open door |
There isn't an inside of the cottage. I followed the tutorial from The Inform Beginner's Guide verbatim. Well, apart from syntax differences obviously. They didn't write an inside of the cottage so I didn't write an inside of the cottage. It's not a particularly interesting or complete game it's just meant to be an example of how to create the basics of a text adventure.
If you click through to the hidden text in my post you'll see all of the rooms and objects that are defined in the game.
Browsing through the code just now I realized I should probably add 'climb' as an alias for 'up' so I've updated the cart.
There's a bug. Start the game. Head east. Take bird. Type: "PUT BIRD INTO NEST". And it crashes with:
Runtime Error Line 87 Tab 4
Attempt to index local 'target' (a NIL value)
@phil
Ah, thanks. Yeah I should put in a check to make sure it does something sensible with input it doesn't know how to handle. The parser...well probably really shouldn't be called a parser in truth. It's very simple. It doesn't know what to do with 'into': Thinks it's an object but can't find it in the set of objects.
PUT BIRD NEST
will work and I'll add that check later when I've got some time so it will at least fail gracefully instead of crash. Thanks for pointing it outd
Hi @jasondelaat:
I had to look inside your code and sure enough you are not covering the cottage. However for the very fact the game had listed the words "cottage" at all.
So then I looked inside the original Inform code to see if there was anything there about it.
And there was, they do handle the cottage after all. You get this:
in_to "It's such a lovely day -- much too nice to go inside."
That right there would've stopped me from trying. :)
Nonetheless it is impressive what you have done here, taking a massive programming language like INFORM and squashing it down to Pico-8.
And for that in your game of Heidi, I applaud you. Definite gold star.
Huh. Not sure how I missed that...
Ah! Just went back through the code and that's from the "Heidi Revisited" chapter which adds some additional features and mine was just based on the "original" version which left those out. Fair enough, going in the cottage is a pretty natural thing to try. I was poking around in the code anyway so I've add it in though I don't think I'll bother with the rest of the stuff from that version.
Thanks for the kind words. This is just the barest of bare bones; there are tons of features of Inform that are missing. I may or may not ever get around to adding them but it was a fun little project either way.
Problem, @jasondelaat:
Climbed the tree with the bird in the nest and typed, "Put Nest" and got this error.
Ah, it also died again when I typed, "Put bird" when I was carrying the bird and the nest was on the ground.
Also I could not seem to pick up the nest until I had placed the bird in the nest.
You may include a walkthrough of the game for people like me who keep typing the wrong things. :)
> "You may include a walkthrough of the game for people like me who keep typing the wrong things. :)"
Sure, that's a good idea. I've added it to the bottom of the post and I think I've fixed that bug. Thanks for the feedback.
Just tried this on an iPhone, but no obvious way to bring up the device keyboard, despite the keyboard option being enabled. I guess this is a wider option for the mobile player, but could there be a way to enter text, if the keyboard is enabled, please?
@DoctorMikeReddy
Unfortunately I think this is a limitation of the web player on mobile so I don't think there's anything I can do about it myself. And since the devkit modes aren't really intended to be used in actual games like I've done here I don't imagine that's likely to change anytime soon.
I could be wrong though. Maybe I just missed setting a particular flag or something so if anybody knows how to make it work on mobile and it's something I can do, let me know and I'll be more than happy to make the change.
[Please log in to post a comment]