hi guys, how can i set the player input symbol “>” with a question like “What should i do?”
From the Inform6 docs:
DM4 §25: Extending and redefining the world model (inform-fiction.org)
An especially useful library message to change is the prompt, normally set to "^>"
(new-line followed by >). This is printed under the action Prompt
(actually a fake action existing for this very purpose). You can use this to make the game’s prompt context-sensitive, or to remove the new-line from before the prompt.
• EXERCISE 59
Infocom’s game ‘The Witness’ has the prompt “What should you, the detective, do next?” on turn one and “What next?” subsequently. Implement this.
From the Inform7 docs 8.2. Changing the command prompt (ganelson.github.io) :
When play begins:
now the command prompt is "What should I do? ";
Include “Parser”;
Object LibraryMessages
with before [;
Prompt: switch (turns) {
1: print “^Cosa devo fare adesso?^>”;
2 to 9: print “^What next?^>”;
10: print “^(Aren’t you getting tired of seeing ~What
next?~ From here on, the prompt will be much
shorter.)^^>”;
default: print “^>”;
}
rtrue;
];
Include “Verblib”;
Include “Replace”;
Object stanza_1 “Salotto” with description “Ti trovi nel salotto della tua casa.”, has light;
[Initialise;
location=stanza_1;
];
if I enter the code in this way, the symbol “>” appears at the beginning of the game, and the question “Cosa devo fare adesso?” happens only after the first player input…
Hmm… maybe turns starts at 0?
yes! Thank you very mutch!!!
[This is regarding your deleted post about not wanting the modified prompt after certain library messages.]
Here’s something compatible with Standard Library 6/11. Place the following between the inclusion of “Parser.h” and of “Verblib.h”:
Global last_LM; ! holds last library message displayed for ##Miscellany
Array excluded_messages table 5 10 45 46 47 48 49 57; ! list of ##Miscellany library message numbers needing normal prompt after
Object LibraryMessages
with before [ i ;
Prompt:
for (i=excluded_messages-->0: i > 0: i--) {
if (excluded_messages-->i == last_LM)
rfalse;
}
print "^*>"; ! <-- replace with the prompt that you want
last_LM = 0;
rtrue;
];
Object "(interceptLMID)" LibraryExtensions
with ext_messages [;
Miscellany:
last_LM = lm_n;
];
Note that you’ll have to review the Italian library to find out which message numbers should not use the modified prompt, and change excluded_messages
accordingly. For this example I just listed every message that ends in a question mark.
I’m not sure that the Italian library would have the LibraryExtensions
subsystem, so this may not work as-is. If the subsystem is not available, then the capture of the library message number being printed can be done a different way. The easiest place to change things might be a modification of routine L___M()
(note three underscores, not two), which can be found in verblib
and hopefully exists in the Italian library. There should be a line:
[ L___M n x1 s;
...
action = sw__var;
...
];
which can have the following placed after it:
[ L___M n x1 s;
...
action = sw__var;
if (action == ##Miscellany) last_LM = lm_n; ! ADDED
...
];
The routine needs to be modified either using the Replace
directive (prior to including verblib
, with the modified definition coming after including verblib
) or by using an alternate version of the library file.