intfiction.org

The Interactive Fiction Community Forum
It is currently Tue Nov 20, 2018 9:48 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Aug 20, 2018 10:30 am 
Offline
User avatar

Joined: Mon Oct 11, 2010 1:27 pm
Posts: 1761
I have used the LanguageVerb function a lot to deal with the "only understood as far as" error for unusual metaverbs, e.g. "about."

But I'm confused by how to get 2-word commands to work.

Code:
Include (-
Replace LanguageVerb;
-) after "Definitions.i6t".

room 1 is a room.

Include (-
[ LanguageVerb i;
   switch (i) {
     'i//','inv','inventory':
            print "take inventory";
     'l//':   print "look";
     'x//':   print "examine";
     'z//':   print "wait";
     'avada kedavra//':    print "cast a killing curse (2 words)";
     'avada':    print "cast a killing curse (1 word)";
     'about':  print "see info about the game";
     default: rfalse;
   }
   rtrue;
];
-) after "Language.i6t".

understand the command "avada kedavra" as something new.
understand "avada kedavra" as requesting the score. [ok, it does something else, but let's keep the example simple]

test ak with "avada kedavra x"


In the example above, I'd like to see "cast a killing curse (2 words)" but instead I see "cast a killing curse (2 words) kedavra." This makes sense, since LanguageVerb is called from Parser.i6t on a word by word basis.

But is there an easy, sensible way to do this in inform 6? I suppose I could really hardcode things in Inform 7 with an "after reading the player's command: (change regex "^avada kedavra" to "avadakedavra" and use avadakedavra as a command) but this looks like a hack.

I could also have a table that the "Rule for printing a parser error when the latest parser error is the only understood as far as error" reads through and then notes you used a 2 word command, but again, that feels like a real hack.

It'd be acceptable, but I can't help feeling there's something a lot better.

Thanks for any and all help!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Aug 20, 2018 12:00 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5806
PrintCommand has the job of printing the entire player command. It calls LanguageVerb on the first word (de-abbreviating it), and then prints the rest of the grammar line, inserting the parsed objects as needed.

Note that your line "'avada kedavra//': print ...;" can't work as written. 'avada kedavra' can never be a dict word in the player's input, because the input routine treats spaces as a separator.

(Also, the '//' is only needed for one-letter dict words. 'x' is a character value, 'x//' is a one-letter word, but 'avada' is unambiguous and doesn't need the //.)

So it sounds like you want to add more logic to PrintCommand. I think you want to check action_to_be; if that's a specific action value (the avada kedavra action), you print your string and skip the rest of PrintCommand.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 23, 2018 7:28 pm 
Offline
User avatar

Joined: Mon Oct 11, 2010 1:27 pm
Posts: 1761
Thanks, Zarf! I tried a few things at first, and while I haven't gotten it nailed down, what you have is a good start. It feels right, and I think I'm being thick about the execution. I'll post something if/when I figure what's going on.

Also, I really did try just "avada kedavra" first but slapped on the "//" as a wild try that didn't work.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group