Multiple of the same object

i’m trying to write a game that can be compiled with inform 6 and punyinform, but i’ve run into my first snag! how should i go about making multiple of the same object, such as in this example from the dm4?

Class Pebble(50)
 with name 'smooth' 'pebble' 'stone' 'pebbles//p' 'stones//p',
      short_name "smooth pebble from the beach",
      plural "smooth pebbles from the beach";

inform 6:

>take pebble
Taken.

>take pebble
(the pebble)
Taken.

>i
You're carrying:
  two smooth pebbles from the beach

>drop pebble
(the smooth pebble from the beach)
Dropped.

punyinform:

> take pebble
Taken.

> take pebble
Taken.

> i     
You're carrying a smooth pebble from the beach and a smooth pebble from the
beach.

> drop pebble
Do you mean the smooth pebble from the beach or the smooth pebble from the beach?

http://www.inform-fiction.org/manual/html/s3.html#s3_11

I don’t think this would be possible with PunyInform; the manual says: “PunyInform can handle a collection of objects as long as they can be described with full names, but it does not offer support for indistinguishable objects.”

ah, i missed that! i suppose that leaves looking into making a counter as described here:

2 Likes

for posterity, here is my attempt in punyinform. you have to drop all of the pebbles at once, but that works for me!

newton.inf
!% -~S
!% $OMIT_UNUSED_ROUTINES=1

Constant Story      "ISAAC NEWTON'S BEACH";
Constant Headline   "^An Interactive Metaphor^";

Constant STATUSLINE_SCORE; Statusline score;
Constant NO_SCORE = 0;

Constant OPTIONAL_NO_DARKNESS;

Constant INITIAL_LOCATION_VALUE = Shingle;

Include "globals.h";

Global pebbles = 0;

Include "puny.h";

Object Pebble "pebble"
    with
        name 'smooth' 'pebble' 'beach' 'pebbles//p',
        article [;
            if (pebbles == 1) {
                print "a"; rtrue;
            }
            if (pebbles == 2) {
                print "two"; rtrue;
            }
            if (pebbles == 3) {
                print "three"; rtrue;
            }
            if (pebbles == 4) {
                print "four"; rtrue;
            }
            if (pebbles == 5) {
                print "five"; rtrue;
            }
            else
                print "some"; rtrue;
        ],
        short_name [;
            if (pebbles >= 2) {
                print "smooth pebbles";
            }
            else
                print "smooth pebble";

            print " from the beach"; rtrue;
        ],
    has;

Object Shingle "Shingle"
    with
        description
            "You seem to be only a boy playing on a sea-shore, and
             diverting yourself in finding a smoother pebble or a
             prettier shell than ordinary, whilst the great ocean of
             truth lies all undiscovered before you.",
    has;

Object -> "pebble"
    with
        name 'smoother' 'pebble' 'stone' 'stones',
        initial "The breakers drain ceaselessly through the shingle,
                 spilling momentary rock-pools.",
        before [;
            Take:
                if (pebbles == 6) {
                    "You look in vain for a stone smoother than
                     the six ever-smoother stones you have
                     gathered so far.";
                }
                else
                    pebbles++;
                    move Pebble to Shingle;
                    update_moved = true;
                    <<Take Pebble>>;
        ],
    has static;

[Initialise;
    print "^^^^^Welcome to...^^";
];
3 Likes

PunyInform tries to create the smallest possible compiled z-code file so that you can run it on retro platforms. As a consequence, some of the lesser-used features of the standard Inform 6 library have been omitted. Collections of indistinguishable objects is one of those features that got the chop.

However, that doesn’t mean you can’t do it in other ways. ‘Captain Cutter’s Treasure’ does something very similar to what you want. The design choices I made were as follows:

  • As there are a lot of pebbles (48 to be precise), you can’t get the pebbles unless you have a container to put them in.
  • When you initially get the pebbles, it’s all or nothing.
  • You can remove any number of pebbles from the container, but when you do, you throw them away. (This avoids the Hansel and Gretel problem and needing to have one object per pebble.)
  • When you drop the pebbles, you drop all of them.

Have a bit of a play with it and see what you think. You can find the container you need in the first room and the pebbles are on the path just south of the pub at the beginning of the game, so you don’t need to play very far into it.

3 Likes