Narrative Mode for Multiple Actions by Martin Oehm begins here. "Tries to report actions on multiple objects in a more natural, 'narrative' style instead of prefixing the result for each object with the objet's name." Include Default Messages by Ron Newcomb. Section - The list of deferred reports A thing can be marked for deferred reporting. A thing is usually not marked for deferred reporting. The deferred report is a text that varies. After reading a command (this is the deferred reporting initalisation rule): now every thing is not marked for deferred reporting. The announce items from multiple object lists rule is not listed in any rulebook. To flush the deferred report: If there are things that are marked for deferred reporting, say "[the deferred report][line break]"; now every thing is not marked for deferred reporting. To flush the deferred report with line break: If there are things that are marked for deferred reporting, say "[the deferred report][line break][line break]"; now every thing is not marked for deferred reporting. Section - Verbs for list-printing To print the verb (sing - a text) or (plur - a text) for (L - a list of objects): If the number of entries in L is greater than one: say plur; otherwise if entry 1 in L is plural-named: say plur; otherwise: say sing. To say deferred is-are: print the verb "is" or "are" for the list of things that are marked for deferred reporting: Section - Deferred reporting for the standard library actions Report taking something (this is the defer successful acquisition of multi-objects rule): now the noun is marked for deferred reporting; now the deferred report is the library message taking action number 51; stop the action. Check taking something when the number of things carried by the player is not less than the carrying capacity of the player (this is the handle carrying capacity insufficience for multi-objects rule): if there are things that are marked for deferred reporting: flush the deferred report with line break; issue library message taking action number 52; otherwise: issue library message taking action number 53; cut the multiple action short; stop the action. Report removing something from (this is the defer successful removal of multi-objects rule): now the noun is marked for deferred reporting; now the deferred report is the library message removing it from action number 51; stop the action. Report dropping something (this is the defer successful disposal of multi-objects rule): now the noun is marked for deferred reporting; now the deferred report is the library message dropping action number 51; stop the action. Report inserting something into a container (this is the defer successful inserting of multi-objects rule): now the noun is marked for deferred reporting; now the deferred report is the library message inserting it into action number 51; stop the action. Check inserting something into a container when the number of things in the second noun is not less than the carrying capacity of the second noun (this is the handle container capacity insufficience for multi-objects rule): if there are things that are marked for deferred reporting: flush the deferred report with line break; issue library message inserting it into action number 52; otherwise: issue library message inserting it into action number 53; cut the multiple action short; stop the action. Check inserting something into a closed container (this is the handle insertion inablity due to lack of container openness for multi-objects rule): cut the multiple action short; issue library message inserting it into action number 54; stop the action. Report putting something on a supporter (this is the defer successful superposition of multi-objects rule): now the noun is marked for deferred reporting; now the deferred report is the library message putting it on action number 51; stop the action. Check putting something on a supporter when the number of things on the second noun is not less than the carrying capacity of the second noun (this is the handle supporter capacity insufficience for multi-objects rule): if there are things that are marked for deferred reporting: flush the deferred report with line break; issue library message putting it on action number 52; otherwise: issue library message putting it on action number 52; cut the multiple action short; stop the action. Every turn when there is a marked for deferred reporting thing (this is the deferred announcement of successful transactions for multi-objects rule), flush the deferred report. The deferred message action is an action name that varies. The deferred message number is a number that varies. To say the deferred library message: Issue library message deferred message action number deferred message number. To decide what text is the library message (A - an action name) number (N - a number): now the deferred message action is A; now the deferred message number is N; decide on "[the deferred library message]" Section - The I6 loop for multiple actions Include (- Global multiple_action_cut_short = false; Global multiple_action_underway = false; [ GenerateMultipleActions initial_location k item; initial_location = location; multiple_action_cut_short = false; multiple_action_underway = true; for (k=1: k<=multiple_object-->0: k++) { item = multiple_object-->k; !RunParagraphOn(); if (inp1 == 0) { inp1 = item; BeginAction(action, item, second, item); inp1 = 0; } else { inp2 = item; BeginAction(action, noun, item, item); inp2 = 5; } if (multiple_action_cut_short) break; if (deadflag) break; if (location ~= initial_location) { L__M(##Miscellany, 51); break; } } multiple_action_underway = false; ]; -) instead of "Generate Multiple Actions" in "OrderOfPlay.i6t". Section - Premature end to multiple actions The multiple actions short circuit is a truth state that varies. The multiple actions short circuit variable translates into I6 as "multiple_action_cut_short". Multiple action processing is a truth state that varies. Multiple action processing variable translates into I6 as "multiple_action_underway". To cut the multiple action short: flush the deferred report with line break; now the multiple actions short circuit is true. Section - Library messages To say is-or-are (N - an object): if N is plural-named: say "are"; else: say "is". Table of custom library messages (continued) library-action library-message-id library-message-text taking action 51 "You have now got [the list of things that are marked for deferred reporting].[ignore library line break]" taking action 52 "You can't take [the noun], because you're carrying too many things already" taking action 53 "You're carrying too many things already" removing it from action 51 "You have now got [the list of things that are marked for deferred reporting].[ignore library line break]" dropping action 51 "You have dropped [the list of things that are marked for deferred reporting].[ignore library line break]" inserting it into action 51 "[The list of things that are marked for deferred reporting] [deferred is-are] now in [the second noun].[ignore library line break]" inserting it into action 52 "You can't put [the noun] into [the second noun], because there's no more room." inserting it into action 53 "There's no more room in [the second noun]." inserting it into action 54 "[The second noun] [is-or-are second noun] closed." putting it on action 51 "[The list of things that are marked for deferred reporting] [deferred is-are] now on [the second noun].[ignore library line break]" putting it on action 52 "You can't put [the noun] onto [the second noun], because there's no more room." putting it on action 53 "There's no more room on [the second noun]." Narrative Mode for Multiple Actions ends here. ---- DOCUMENTATION ---- This extension tries to make the messages for dealing with multiple objects a bit more "narrative". Inform 7 makes it easy to write "In the cupboard are six cups" in the source, code, but the story's output looks somewhat mechanic: > take four cups Cup: Taken. Cup: Taken. Cup: Taken. Cup: Taken. This extensions changes this to: > take four cups You have now got the four cups. This is easier to read and hides the fact, that each cup is a separate object. The extension works for any list of objects. (The name "narrative" is taken from Anson Turner's Platypus lib, which tries something similar with its experimental narrative mode.) The auther would like to thank Christian Blümke for his useful advice on how to turn loose chunks of code into a proper extension. Section: Pitfalls This extension should work for normal story that don't rely too heavily on inventory management. The default report is deferred to the end of the turn and the order in which things are picked up or laid down usually does not matter. Sometimes, however, there might be interactions bewteen the objects and the story's messages may be misleading if the story makes use of knowledge that this extension has deferred. (If this sound confusing, look at the serpent in Example B.) We can write the list of silently taken things with: flush the deferred report. We can also check whether an object has been sucessfully treated earlier in the same turn: After taking the nail if the player is carrying the magnet: if the magnet is marked for deferred reporting, flush the deferred report; say "Clang! As you pick up the rusty nail, the magnet you're carrying attracts it." Authors should try to handle such cases explicitly. Section: Cutting actions on multiple objects short The objects are dealt with in order, rigorously. Even if there is a fundamental problem in the player's request, such as a close container or not enough room, the parser stubbornly tries to fulfill it. It would be nice to cut the action short in such cases. This extension does this automatically for the known cases of the standard library verbs, but we can stop the action ourselves with "cut the multiple action short": Instead of taking something in the Forbidden City when the number of things carried by the player two: if there are things that are marked for deferred reporting: flush the deferred report with line break; say "You can't take [the noun]: Strangers are not allowed to carry more than two things in the Forbidden City."; otherwise: say "Strangers are not allowed to carry more than two things in the Forbidden City."; cut the multiple action short; stop the action. The conditional "if there are things that are marked for deferred reporting" checks, whether other things have already been picked up in the same turn. In that case, taking these objects, which may be in the deferred report, is reported before the denial to pick up a third object is printed. If we don't want to print different messages when objects have already been taken or not it is enough to cut the action short, which also flushes the list: Instead of taking something in the Forbidden City when the number of things carried by the player two: cut the multiple action short; say "Fremde dürfen in der Verbotenen Stadt nur zwei Dinge tragen."; stop the action. Section: New actions with multiple actions This extension treats all actions in the standard library that allow multiple objects, i.e. that understand a variant of the [things] token. These are the taking and dropping actions and their container and supporter cousins. We can write our own actions for multiple objects with deferred reporting. The reporting rule should then be something like: Report admiring something: now the noun is marked for deferred reporting; now the deferred report is "You admire [the list of things that are marked for deferred reporting]."; stop the action. The deferred report ist the sentence that is written after the individual messages for that action at the end of the turn. Section: Check whether multiple objects are dealt with Narrative actions on multiple objects should be explicit, because there's no context beside the message itself. We won't get away with a terse "Taken". If we want to print such messages, we should check whether the story processes a single object or multiple objects. The truth state multiple action processing tells us so. (It is true if "take all" correspons to only one object, though.) See the serpent in Example B for a possible use. Example: * Glamorgan - Lots of stuff to pick up Pick up the many objects and try to put them into the rucksack or on the table. There's also an action to examone multiple things. Non-descript things have an empty description. *:"Glamorgan" Include Narrative Mode for Multiple Actions by Martin Oehm. Section - The sword in the stone and lots of other stuff Meadow is a room. The description is "You're on a peaceful meadow - consideringb that the Battle of Glamorgan rages in the east." Instead of going east in Meadow, say "You've just escaped from there." An arrow is a kind of thing. Here are six arrows. A long bow is here. A shield is here. "A shield is lying in the grass." The strange symbol is a thing. It is fixed in place. "A strange symbol has been cut into the grass here." The description is "The symbol is the rose of Lancaster. Or ist it the rose of York?" After taking the shield for the first time: say "As you pick up the shield, you notice a strange symbol that has been cut in the grass beneath it."; now the strange symbol is in the meadow. A sword in the stone is here. "A sword sticks in a stone." The description is "An ornate sword sticks in a stone." Understand "ornate" as sword. Instead of taking the sword, say "The sword is stuck formly in the stone. You can't get it out." The rucksack is a wearable container carried by the player. Instead of dropping the rucksack, say "You hold on to the rucksack. It's far too useful." The oak table is a supporter in the meadow. "There's a massive oak table here" Every turn when a random chance of 1 in 2 succeeds, say "[one of]The clamour of battle can be heard to the east.[or]A dissonant bugle calls from the battlefield.[or]An eerie gust of wind blows over the meadow.[at random]" The carrying capacity of the rucksack is 5. The carrying capacity of the oak table is 6. Section - Multiexamine Understand "examine [things]" as examining. Understand "x [things]" as examining. Understand "look at [things]" as examining. Understand "inspect [things]" as examining. Instead of examining something when the description of the noun is empty text: now the noun is marked for deferred reporting; now the deferred report is "You see nothing special about [the list of things that are marked for deferred reporting]."; stop the action. Rule for deciding whether all includes rooms: it does not. Test me with "take all / put everything on the table / put all in the rucksack / get all / drop arrow / drop shield / x everything". Example: ** Serpent's Hold - avoid that a puzzle is solved without noticing Old-school puzzle time: The snake will only let the player take the key if she carries the garlic. Luckily the garlic sits right beside tha key. This puzzle is solved easily by taking all. In the initial setup, the garlic will be taken before the key when the player wants to take everything. The key can only picked up when the player carries the garlic. If the garlic has already been picked up in this turn, the player does not yet know that she has it, rendering the message about the garlic repelling the snake inconsistent. That's why we must flush the deferred report. Another solution would have been to provide an rule after taking the garlic to print a separate paragraph and prevent putting the garlic on the deferred report. (It is obvious that this example is rather contrived even for an old-school puzzle.) *:"Serpent's Hold" Include Narrative Mode for Multiple Actions by Martin Oehm. Dracula's vault is a room. "This is where Count Vlad stashes his riches." A chest is in the vault. The chest is closed, openable, lockable, locked and fixed in place. "A chest sits in the corner." Understand "treasure chest" as chest. A clove of garlic is in the vault. A dollar is a kind of thing. Understand "coin" as dollar. Understand "coins" or "money" as dollars. In the chest are 17 dollars. A golden key is here. The golden key unlocks the chest. An adder is here. "An adder coils Natter ringelt sich auf dem Boden." Understand "snake", "serpent" as adder. Instead of taking the adder when Multiple action processing is true, say "You can't possibly pick up an adder." Instead of taking the adder: say "I'd rather not." Instead of taking the key in the presence of the adder when the player is not carrying the garlic: say "The adder hisses angrily as you reach for the key. You desist." After taking the key in the presence of the adder when the key is in the vault: if the garlic is marked for deferred reporting, flush the deferred report with line break; say "The garlic repels the adder. You quickly snatch the key." Table of custom library messages (continued) library-action library-message-id library-message-text taking action 51 "You're now arrying the following: [the list of things that are marked for deferred reporting].[ignore library line break]" taking action 53 "Oh dear, looks like you're carrying too much already!" Test me with "get key / get all/ put all in chest / unlock chest with key / open chest / put all in chest / pick up adder / get all" Example: **** Sand Revisited - A concise version of "Sand" This exercise reworks the library example "Sand", which implements implicitly taking things before putting them elsewhere. This implcit taking is implemented is hand-coded. The player is Cinderella who should sort lentils and peas. Standard output leads to reams of "Lentil: Taken.", each accompanied by its own "(First taking the lentil.)" Because the [things] token cannot understand the context, the action is also generated for items that are already at the destination. This is commented with "Already done" for each lentil or pea. A lot of text that essentially doesn't say anything. The reworked version defers reporting. In addition, all items thatv are already at their destination are marked. Onlöy if no items were successfully moved, i.e. if there are no items marked for deferred reporting, the message, that so-and-so much lentils are already in the tin is written. The "(First taking...)" is suppressed entirely. *:"Sand II" Include Narrative Mode for Multiple Actions by Martin Oehm. Use no scoring. Section - Implicit multi-getting The implicit multi-getting phrase is a text that varies. A thing can be implicitly-multi-taken. A thing can be conforming to placement. A thing can be implicitly unacquirable. Every turn when there are things that are conforming to placement and there are things that are marked for deferred reporting, flush the placement list. Every turn when there are things that are conforming to placement, flush the placement list. To say placement is-are: print the verb "is" or "are" for the list of things that are conforming to placement: To flush the placement list: if there are no things that are marked for deferred reporting: say "[The list of things that are conforming to placement] [placement is-are] already in [the second noun]."; now every thing is not conforming to placement. Before inserting something which is not carried by the player into something: if the noun is in the second noun: now the noun is conforming to placement; stop the action; silently try taking the noun; if the player is not holding the noun: now the noun is implicitly unacquirable; stop the action. Before putting something which is not carried by the player on something: if the noun is on the second noun, say "Already done." instead; say "(First taking [the noun].)[line break]"; silently try taking the noun; if the player is not holding the noun, stop the action. Section - The story proper Understand "put [things] in [something]" as inserting it into. Understand "put [things] on [something]" as putting it on. The Closet is a room. A lentil is a kind of thing. A black-eyed pea is a kind of thing. The closet contains 3 lentils. The Closet contains 14 black-eyed peas. The round tin is a container in the closet. The round tin contains 17 lentils. The square tin is a container in the Closet. The square tin contains 20 black-eyed peas. Sorting is a scene. Sorting begins when play begins. Sorting ends when all the lentils are in the round tin and all the black-eyed peas are in the square tin. When Sorting ends: flush the placement list; flush the deferred report with line break; say "Well, that wasn't all that bad now, was it?"; end the story finally. When play begins: say "Thanks to your cruel stepmother, you're not going anywhere until the lentils and peas are sorted." Test me with "put peas in square tin / put lentils in round tin".