Can Inform “Behaviours”/ kinds of actions be nested?

Mad Scientist responding…

The syntax of action patterns is interesting and often slightly obscure to me even after perusing the literate source.

Furthermore, the parsing of them has changed slightly between 9.3 and 10.1.2, such that some slightly ambiguous things that were incorrectly parsed or wouldn’t compile at all in 9.3 now work.

The full structure of an action pattern (excluding requested actions, for simplicity) is exemplified by the following:

a knighted person                                            [actor clause]
going inside                                                 [basic action pattern- can't include 'it' here: so 'putting' or 'putting on' rather than 'putting it on']
to the Cave                                                  [this and the next line represent a list of clauses aliased by action variables]
with a lit thing which is in a carried transparent container [with => along with a pushed item*]
in the Cave Entrance	                                     [location (of the actor) clause] 
in the presence of the page                                  [in the presence of clause]
when the dragon is in the Cave                               [when clause- this is the only clause allowed an 'and' or 'or']
for the first time                                           [no. of times clause**]
during sunrise:                                              [during a scene clause]
	say "The page looks at you quizzically in the early dawn light.".

[* the pushing it to action internally invokes a going action, with the pushed item temporarily carried by the actor during the going action before being set down again at the destination, at the end of the pushing it to action. As an illustration of the difficulties of parsing, we can’t write ‘held by the actor’ or ‘carried by the actor’ here because ‘held’ and ‘carried’ are adjectives defined in the Standard Rules and so this clause would be parsed as two separate aliased action variable clauses: ‘with a lit thing which is carried’ and ‘by the actor’ (meaning ‘travelling by the actor’ as in ‘travelling by vehicle’). Even with the above phrasing, 9.3.incorrectly parses this clause as implying that the ‘lit thing’ in its container is contained by the Cave Entrance, rather than that the actor’s location is the Cave Entrance. Ver 10.1.2 parses it correctly] (9.3’s interpretation can be forced in Ver 10.2.1 by bracketing the two clauses together- (a lit thing which is in a carried transparent container in the Cave Entrance) ).

[** this is the no of times the action has occurred with all preceding parameters being true, i.e. excluding the scenery one. So if the fully-described action occurs for the first time while sunrise is not happening, this rule will never fire. The easiest way of thinking about this is that the ‘no. of times’ clause is bracketed with the preceding clauses, so the rule fires if and only if (all this happens together for the first time) during sunrise.]

[A named action pattern is only allowed to have some of the clauses of a full action pattern.]
[NB named action patterns must be defined in source AFTER the actions they refer to]
[behaviour characterised by named action patterns can only specify the action not the actor: as a result, it cannot include requests to other people to do things (asking someone to try doing something), nor can the actor be specified or restricted]
[clauses aliased from action variables, a ‘location clause’ and/or an ‘in the presence of clause’ are permitted but not ‘when’ or ‘for x times’ or ‘during’ clauses. The last three may occasionally seem to compile, but only non-functionally due to misparsing. The exception is that when <description of objects> e.g. ‘when Bob’ or ‘when an undescribed man’ seems, surprisingly, to compile such that the pattern matches only when the actor is Bob or an undescribed man respectively. This last strange quirk may be unintended behaviour by the compiler (given the statement above- taken from the literate source of the compiler- that actors cannot be stated or restricted in named action patterns), so may be best not relied upon, especially in extensions]

So, for example:

going down                      [basic action pattern]
to the Root Cellar              [ this and the next 2 lines represent a list of clauses aliased by action variables]
through a door                         
with a lit thing 
in the Kitchen			        [location clause] 
in the presence of Scooby Doo   [in the presence of clause]
when Shaggy                     [actor clause (of doubtful reliability)]
is behaving dangerously.

small print there is currently a bug in the compiler whereby rooms referenced by action variable aliases in named action patterns, e.g. ‘to the Root Cellar’, must be previously explicitly declared in the source as rooms (Root Cellar is a room) not simply through mapping relations (Root Cellar is down from Kitchen)

more small print calls to create local rule variables in declarations of named action patterns- e.g. to the Root Cellar (called the destination)- will compile but don’t in fact create said local variables in rules where e.g. ‘behaving dangerously’ subsequently forms part of the preamble.

As noted previously, named action patterns used in action rule preambles can be prefaced only by ‘an actor’ (which matches any actor) or nothing (which matches only the player) as actor clauses.


Before behaving dangerously....


Before an actor behaving dangerously...

The latter offers an alternate and perhaps more reliable way to specify the actor(s) able to trigger a rule via a named action pattern, by inserting a when clause:

Before an actor behaving dangerously when the actor is Shaggy:

or, more elaborately:

an actor
behaving dangerously
in the Mystery Machine
in the presence of Velma
when (the actor is Shaggy or the actor is Daphne) and Scooby Doo is asleep
for the first time
during moonlight:

NB although the named action pattern (behaving dangerously) itself cannot represent a request for someone other than the player to do something, with the above in place typing a command successfully persuading Shaggy or Daphne to behave dangerously while at the same time all the other parameters of the Before rule preamble are met WILL trigger the rule.

NB2 if we want to intervene before persuasion has had a chance to take place, we can also write-

Before asking Shaggy to try acting dangerously...etc...