Discuss Scratch
- Discussion Forums
- » Show and Tell
- » The Ultimate in Scratch Text Adventuring!
- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
About the project
This project contains many fully playable classic text adventures including -
It is a full z-code interpreter which means it is capable of running hundreds of different adventures. It even allows you to load and play your own z-code games!
How to play text adventures
When you start up a text adventure, it will display some introductory text and then print an input prompt, something like >. Nothing will happen while you wait at the prompt; time doesn't pass until you type something and hit Enter.
The commands you type are, for the most part, as if the sentences begin with “I want to…”. Think of the commands as telling your adventurer alter-ego what to do.
While many older adventures varied greatly in what kinds of commands they would accept, modern adventures tend to share the same commands and general syntax. For modern adventures, commands tend to fall into one of six categories:
Can the project play any other games?
It can play virtually any non-graphical z-code game! Not all features have been fully implemented yet. If you play a game and it doesn't seem to be working properly, have a look inside. Show the Todo Log list and it will let you know if any important features are needed by that game but are currently missing. Let me know if this happens and I'll (probably) work on adding those features. Note that I have no intention of adding graphics for Blorb files and v6 games. This isn't because it can't be done but rather because it would take a separate process to extract the graphics from those files.
There is an absolutely amazing collection of interactive fiction that can be downloaded from the if-archive. Go there, find a game you want to play, download it and play it in Scratch! If you find any that you really like or know of any other games you think should be included in the project then please let me know and I'll add them.
What else?
Implementing a z-code interpreter in Scratch has been a huge endeavour but one that has been extremely satisfying. There have been many hurdles to overcome. These included -
This project contains many fully playable classic text adventures including -
- Zork
- The Hitchhiker's Guide to the Galaxy
- Shade
- The Hulk
- Infidel
- Colossal Adventure
It is a full z-code interpreter which means it is capable of running hundreds of different adventures. It even allows you to load and play your own z-code games!
How to play text adventures
When you start up a text adventure, it will display some introductory text and then print an input prompt, something like >. Nothing will happen while you wait at the prompt; time doesn't pass until you type something and hit Enter.
The commands you type are, for the most part, as if the sentences begin with “I want to…”. Think of the commands as telling your adventurer alter-ego what to do.
While many older adventures varied greatly in what kinds of commands they would accept, modern adventures tend to share the same commands and general syntax. For modern adventures, commands tend to fall into one of six categories:
- A one-word action
These are the commands like LOOK, JUMP, and SING which don't act on any objects. - An action and a direct object
These are the commands that act on something. For instance, TAKE THE BOOK. TAKE is the verb, and THE BOOK (or simply BOOK) is the object. - An action, a direct object, and an indirect object
These are the commands that act on two things. You give a verb, the direct object of the verb, and the indirect object. PUT THE TOAST IN THE TOASTER is an example: PUT is the verb, THE TOAST is the direct object, and THE TOASTER is the indirect object. - An order to another character
In many games you'll meet other people or animals, and sometimes you cal tell them to do things. You do that by saying their name, followed by the command you want to give them. For example, RONALD, GIVE ME THE FRIES. - Communicating with another character
Besides ordering characters around, you can communicate with them using commands like ASK RONALD ABOUT THE FRIES, TELL RONALD ABOUT THE MANAGER'S SPECIAL, and SHOW THE GREASY BURGER TO RONALD. Strictly speaking, these fall under the third category above, but they're specialized enough that I wanted to make them a separate category. (And in some newer games you can TALK TO characters, just so you know.) - A special command
These are the commands which do something outside of the game world, like AGAIN, which repeats the last command you did, SAVE, which saves your game, and RESTORE, which reloads a previously saved game.
Can the project play any other games?
It can play virtually any non-graphical z-code game! Not all features have been fully implemented yet. If you play a game and it doesn't seem to be working properly, have a look inside. Show the Todo Log list and it will let you know if any important features are needed by that game but are currently missing. Let me know if this happens and I'll (probably) work on adding those features. Note that I have no intention of adding graphics for Blorb files and v6 games. This isn't because it can't be done but rather because it would take a separate process to extract the graphics from those files.
There is an absolutely amazing collection of interactive fiction that can be downloaded from the if-archive. Go there, find a game you want to play, download it and play it in Scratch! If you find any that you really like or know of any other games you think should be included in the project then please let me know and I'll add them.
What else?
Implementing a z-code interpreter in Scratch has been a huge endeavour but one that has been extremely satisfying. There have been many hurdles to overcome. These included -
- Larger text adventures weren't working because of the 200000 item limitation on lists so I've had to introduce a system of splitting large games across multiple lists
- Only a few adventures would fit into the project at first so I introduced a system by which adventures can be stored as graphical images and decoded within the game. This means the game can now hold hundreds of full adventures!
- Playing adventures without a load/save system can be soul destroying so I utilised my Save-Game Toolkit to allow adventures to be loaded and saved.
- Debugging has been painful to say the least!
- Adding an easy to use system that allows players to load and play their own z-code games.
- There's no way to detect the backspace key being pressed so I've had to use the “ask” block. As this takes up a different amount of space on a screen depending on resolution, full-screen or windowed, etc. I've had to allow the user to modify their playing area quickly and easily.
Last edited by RokCoder (Sept. 19, 2019 07:48:21)
- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
Bugs!
It's a huge project and there are lots of issues to sort out before I'll consider it complete.
Infocom
Trinity
Adventure International
Interactive Fiction
Colossal Cave
It's a huge project and there are lots of issues to sort out before I'll consider it complete.
General issues
- Status bar for v3 games needs adding again now that I've updated the entire output system (as the limited system I had previously only seemed to fully support Infocom games)
- Text windows are not yet implemented so the text format is often questionable.
- Room titles are appearing underneath the text instead of at the top of the screen (which relates to the windows implementation mentioned above).
- Negative scores display as large positive ones.
Game-specific issues
Infocom
Trinity
- Text parsing doesn't seem to be working at all.
- Can't enter the password on the keyboard. It turns out that you need to enter the word in quotation marks. E.g. TYPE “ANSWER” ON KEYBOARD.
Adventure International
- Their bespoke load/save routines aren't working from the start menu. Though upon reading the instructions properly it seems you have to enter “save game” rather than just “save” on these particular adventures!
- An extra newline is being inserted after any command is entered that isn't understood.
Interactive Fiction
Colossal Cave
- First line of text asking if instructions are required is hidden behind the status bar at the top.
- There's virtually no text appearing since the windowing system was added! I fixed the issue but discovered very occasional unsuitable use of language so removed the adventure from the project :(
- I have no idea what to do in this game. It understands very few instructions. This actually seems to be an issue with the game itself and not the interpreter!
- The game seems to work but displays a few lines of gibberish after every command! Internally there are some weird things going on. It seems that there are multiple threads running (though I'm 99% sure I've avoided that so I'm not sure how it's happening). For debugging purposes, __extended__ is the function where these issues start showing up…
- In-game help instructions take up the full screen and then don't release it afterwards. They also don't really show the instructions!
- The status bar at the top doesn't seem to update with new locations.
Last edited by RokCoder (Sept. 26, 2019 08:17:27)
- colinmacc
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
Minor bug report. There's a typo in the “Zork” intro text on the menu..
"The troll, who is remarkably coordinated, catches the brown sack and, hot having the most discriminating taste, gleefully eats it."
LOL I just had to check, and the typo is not in the game
"The troll, who is remarkably coordinated, catches the brown sack and, hot having the most discriminating taste, gleefully eats it."
LOL I just had to check, and the typo is not in the game

- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
Minor bug report. There's a typo in the “Zork” intro text on the menu..
"The troll, who is remarkably coordinated, catches the brown sack and, hot having the most discriminating taste, gleefully eats it."
LOL I just had to check, and the typo is not in the game
Haha! Now that's a bug I can fix quite easily

Last edited by RokCoder (Sept. 18, 2019 13:50:45)
- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
It's a language used to create text adventure games. Z-code was originally written by Infocom and has gone through many iterations and improvements over the years. There's a lot of interactive fiction (text adventures) still being written using z-code. In fact what is a z-code game?Inform 7 is a popular free app that can be used to make such adventures.
There are a large number of z-code games freely available at the interactive fiction archive. They're not all written using z-code but those which are can be played in Scratch using this project!
- colinmacc
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
The Dragon and the Troll
- I have no idea what to do in this game. It understands very few instructions. This actually seems to be an issue with the game itself and not the interpreter!
I can provide a walkthrough for this one now if anyone wants it! LOL!
- imfh
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
In the Adventure International games, text wrapping doesn't work correctly for the description at the top of the screen. Also, there is an extra newline whenever it doesn't understand something.
This is really neat! I like how you use images to store the data. I was trying something similar a while ago, but with multiple colors. It is definitely a lot faster when you use just 1 color.
This is really neat! I like how you use images to store the data. I was trying something similar a while ago, but with multiple colors. It is definitely a lot faster when you use just 1 color.
- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
Thanks for the bug reports! I'm surprised I haven't received more of them - hopefully it's because there are less issues than I imagined there would be In the Adventure International games, text wrapping doesn't work correctly for the description at the top of the screen. Also, there is an extra newline whenever it doesn't understand something.
This is really neat! I like how you use images to store the data. I was trying something similar a while ago, but with multiple colors. It is definitely a lot faster when you use just 1 color.

