Inform 6: Having a seperate "you can see" line for a class

So, basically, my game’s got a bunch of generic monster classes. How do I set it up so that they all have their own line of “you can see” descriptions? For example:

I’m reasonably sure this can be done, right?

Read up in Chapter 17, “Activities”, especially 17.14. Grouping together something and/or 17.23. Listing nondescript items of something. I think fiddling with one or both of those is the answer.

Of the DM4? Because I couldn’t find anything about that in section 17 and the rest of the document only seems to touch on the normal uses of describe, initial, invent, etc.

Ron misread and thought you were using Inform 7, so he was referring to that manual.

Just off the top of my head, maybe you could have a floating object with a describe routine that takes care of this. Then you could give all the monsters the concealed attribute.

Doh, sorry. I did miss the “6”.

Is there a way to make a floating object where the “found_in” property returns as “wherever the player is”?

The point of a floating object is it’s either where the player is, or it’s gone. So you’re just asking for a floating object that’s found everywhere. This is easy:

found_in [; rtrue; ]

Oh cool, I didn’t know you could do that. Thanks, zarf! All I need to know now is if there a way to list (using WriteListFrom, I s’pose) only objects of a certain class or with a certain attribute (like “hostile”). I assume it’s something involving workflags and whatnot, but so far I haven’t gotten that to work for me at all. I want to avoid having the “bunch of monsters” object actually contain the monsters, since obviously that would mean that they follow the player around and whale on him/her nonstop like a bunch of angry ghosts. But I can’t seem to actually get the object to say “here’s a buncha monsters, and they consist of…” and not say it while there are none around.

Roughly, it has to run through the domain of possible objects (presumably objects in the room) twice. The first time, you set or clear workflag, and keep a running count of objects for which workflag is set. If the count winds up being zero, print nothing. If it is nonzero, call WriteListFrom with the WORKFLAG_BIT flag.

This then brings up the problem of having a separate paragraph for an object which sometimes prints nothing. You can’t use the “initial” property for this, because “initial” always prints a newline. You have to use “describe”. An object’s describe property can be invisible by printing nothing (and return true). If it does print something, however, it must end with a newline.

Well, here’s what I came up with:

Object monsters_monitor with describe [ npc; objectloop (npc in location) { if (npc hasnt hostile) give npc ~workflag; else give npc workflag; } objectloop (npc in location) { if (npc hasnt workflag) { print ""; return; } else { print "^There is a group of monsters consisting of "; WriteListFrom(child(location), ENGLISH_BIT + RECURSE_BIT + WORKFLAG_BIT); } } ], found_in [; return true; ], has ;

I’m still a little confused as to how objectloop and workflags really work, though, so when I compile, it just seems to cheerfully ignore all that and continue to print “You can see two kobolds (a level 1 kobold and a level 2 kobold) and a cart here”. Am I on the right track, or no?

I think you’re trying to write this:

    describe [ npc count;
     objectloop (npc in location) {
       if (npc hasnt hostile) {
         give npc ~workflag;
       }
       else {
         give npc workflag;
         count++;
       }
     }
     if	(count > 0) {
       print "^There is a group of monsters consisting of ";
       WriteListFrom(child(location), ENGLISH_BIT + RECURSE_BIT + WORKFLAG_BIT);
     }
     rtrue;
   ],

However, this doesn’t disable the normal printing of object descriptions. For that, you’ll have to do something else. Making all the monsters scenery would work. Or give them a describe property that prints nothing (returning true) if they’re hostile.

Ah, that works perfectly! I hadn’t thought of having a second variable there. Dude, thank you so much for the help, and for being available at this ungodly hour (assuming you’re on the east coast). At this rate it feels like half my code is actually yours…