Dear all,
how can I print out part of what the player has typed in? Specific example: I defined a “look up xxx” verb and parse all kinds of topics:
wn = consult_from;
wd = NextWord();
if(wd==‘topic1’){
…
}
“No information on that topic found.”;
But instead of the generic “No information … found” output I would like to have an output “No information on xxx found.”, with “xxx” being the string the player typed. I tried to simply print wd or (string) wd but in both cases I just got a “[** Programming error: tried to print (string) on something not a string **]” error during the game.
I have saved the values of wn and consult_words, but I’m not sure if this is necessary. Check it out, I made this example a bit fast.
Code
Include "parser";
Include "verblib";
Object room "Room"
with description "You are in a room.",
has light;
Object book "book" room
with
name 'book',
description "It is a book about the fruits of the orchard.",
Before [ w cw swn;
Consult:
swn = wn;
wn = consult_from;
cw = consult_words;
while (cw) {
w = NextWord();
switch (w) {
'apple', 'apples': "Eat apples!";
'pear', 'pears': "Eat pears!";
}
cw--;
}
wn = swn;
print "No information on ";
PrintWord(consult_from);
".";
],
has;
[ PrintWord wordnum at len;
at = WordAddress(wordnum) - buffer;
len = WordLength(wordnum) + at;
for ( : at < len: at++)
print (char) buffer->at;
];
[ Initialise;
location = room;
];
Include "grammar";
Release 1 / Serial number 210105 / Inform v6.35 Library v6.12.4 S
Room
You are in a room.
You can see a book here.
>read about apple in book
Eat apples!
>read about apple from the orchard in book
Eat apples!
>read about cherries in book
No information on cherries.
Finally found the time to implement this. Wow! auraes, it works!! And I even understood what you’ve been doing and can amend it to my individual needs! Awesome, thanks alot!!!