Hi all,
I've been stumped by an Inform output/line break issue.
Picture a box of coins. You "take 3 coins". Inform wants to say "coin: Taken. coin: Taken. coin: Taken.", but I want Inform to say "three coins: Taken."
My approach (see below) is to modify the way the "multiple object list" is announced: when taking multiple coins, we'll count them and only announce the first coin, disguised to look like multiple coins.
What I have here *almost* works, but Inform doesn't line break correctly when giving the output and I can't figure out why, or how to fix it. Any help would be appreciated!
Thanks!
Jason
(P.S. The test command "Test Problem" trips over another issue, it seems to me. If you run that first, the two identical identical commands in the test behave differently. Not sure why. Are the "every turn" rules run at the start of the very first turn?)
- - - - - CODE - - - - -
Code:
"Tester"
Void is a room. The box is a container in the void.
A gold coin is a kind of thing. 10 gold coins are in the box.
Test Problem with "take 3 coins / take 3 coins".
Test One with "look / take 3 coins".
Test Two with "take all from box / drop coin / take all / drop all / take coins / put coins into box".
[The following is based on Example 400 in the Inform documentation.]
The fancy announce items from multiple object lists rule is listed instead of the announce items from multiple object lists rule in the action-processing rules.
The coin-count is a number that varies. Every turn: now the coin-count is 0.
Coins-have-been-counted is a truth state that varies. Every turn: now coins-have-been-counted is false.
First-coin is a truth state that varies. Every turn: now first-coin is true.
This is the fancy announce items from multiple object lists rule:
[First, count the number of coins in a multiple-object action. This number may be 0.]
if coins-have-been-counted is false:
repeat with temp running through the multiple object list:
if temp is a gold coin, increment the coin-count;
[Ensure that we only count the coins once per action.]
now coins-have-been-counted is true;
[We'll start with the taking action. We'll also need: dropping, inserting it into, removing it from, putting it on.]
if taking:
if the current item from the multiple object list is a gold coin:
if first-coin is true:
say "[The coin-count in words] gold coin[if coin-count is greater than 1]s[end if]: [run paragraph on]";
otherwise if the current item from the multiple object list is not nothing:
say "[current item from the multiple object list]: [run paragraph on]";
otherwise:
if the current item from the multiple object list is not nothing, say "[current item from the multiple object list]: [run paragraph on]".
After taking a gold coin:
if first-coin is true:
now first-coin is false;
say "Taken." instead. [***]
[If this After rule contains ONLY the *** line, then the word 'Taken.' appears multiple times -- which is not what we want -- but, the spacing is correct. Why would adding that conditional statement in the rule impact the line spacing of its output?]