I’ve created a solution system using the multiple action processing rules, a table and a temporary list.
I haven’t tested this super-hard, but I’ve tested it a bit and it seems decent. I tested getting all and dropping all with both a mix of multi-items and unique items at the same time, and getting all from a container.
With this code in place, whenever you take, drop, remove it from, or remove, multiples of things, any that have the same printed plural name will be grouped together.
Here’s the code (written in 10.2):
Summary
MULTI-ACTION-LIST is a list of objects that varies.
Table of multi-item trackings
entity(a thing) plural-name(text) amount(number)
-- -- --
with 99 blank rows.
MULTI-ACTED is initially false.
First multiple action processing rule:
now MULTI-ACTED is false;
now the MULTI-ACTION-LIST is the multiple object list;
To deal with (ITEM - a thing) during multiple action processing:
if taking or removing or removing from:
now player carries ITEM;
now ITEM is handled;
otherwise if dropping:
now ITEM is in location;
A multiple action processing rule:
let DELETION-LIST be a list of things;
let DETECTED-MULTIPLES be false;
let LINES-WITH-MULTIPLES be 0;
blank out the whole of the table of multi-item trackings;
;
[say "MULTI-ACTION-LIST going in: [MULTI-ACTION-LIST].";]
repeat with ITEM running through MULTI-ACTION-LIST:
let PLURAL be "[printed plural name of ITEM]";
if PLURAL is a plural-name listed in the Table of multi-item trackings:
now MULTI-ACTED is true;
if amount entry is 1:
increment LINES-WITH-MULTIPLES;
increment amount entry;
if entity entry is not listed in DELETION-LIST:
add entity entry to DELETION-LIST;
[say "ADDED ORIGINAL ITEM TO LIST.";]
deal with entity entry during multiple action processing;
add ITEM to DELETION-LIST;
[say "ADDED DUPE ITEM TO LIST.";]
deal with ITEM during multiple action processing;
now DETECTED-MULTIPLES is true;
otherwise:[make a new entry]
choose a blank row in the Table of multi-item trackings;
now entity entry is ITEM;
now plural-name entry is PLURAL;
now amount entry is 1;
[say "ITEM NOTED.";]
if DETECTED-MULTIPLES is true:
repeat through the table of multi-item trackings:
if amount entry > 1:
let TITLE-CASED be "[amount entry in words]";
now TITLE-CASED is TITLE-CASED in title case;
say "[TITLE-CASED] [plural-name entry]: ";
if taking or removing or removing from:
say "Taken. ";
otherwise if dropping:
say "Dropped. ";
decrement LINES-WITH-MULTIPLES;
if LINES-WITH-MULTIPLES > 0:
say line break;
repeat with Z running through DELETION-LIST:
remove Z from the MULTI-ACTION-LIST;
if number of entries in MULTI-ACTION-LIST is 0:
say line break;
[say "Removed [Z] from list.";]
Last multiple action processing rule:
alter the multiple object list to the MULTI-ACTION-LIST;
if MULTI-ACTED is false and the multiple object list is empty:
if taking or removing or removing from:
say "There's nothing I can take.";
otherwise if dropping:
say "I have nothing.";
otherwise if MULTI-ACTED is true and number of entries in multiple object list is 1:
say "[entry 1 of MULTI-ACTION-LIST]: [run paragraph on]";
It scans everything that’s about to be acted on, makes item counts in a temporary table, manually deals with the getting or dropping of items which share the same plural name - taking the opportunity to print their names in a group fashion while at it - removes those items from the master list of things to be acted on, then lets Inform act on the rest as usual.
One thing to note is that the Table of multi-item trackings should have at least as many blank rows as the number of uniquely-named items the player could ever hold at once! I’ve started it with 100.
EDITS - I just realised my code was missing a line defining the MULTI-ACTION-LIST. Now fixed.
Bigger problem - it doesn’t respect a lot of rules that would block taking or dropping (or presumably, the other actions too) certain things. I noticed it wouldn’t even try to take a fixed in place thing (good) but it would happily drop things that had ‘Instead of dropping’ rules on them.
EDIT EDIT - I made my own version better, but I realise now the brick wall on this approach is it just can’t be made to respect all rules applying to an item unless the items are acted on and checked one at a time, the way the multiple object processing rules normally handles them. The closest I got was checking if one could be acted on, and if it could, acting on the whole group. But what if taking arrow 3 trips an inventory or space limit, or there’s suddenly no more stock? I couldn’t intercept that stuff with my approach, so I’m downing tools.
-Wade