I've found many interesting things about z-code whilst making this project. One is that when it splits text windows (as in the Adventure International games) the top window doesn't wrap. I noticed the hyphenated line at the bottom of the description runs too far but figured I could live with that? Are there occasions when the actual text is overrunning the screen edge? I just tested in WinFrotz and it simply cuts the end off text if you reduce the window's width but we are stuck with quite a small maximum width in Scratch by default.
As for the extra newline, I've added that to my bug list - thank you

I was very pleased with how the image->data worked out. Especially being able to use it while the barcode type screens are concealed. I thought about using 256 colours for one byte per pixel rather than one bit per pixel. It would have used far less image space but I figured it would be approximately 32 times slower!
- The_BenG
-
2 posts
The Ultimate in Scratch Text Adventuring!
I'm storing my save code here : 000001c1AA8AAABnTn-df90AAH-nAPAAJQAAABcABwAAAAAAAAAHAAF-9gGLACQAYQAAAGEAAQABAAAAAAAAAAAAAAAAAAB–wDrACQAAQABIsQiyiLW-1ZvCP8MDQgCxyOmVghaAHUAYjUhCD4IuoYEAEQIAvwpCFAIAPwA5XsIgAAGJ1gIAPwAyDMIAAAFB48GBAACEgIIAPwAiRgIswg1CAD8FwQTCGUAPHsAAACw-yr-mv8A-5r-Bf_S-wD-wP8E-4j-K-9B-2PMAP8r-0b-Gf9E-9n-3-_I-0zwewEKATUORQD5AP8A-wQlAE4RYQt7EfwOJQB_EC4AbwsBODcAngEHEZAdBwUBFQrdAQD-APsAbAC-AQEBrwAvAB0DKAAvACMBAQD-AMoALQDvAv8A-wAtAHUBAQD-AMoALQAMtQEAQgDpAAQAAQBFAHsAAgAEADcAngAEAAcAPADCAAQAC99zAGEAdgBlAW4BaQByAGQBeQBvAG4CYQBzAGW19QAlAHYRvAAlAHYB-wYjAJgAIwCcBEIA6QAEAAEHYf8AK8j-9P8F-4D-Af8B8iwAGgAsABwELABIACwASgIsAGACLAB2J8oR
- imfh
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
In “Mission: Impossible,” if you travel West then South, it cuts off “Chair bolted to the floor” in the middle of “bolted.” Looking at an emulated version, “Chair bolted to the floor” is put on a new line for some reason: https://archive.org/details/a2_asimov_mission_impossibleThanks for the bug reports! I'm surprised I haven't received more of them - hopefully it's because there are less issues than I imagined there would be In the Adventure International games, text wrapping doesn't work correctly for the description at the top of the screen. Also, there is an extra newline whenever it doesn't understand something.
This is really neat! I like how you use images to store the data. I was trying something similar a while ago, but with multiple colors. It is definitely a lot faster when you use just 1 color.
I've found many interesting things about z-code whilst making this project. One is that when it splits text windows (as in the Adventure International games) the top window doesn't wrap. I noticed the hyphenated line at the bottom of the description runs too far but figured I could live with that? Are there occasions when the actual text is overrunning the screen edge? I just tested in WinFrotz and it simply cuts the end off text if you reduce the window's width but we are stuck with quite a small maximum width in Scratch by default.
As for the extra newline, I've added that to my bug list - thank you
I was very pleased with how the image->data worked out. Especially being able to use it while the barcode type screens are concealed. I thought about using 256 colours for one byte per pixel rather than one bit per pixel. It would have used far less image space but I figured it would be approximately 32 times slower!
If it's easy to do, it might look better if you replaced the hyphenated line with ^ ^ ^ ^ ^ ^ like it does in the emulated version. It would just be a small visual tweak though so it might not be worth the effort.
I would guess that the newline in front of the unrecognized command is something to do with how it flashes the input. There's probably a special character being treated as a newline somewhere.
- oblanman
-
26 posts
The Ultimate in Scratch Text Adventuring!
Man, this looks amazing! Good job, I could never hope to do this!
- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
https://archive.org/details/a2_asimov_mission_impossibleThanks for the link - made it much easier to see what you were describing. You were playing an emulated version of the original release. I actually made a Scott Adams interpreter many moons ago which you can find in my In “Mission: Impossible,” if you travel West then South, it cuts off “Chair bolted to the floor” in the middle of “bolted.” Looking at an emulated version, “Chair bolted to the floor” is put on a new line for some reason: Adventure Studio. Unfortunately it broken in the transition to Scratch 3.0 (as did most of the adventures in that studio). I'll modify them with the UI of this project at some point… Anyway, the original games weren't z-code. They were translated to z-code later to make them readily available but that's where the differences creep in. If you play the z-code versions on any interpreter you'll find the same issues if you reduce the screen width. There's not really much I an do about that without adding special case per-game code into the interpreter which I don't really want to do.
It's a nice thought but this is the same issue as above. They've changed the characters during the conversion to z-code so, unless I add per-game hacks into the interpreter, they're not going to look like the original version. If it's easy to do, it might look better if you replaced the hyphenated line with ^ ^ ^ ^ ^ ^ like it does in the emulated version. It would just be a small visual tweak though so it might not be worth the effort.
It's to do with the way the interpreter can switch between windows and also between buffered and unbuffered text. There are a lot of differences in that area due to the methods I've used for displaying text. Hopefully I'll have time to think of a neater solution for that as I suspect it'll cause issues here and there in a lot of different z-code games. I would guess that the newline in front of the unrecognized command is something to do with how it flashes the input. There's probably a special character being treated as a newline somewhere.
Thanks very much for taking the time to report all of the above

