Collections extension

So here’s the new Collections extension:

I’m quite happy with how it’s turned out. Collection values can be of any sayable kind (which is almost everything), and so can map keys. (Except for arrays and maps. Well sort of. I think they can be keys, but they can’t be matched, only iterated.) It seamlessly handles keys being either the value directly, or wrapped in a collection reference.

I’d still like to try to get a reliable way of printing a kind, and then use that in type mismatches.


If I understand correctly what you’re looking for, I think this serves to gather the info…

Lab is a room.
Include JSON by Dannii Willis.

Include (-
[ kovtest i;
PrintKindValuePair(i, MAX_POSITIVE_NUMBER);

To say max positive number: (- print MAX_POSITIVE_NUMBER; -)

To say kov test (n - a number): (- kovtest({n}); -)

when play begins:
  let t be "";
  let maxpos be the substituted form of "[max positive number]";
  repeat with i running from 43 to 1000 begin;
    now t is "[kov test i]";
    if t exactly matches the text maxpos, break;
    if t matches the regular expression "^\<illegal (.+)\>$" begin;
      say "[i] [text matching subexpression 1][line break]";
    end if;
  end repeat;


43 scene
44 figure name
45 sound name
46 external file
47 natural language
48 command parser error
49 grammatical tense
50 narrative viewpoint
51 grammatical case
52 grammatical gender
53 json type
1 Like

So I think it might be possible to make it so you don’t have to manually clean up and destroy collection references, but it would be 1) very complicated, 2) involve replacing an entire I6T template (though it should be okay to replace it in the .Materials/I6T/ folder, rather than Internal/I6T/.) I might investigate this option later.

Thanks, I used something similar to get name of kinds, but in I6.

I’ve pushed an update to Collections which will return something sensible for the kind of (ref) for each kind. If you have a custom numerical kind, like a weight, it will just say “0kg”, because the name of the kind isn’t stored anywhere in the I6 code, so we can’t access it.

I think I should add forms of a lot of the list phrases, as it’s not actually very ergonomic to just access the internal list, as you have to manually create collection references, and destroy them before removing entries from the list.

1 Like