I would like to be able to use the fact whether or not an object has been examined in a conditional expression that I am creating. Something like this:
[Code Example 1]
Instead of examining the parchment:
if the player has the magnifying glass:
if the diary has been examined:
say "HAS MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "HAS MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.";
otherwise:
if the diary have been examined:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.".
When I try and compile Code Example 1 I get the following message:
I was trying to match this phrase:
if (the diary has been examined - a condition):
But I didn't recognize 'diary has been examined'.
Iâve read through quite a few sections of the documentation (including Writing §9.13. The past and perfect tenses) and did some searches here, but I havenât been able to figure out how to make the above code compile.
What I did end up doing was creating a truth value that I initially set to false.
examined-diary is a truth state that varies.
examined-diary is false.
And I set this boolean to true when the diary is examined.
now examined-diary is true.
And I modified Code Example 1 to read
[Code Example 2]
Instead of examining the parchment:
if the player has the magnifying glass:
if examined-diary is true:
say "HAS MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "HAS MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.";
otherwise:
if examined-diary is true:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.".
Itâs a bit of a kludge so I would still like to know if there is a way to use the examined nature of an object in a conditional expression.
That said, I personally think your solution is better, because Inform 7 isnât optimized to handle past tense very well, and can run slowly if you add too many past tense checks. A truth state accomplishes the same thing with a minimum of fuss.
Strange⌠when I test using âif we have examinedâ within an If block, it only does the otherwise part, no matter how many times you examine it.
Instead of examining the knife:
if we have examined the knife:
say "The knife has not changed since you last examined it!";
otherwise:
say "Upon closer inspection you confirm it is indeed a knife";
However it works if you put the code in the description of the object like in the night sky example.
The description of knife is "[if we have examined the knife]The knife has not changed since you last examined it![otherwise]Upon closer inspection you confirm it is indeed a knife.[end if]".
If thatâs the case, that it only works within the description part of the object definition, then in this case, it might not be the right approach, as the desired scenario is not only checking if this item has been examined but itâs also part of a larger if check comparing other things such as does the player have the magnifying glass.
Personally, as Chin Kee Yong suggests, I would stick with the original âkludgeâ approach myself.
If youâre checking multiple states (if holding Object2, and if Object1 has been examined, while I examine Object3)
[assuming parchment is not the diary]
then storing the status of these scenarios is vital imo.
Youâll have far more control over how itâs working, when itâs working and why.
The problem lies with your use of âInsteadâ in this case. Further down, the âNight Skyâ example notes:
On the other hand, beware that this would not work as desired:
[example repeated with an Instead rule]
The reason is that our Instead rule has pre-empted normal listening, so Inform considers that we have never successfully heard the message.
If an âInsteadâ rule intervenes, Inform typically considers the action to have failed. However, we can easily convince it of the opposite by adding rule succeeds to the end of the rule. Then it should work as intended.:
Instead of examining the knife:
if we have examined the knife:
say "The knife has not changed since you last examined it!";
otherwise:
say "Upon closer inspection you confirm it is indeed a knife";
rule succeeds.
Alternatively, you can split the definition into two rules:
Instead of examining the knife, say "Upon closer inspection ...".
Instead of examining the knife for more than the first time, say "The knife has not changed ...".
Thanks everyone. I now have two approaches that will work.
Approach 1 is setting a truth value, i.e. boolean, when the diary has been examined and using that boolean in my conditional statement.
Instead of examining the diary:
if the player does not have the glasses:
say "Can't read.";
if the player has the glasses:
say "Very interesting.";
now examined-diary is true.
...
Instead of examining the parchment:
if the player has the magnifying glass:
if examined-diary is true:
say "HAS MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "HAS MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.";
otherwise:
if examined-diary is true:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.".
Approach 2 is using the actual âexamined-nessâ state of the diary in the conditional.
Instead of examining the diary:
if the player does not have the glasses:
say "Can't read.";
if the player has the glasses:
say "Very interesting.";
rule succeeds.
...
Instead of examining the parchment:
if the player has the magnifying glass:
if the diary has been examined:
say "HAS MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "HAS MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.";
otherwise:
if the diary have been examined:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS EXAMINED DIARY.";
otherwise:
say "DOES NOT HAVE MAGNIFYING GLASS; HAS NOT EXAMINED DIARY.".
Both work in isolation.
Iâm going to continue using the examined-diary boolean for now but I also added the ârules succeedsâ to the end of my diary Instead in case I want to use the diaryâs âexamined-nessâ somewhere else (I had forgotten or didnât realize that Instead short-circuits the actions it interrupts).
Instead of examining the diary:
if the player does not have the glasses:
say "Can't read.";
if the player has the glasses:
say "Very interesting.";
now examined-diary is true;
rule succeeds.
It seems worth pointing out that the light-weight extension called âEpistemologyâ by Eric Eve (built-in in Inform 6M62) creates a âfamiliarâ property that is set for any object that has been examined by the player. (But note that it wonât work in conjunction with the instead rule approach that youâre using, as things become marked as familiar by a carry out examining rule.) Using it will prevent the need for multiple special-case variables.
Also, note that the âwe have examinedâ syntax does not store information about who the actor was, so if you have NPCs that are executing examine actions, that condition can become true unexpectedly.
This is maybe a nitpicky kind of correction, but the name of the property in Epistemology that tracks whether something is seen is seen; familiar is a different property thatâs intended to track whether the PC is aware of something (and is useful for things that the PC hasnât seen yet, but knows about, or unseeable things, like abstract conversation topics).
I just got bit by that distinction a few days ago and spent a merry half-hour tracking down the bug that arose.
A thing can be familiar or unfamiliar. A thing is usually unfamiliar.
Carry out examining something visible (this is the mark items as seen on examining rule):
now the noun is familiar;
now the noun is seen.
Definition: a thing is known if it is familiar or it is seen.
when I reviewed it, but I had missed that everything visible to the player when looking is marked as familiar, too:
Carry out looking (this is the mark items as seen when looking rule):
unless in darkness:
now every backdrop in the location is seen;
repeat with item running through things that are enclosed by the location:
if the item is not enclosed by an opaque closed container:
now the item is familiar;
now the item is seen.
So @billmaya ⌠forget what I said before â it wonât work. You may want to use the extension as a model for something that actually does what you want, however.
For example:
A thing can be inspected.
Carry out examining:
now the noun is inspected.
if the diary is inspected...
But â again â this approach requires that instead rules not be used to print out the results of examining. (Even if the action is forced to succeed from an instead rule, the carry out rules wonât be processed.)