- imfh
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
That makes sense. It's not really worth it to go through and make a bunch of small changes like that.https://archive.org/details/a2_asimov_mission_impossibleThanks for the link - made it much easier to see what you were describing. You were playing an emulated version of the original release. I actually made a Scott Adams interpreter many moons ago which you can find in my In “Mission: Impossible,” if you travel West then South, it cuts off “Chair bolted to the floor” in the middle of “bolted.” Looking at an emulated version, “Chair bolted to the floor” is put on a new line for some reason: Adventure Studio. Unfortunately it broken in the transition to Scratch 3.0 (as did most of the adventures in that studio). I'll modify them with the UI of this project at some point… Anyway, the original games weren't z-code. They were translated to z-code later to make them readily available but that's where the differences creep in. If you play the z-code versions on any interpreter you'll find the same issues if you reduce the screen width. There's not really much I an do about that without adding special case per-game code into the interpreter which I don't really want to do.
No problem! Thanks very much for taking the time to report all of the above
- tinmap
-
19 posts
The Ultimate in Scratch Text Adventuring!
Last edited by tinmap (Sept. 21, 2019 02:51:42)
- dekjaz
-
4 posts
The Ultimate in Scratch Text Adventuring!
just my save code:
000002adABQT9ADBbH-gf_AAAH-qAQ0ALgAAAHgABwAAAAAAAAAHAAF-_QAqAC0AAAAAAHgAAQAAAAAAAAAAAAAAAAAAAAB–wGIACwAAAAG-6X-0-8A-7r-gP8VnCAaIAggB5AIkAkgfSAD7FUgCCAB7ADVBSABiwCJB4sAhggADiAB7ACFBSADhwQgCCAIIGIgIyAaIAggPiA1IAggCCARIAggCCAIIAggCCA1IAggCCAIIAggCCAIIKAwACAB7ADWBSEB7ADZDiAK7ADjKSA9gAAAB4AAAAeQJCADAAZ6AHkAiv8u-y3-AP8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oBeAfsAv8A-wAuAFkAQgDOAEcAlgAuAHULBzdsAQ8BXAMCDY8BAQIAAPAHeAFLAQH_hwCrBIcAlgEBAP8A-wBAABcC-wD-AD4AFwEBAAIAtQBLACkBAQABAAEASgC0AQEABwBBAEcAEgEBAP8A-wA7ALsBAQD-AP8ANwDGAQEA-wD-ADUAYP8A-wBxAQBSAL4ABAABAFIAOQADAAcATgDOAAgADwBOAM4ACAAPAFcAFwAHABPbcwBhAHYAZQEgAHIAZQBkAW8AbgEgAG0AZQBnAGEAZgB1AHMAZQFuAGevowAuAG0R0AAuAG0IMAALADAAEwRSAL4ABAABB3gBcQFyAXMBdAF1AXYBdwF4-wB9BgBHAJYCUgA5AkcAlgJNAFQCUwBDAk0AWwJOAM7-AP8A-wD-AP8AywEBAwEFAQYBAgEEAQf-AP8A-wDrJwf
- Peace_ful8
-
31 posts
The Ultimate in Scratch Text Adventuring!
Having issues storing my save codes. It gets cut off by a … which means I cannot copy most of it. What do I do?
- RokCoder
-
1000+ posts
The Ultimate in Scratch Text Adventuring!
Triple clicking the save code selects it all - at least it does when using Chrome on a Windows 10 computer. Let me know if that doesn't help and I'll look into it further. Having issues storing my save codes. It gets cut off by a … which means I cannot copy most of it. What do I do?
- notrealNAEM
-
2 posts
The Ultimate in Scratch Text Adventuring!
In Hitchhikers guide to the galaxy, how do you get out of the “dark” place?
actually i found it
actually i found it
Last edited by notrealNAEM (Sept. 22, 2019 23:12:55)
- notrealNAEM
-
2 posts
The Ultimate in Scratch Text Adventuring!
oh yeah and i wish that when you restart that the progress from last time doesn't affect it.
- Discussion Forums
- » Show and Tell
-
» The Ultimate in Scratch Text Adventuring!