Hi there, I need some basic help with tables.
My game has a “file reading” mechanic, as if the player is opening files in a computer database.
Right now, it successfully displays content from the file then continues to watch for the user’s next file number selection. I’d like the player to have an “exit” option to return to the main story. How can I do this?
Table of Flash Drive
File Name Type Content
0 "Exit" " " " "
1 "oldHouse" ".vid" "Old house video"
2 "missingDog" ".txt" "Missing dog post"
Current file table is a table name that varies.
Understand "[number]" as selecting.
Selecting is an action applying to one number.
Instead of selecting a file listed in the current file table:
choose row with file of number understood in the current file table;
say "[Content entry]";
Carry out selecting:
say "File not found!";
BTW I’m writing and publishing with playfic.com so I don’t have access to extensions, etc. I also don’t really have a coding background so I’m learning as I write.
Instead of selecting -1:
[go back to the game]
Then just display that -1 means exit. Or use 0 for exit and start your entries at 1.
Or, make a new command that exits out of the special mode.
Thank you! I’ve worked out the selection issue, but I’m having issues leaving the mode. I’m probably missing something fundamental here.
Well, how are you preventing other actions while in this mode?
Actually, after more troubleshooting, I realize I’ve misunderstood the issue! It isn’t getting stuck in a mode – it seems that the “
Understand "[number]" as selecting. Selecting is an action applying to one number.” code is the issue here. If the player uses an unknown command it returns “I didn’t understand that number” even at the start of the game.
So overall, it’s frustrating but nothing game-breaking.
Two (EDIT: Three) possible solutions to your frustration:
- make your understand rule context-dependent so that the parser ignores it except when it’s appropriate, e.g.
Understand "[number]" as selecting when the computer terminal is touchable.
- or, add this line which will intercept any unrecognised opening text in a command throughout the game and give the standard parser response for an unrecognised verb:
Understand "[text]" as a mistake ("[text of parser error internal rule response (N)]").
EDIT: if you choose option 1, you might want to add a complementary Understand line to avoid a bland parser error if the player tries typing a number where it won’t work:
Understand "[number]" as a mistake ("You can't open a file from here!") when the computer terminal is not touchable.
- a third option, which you could use if there isn’t any reason elsewhere for your player to use numbers after the first word of a command. The following diverts the ‘I didn’t understand that number’ response to something else:
For printing a parser error when the latest parser error is the didn't understand that number error:
say "[text of parser error internal rule response (N)][line break]" instead.
Or you could prompt for input directly and not use the command loop. My guess is that all this would work in 6G60, though it was tested in 10.1.
when play begins:
let num be the number selected;
To decide what number is the number selected:
decide on "[line input]" as a number.
To decide what number is (t - a text) as a number:
let backup be the substituted form of "[the player's command]";
change the text of the player's command to t;
let result be 0;
if the player's command matches "[number]", now result is the number understood;
change the text of the player's command to backup;
decide on result;
To decide what snippet is the line input:
(- getLine() -)
return 100 + WordCount();