[code]A note is a kind of thing. A note has text called printing. The printing of a note is usually “blank”. A note has a truth state called was_read that varies. was_read is usually false.
Understand the command “read” as something new. Understand “read [something]” as reading. Reading is an action applying to one thing.
if the noun is not a note, say “Nope, that’s not readable” instead.
Carry out reading:
clear the screen;
say “The note reads: [line break] [printing of the noun][line break]”;
now the noun was_read is true;
pause the game.
Problem. In the sentence ‘now the noun was_read is true’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘the noun was_read is true’.
Shouldn’t the noun still be considered “a note” when completing the carry out? I would have thought this should be fine. I don’t get why it doesn’t work.
Additionally, can I override this with additional requirements? I have “a note” as defined as something readable, if I want to put additional conditions on a note, can I have the check pick which “Carry out” to execute out of a lot of them based on the note’s importance? or do I need to custom make a note each time.
Specifically, I want one note in particular in the area to “spawn” an actor into the room, but I want other notes to just be readable by the player. Do I need to write two specific separate note type things here or can I use the basic “a note” and then have “spawner note is a spawner” and when “read spawner note” reads as per the check/carry but executes some extra stuff? Would putting a:
if the note is a spawner note, try silently spawn_person.
since was_read is supposed to be a property of a note, the syntax is not “the noun was_read” but “was_read of the noun.” Just as, if a person has a number called health, we’d be writing “health of the noun” rather than “noun health.”
But, the line “A note has a truth state called was_read that varies.” actually creates a property called “was_read that varies”! Properties always are variables rather than constants, so Inform thinks “that varies” is part of the name. (As a tip as to how to track this kind of error down, what I did was to comment out the Carry out reading rule in order to let the code compile. Then I went to the Index, went to Kinds to look at the note kind, and then saw the properties that notes can have, and was surprised to find out how it was interpreted).
In any case, it seems like it might be more natural to give the note a property with two named values:
A note can be read or unread. A note is usually unread.
and then you can write
now noun is read;
As for your second question, you can totally do that. If you want to have the spawning behavior override the usual reading behavior, write a rule like this:
Instead of reading a spawner note:
An “Instead” rule runs and then stops processing (unless you write “continue the action” inside the rule).
If you want to have all the usual reading behavior as well as the spawning, you can just do another Carry Out rule:
Carry out reading a spawner note:
This will run only for spawner notes, but won’t affect the rest of the rules for notes. One thing to note is that this will happen before the usual carry out reading behavior, since it’s more specific than the general “carry out reading,” which you might not want. Another way to do it is:
After reading a spawner note:
After rules by default run after the Carry Out rules–so not if the action gets stopped by a Check or Instead or Before–and stop processing of the action without an explicit “continue the action,” which means they would preempt any Report rules (which you don’t have).
The chapters of Writing with Inform about Basic Actions and Advanced Actions have lots of helpful stuff about these different kinds of rules.
Great, that worked, thanks. I tried “was_read” because i was concerned that an understand “read” and a read value may cause issues with the compiler.
So by saying “read and unread” have i created a boolean here or is it just a text value expecting those two words/values? Or is it more akin to an enum where read and unread have been given a numerical value for the read value of note?
You’ve effectively created a private enum, and a property which is of that type. (IIRC the options are numbered straightforwardly from zero, like in C.) But Inform can also create special input and output routines for the enum if you’re so inclined, which is a convenience C doesn’t offer.