Ask and Tell Topics

Hi, I have a quick question that’s probably already been answered multiple times. I’m trying to make the parser’s syntax a little less… computer-like on ask / tell. For example, I can have a topic like:

Tell someone about “x”.

But, if I want to ‘tell someone a joke’, I don’t want to ‘tell someone about joke’, and I would also like it to recognize ‘tell joke to someone’. I had the idea of making ‘joke’ a sort of object, hidden in scope, to clear up the non-existence of it, but that seems inelegant and will create a lot more programming.

So, is there a good way to add syntax changes that do the same thing?

Anyway, I’m pretty new to Inform 7, but IT IS AWESOME. I’ve been monkeying around with IF since 1995 or so, and the development systems back then had a limited amount of rooms, flags, etc. The freedom and hidden complexity is of I7 keeps shocking me. It’s so much fun to develop in this system.

Anyway, thanks for any help!

You can add some additional “understand” lines of code to help you enable different ways to use the same command.

Try these for starters:

Understand "tell [someone] about a/the [text]" as telling it about. Understand "tell [text] to [someone]", "tell a/the [text] to [someone]" as telling it about (with nouns reversed).
The “a/the” part will ensure that players will get results whether they type “tell him a joke” or “tell him the joke”. Also, the “with nouns reversed” part of the second line is important when you switch around the text tokens.

Amazing, thank you – I’ll try that out when I get home.

So, in this case, the ‘text’ is an object (or token, as you called it), like a thing, or a room, but it’s created on the fly, with parenthesis? I’ve noticed that ask / tell topics don’t need to be grounded in an object, but anything can be asked about if it is in parenthesis, even if it doesn’t exist in the game world. This was really surprising to me. I guess my next question is, how does an ask / tell topic differ from an object that has to be declared, like a room, or a thing?

Well, this gets more into the technical aspects of how I7 handles things, so I may not the best equipped to answer your questions here. I’ll tell you the important parts.

When you use [text] in a command syntax, the player’s special input (in your case “joke”) falls into a snippet called “topic understood”. Therefore, since the topic understood is going to be whatever the player has typed, it doesn’t necessarily have to be any object in the game. It can even be complete gibberish if that’s what the frustrated player typed.

Example: Instead of telling bob about anything: say "[topic understood]?! Is that some kind of joke?"
Now look what happens here when I try to talk to bob about gibberish:>tell bob about 23572378dfdsfsdbfsd 23572378dfdsfsdbfsd?! Is that some kind of joke?
A snippet can be treated in many ways like a text variable, though with some limitations.

Now if you want the ask/tell actions to actually use objects in the game world, that would require you to create a new action for each, because [text] would no longer be the suitable token in that situation. Also be aware that it is certainly possible to have both a topic-based and an object-based ask/tell system. It would require a bit more work, though.

Aha! Topics are variables, not objects. That makes perfect sense. So, here’s one last question: could I search through that snippet of gibberish and find out if it’s close to an actual topic? Sort of like MySQL’s wild card variable? “If [text topic] is LIKE %actual_topic%” would be how I do this in MySQL, with the % being the start / close of the wild card (meaning, anything can be attached to either end, but within the wild card is the actual topic.) I’ve seen some grammar fix extensions, and I’m assuming this is how they work, but I’m not sure of the language enough yet to know.

I know I’m going on a few tangents here, but thanks for clarifying all of this!

You can do a variety of matches with the topic understood just as you can with other kinds of texts. Check the manual for pages 19.5 and 19.6 to see the possibilities. One is a simpler method and the other uses regular expressions.

For the basic matches you want to utilize “matches the text”, which is thankfully very easy to use.

Before telling bob about anything: if topic understood matches the text "bad": say "I don't like you using the word 'bad' under any circumstance!" instead.
Output:

[code]>tell bob about bad dudes
I don’t like you using the word “bad” under any circumstance!

tell bob about baddudes
I don’t like you using the word “bad” under any circumstance!

tell bob about good dudes
This provokes no reaction.
[/code]

Great! Thank you for all the help and the quick replies. I’m designing a pretty elaborate game for my first one, since the story requires it. I know that I’m using some workarounds that are heavy on resources to get things to do what I want, since I’m still learning I7, but this solution cuts my code down significantly.

Now I need to figure out the wonder of tables… other posts to follow :smiley: