How do I model collections of objects (coins, for example) in PunyInform?

I’m following the example on page 212 of the Inform 6 manual. However, it looks like Puny lacks the ability to infer collections of objects.

Class GoldCoin
  with name 'gold' 'coin',
  short_name "gold coin",
  plural "gold coins";

Object -> CashRegister "cash register"
  with
      description "[ This is the cash register. TODO: There will be some money in here ]",
      name 'cash' 'register',
  has container openable static;

GoldCoin -> ->;
GoldCoin -> ->;
GoldCoin -> ->;

Here, the coins are listed individually:

> open cash register
You open the cash register, revealing a gold coin, a gold coin and a gold coin.

What’s the best way of ensuring they’re listed as ‘some gold coins’ when plural, and ‘a gold coin’ when there is only one? I imagine I need to iterate over the contents of the cash register and count the coins. How do I do that? Can I do that?

One of the biggest differences between the standard library and PunyInform is that PunyInform doesn’t handle several identical objects. You may want to have a look at a comparison between PunyInform and the standard library, like this one: PunyInform vs Inform 6: A Comparison .

There is a way to hack the library to do it however, in the howto-folder of the distribution. It’s not perfect, but may be sufficient if you need a few identical objects.

1 Like

Thanks. Realised I’d overthought the problem. Best solution for me is to model is as one ‘money’ object that changes ‘amount’.

2 Likes