(1) Using BeforeParsing, convert “your name is nicola, you live in rome” to “try your name is nicola you live in rome” (note that I got rid of the comma).
(2) Create a fake object with a parse_name that checks for “nicola” and “rome”.
(3) When the game asks that question, move this object into the room with the player. (You have to have at least one room, even if it’s invisible.)
(4) Have parse_name save the number of matching words, using a property of the object.
(5) Create a verb for “try”.
(6) Write a before response for the Try action that checks the number of matching words and prints out a suitable response.
Your indications soundend pretty cool, so I decided to stand on at night to try them.
You said you was wondering if that was actually possible (open question aren’t something pretty concerning inform), but I found those hints useful, except that I had to learn everything about parse_name.
That’s what I approximately made:
The mocking object:
Object book_mineral “libro sui minerali” ,
with parse_name [;
if (NextWord() == ‘tomato’ or ‘fried’) opscore++;
if (NextWord() == ‘fried’ or ‘tomato’) opscore++;
if (NextWord() == ‘tomato’ or ‘fried’) opscore++;
if (NextWord() == ‘fried’ or ‘tomato’) opscore++;
if (NextWord() == ‘tomato’ or ‘fried’) opscore++;
if (NextWord() == ‘fried’ or ‘tomato’) opscore++;
if (NextWord() == ‘tomato’ or ‘fried’) opscore++;
if (NextWord() == ‘fried’ or ‘tomato’) opscore++;
if (NextWord() == ‘tomato’ or ‘fried’) opscore++;
if (NextWord() == ‘fried’ or ‘tomato’) opscore++;
],
has ;
That’s able to catch 10 words, and if 1 of these are “tomato” or “fried” then opscore++ (Global constant).
Then as you said in point 4, the mocking object is able to record num of matching words, Cool
Object is in the same room, ok, but about the “try” was impossible to make waht you said, actually if you player, declare “try your name is nicola you live in rome”, inform doesn’t recognised the subject of try and replicates “You can’t see any such thing.”
I think it’s due to the parse_name, anyway I solved easily on this (went over English.h, erased “You can’t see any such thing.”, and then print myself the suitable response.
Coming to the end, when the object recorded the constant “opscore” I realised it wasn’t just anymore an idea.
At last I didn’t succeed in the big deal, as you can observe, I didn’t mentioned the point 1 of your project.
I actually couldn’t find the way to make BeforeParsing adding the verb at the beginning of the input, that’s really the ending point, i look up at DM4, but I couldn’t do nothing about it, so I need the BeforeParsing Code that tranforms the user inputs adding the word
( an answer like maybe “your name is nicola, you live in rome” ->should end as something like-> “Climb your name is nicola you live in rome”)
So well:
- Adding the word 0
- Deleting commas
For anybody who can help I give you some cool stuff and idea about BeforeParsing code (to correct incorrect inputs ) I found around tryng to learn how it works, anybody who mastered BeforeParsing and can helps me would have all my gratefullness
Extra stuff I found about same topic:
BeforeParsing code (to correct incorrect inputs ):
!----------------------------------------------------------------------
Constant MAX_WORDLENGTH = 10;
[BeforeParsing word num_word;
for (num_word=1 : num_word<=num_words : num_word++) {
word = tokenDict(num_word);
switch(word) {
‘cerbiato’, ‘crebiato’, ‘crebiatto’:
num_word = ReplaceWord(num_word,‘cerbiatto’);
‘prendi’:
num_word = ReplaceWord(num_word,‘lascia’);
}
}
];
[ReplaceWord num_word word new_word pos_word num_letter;
pos_word = tokenPos(num_word);
for (num_letter=0 : num_letter<=MAX_WORDLENGTH : num_letter++)
LTI_Insert(pos_word+num_letter, word->(num_letter+1));
#ifdef TARGET_GLULX;
Tokenise__(buffer,parse);
#ifnot;
@tokenise buffer parse;
#endif;
return 0;
];
And a quote about this library " LanguageToInformese(). ", according to the author Francesco Sircana, he used a lot BeforeParsing in it. Good job guys, if you find it, post the beforeparsing code, I’ll post my final job in exchange, thanks everybody !