In my current game I have a separate window that automatically displays the items carried by the player.
There is a rule that refreshes this window Every Turn.
Rule for refreshing the contents-inventory window:
try taking inventory.
If the player types >examine of something they are carrying, I would like the thing’s description to be displayed in the inventory window instead of the list of inventory items.
I have been able to create a rule that overrides the “standard examining rule” and prints the thing’s description in the inventory window.
Carry out examining (this is the new examining rule):
if the noun provides the property description and the description of the noun is not "":
focus contents-inventory window;
say "[description of the noun][line break]";
focus main window;
now examine text printed is true.
The new examining rule is listed instead of the standard examining rule in the carry out examining rulebook.
But when I type >examine [something] the description is printed in the inventory window but it is immediately replaced by the inventory list because of the refresh contents-inventory rule.
My initial thought was that I need to put some conditional logic in the refresh contents-inventory rule so if the player has typed >examine [something] then the description should be displayed otherwise try taking inventory.
My problem is I don’t know how to “trap” what verb command the player just typed. Did they type “examine” or did they type “north” or “look”?
I’ve taken a step back while I think some more about this, re-reading the Activities and Rulebooks sections of the documentation, but I also thought I’d ask her in case anyone has any suggestions.
Inventory suppressed is initially false.
After examining:
now inventory suppressed is true;
continue the action.
Rule for refreshing the contents-inventory window:
if inventory suppressed is true:
now inventory suppressed is false;
otherwise:
try taking inventory.
@Draconis - Thanks for your suggestion. I had not thought about using a global variable but let’s see how your proposed solution works.
I created the inventory-suppressed truth state and modified the rule for refreshing the contents-inventory window like you suggested.
inventory-suppressed is a truth state that varies.
inventory-suppressed is [initially] false.
Rule for refreshing the contents-inventory window:
if inventory-suppressed is true:
now inventory-suppressed is false;
otherwise:
try taking inventory.
I added your After examining code after my new examining rule.
Carry out examining (this is the new examining rule):
if the noun provides the property description and the description of the noun is not "":
focus contents-inventory window;
say "[description of the noun][line break]";
focus main window;
now examine text printed is true;
The new examining rule is listed instead of the standard examining rule in the carry out examining rulebook.
After examining:
now inventory-suppressed is true;
continue the action.
When I have items in my inventory.
And type >examine knife the first time, the You Are Carrying window is cleared out.
When I type >examine knife a second time, the knife description appears briefly but the window is then quickly cleared.
I’ll keep debugging and let you know what I find out.
I don’t have your full setup to test, but I would do all inv-window stuff in a single rule.
cur-examine-item is an object that varies. cur-examine-item is initially nothing.
After examining something:
now cur-examine-item is the noun;
Rule for refreshing the contents-inventory window:
if cur-examine-item is nothing:
try taking inventory;
else:
say "[description of cur-examine-item][line break]";
now cur-examine-item is nothing;
@zarf - This appears to work and also requires the least amount of code.
I created a currently-examined-item object variable and used that as a conditional in my refresh contents-inventory rule. Since I wanted the title-inventory window to display the object name, I chained that refresh rule to the first one.
currently-examined-item is an object that varies.
currently-examined-item is initially nothing.
Rule for refreshing the title-inventory window:
if currently-examined-item is nothing:
say "You Are Carrying";
else:
say "[currently-examined-item]" in title case;
Rule for refreshing the contents-inventory window:
if currently-examined-item is nothing:
try taking inventory;
else:
say "[description of currently-examined-item][line break]";
refresh the title-inventory window;
now currently-examined-item is nothing;
Then I added some Before examining code (changed from “After” in your original example).
Before examining something:
now currently-examined-item is the noun;
stop the action;
I added “stop the action” to prevent the description from also printing in the main window.
Thanks for this suggestion.
I’m familiar with “noun” and “second noun” but never considered using them that way (only used them before in says).
Is the a way to grab the most recently typed “verb” (north, look, examine, etc.) so it can be also used in a conditional?
@otistdog - I wanted to give you some feedback on your proposed solution (and thank you for taking the time to suggest it).
I modified my contents-inventory refresh rules as follows.
Rule for refreshing the contents-inventory window while examining something:
do nothing.
Rule for refreshing the contents-inventory window:
try taking inventory.
And replaced the standard examining rule with my new examining rule.
Carry out examining (this is the new examining rule):
if the noun provides the property description and the description of the noun is not "":
focus contents-inventory window;
say "[description of the noun][line break]";
focus main window;
now examine text printed is true.
The new examining rule is listed instead of the standard examining rule in the carry out examining rulebook.
Unfortunately, the result is the same as @Draconis suggestion with some minor differences. When the inventory list is displayed and >examine is typed, the object description appears briefly underneath the inventory list before the whole window is cleared. Subsequent >examines display the object description briefly before clearing the window.
I think this side effect with your and @Draconis suggestions might have to do with how the Flexible Windows extension refreshes an individual window (I haven’t looked at the code in a while but there might be a clear window statement in there).
But thank you again for your suggestion. I had forgotten that it was possible to make rules more specific by adding criteria.
Thanks for letting me know the results. Sorry it didn’t work. In the future, if you provide a working example of the problem in code, it would allow for at least cursory testing of proposed answers.
A slightly simpler solution with fewer lines of code.
Rule for refreshing the title-inventory window:
if the action name part of the current action is examining action:
say "[noun part of the current action]" in title case;
else:
say "You Are Carrying";
Rule for refreshing the contents-inventory window:
if the action name part of the current action is examining action:
say "[description of the noun part of the current action][line break]";
refresh the title-inventory window;
else:
try taking inventory;
Nothing wrong with that, but you can shorthand it if you want:
if the current action is examining something (called N):
say "[description of N][line break]";
By the way, in my original example I had a separate global variable currently-examined-item because I wasn’t sure if the current action was still current, as it were, during the every-turn phase. But in fact it is.