JWZ's TADbits (#15: some Lite overlap)

Where is the “adv3Utils” repo? I don’t see it at diegesisandmimesis. You’ve clearly been doing some advanced work, so thanks for any pointers to this repo! (And my apologies if I simply failed to spot it at your GitHub space.)

1 Like

Well crap. I thought I’d made it public around the same time I made adv3Patches public (which I just doublechecked to make sure I actually had).

Should be visible now:

Summary (it doesn’t have full documentation, but there should be an information block at the top of the individual source files, and they should be fairly verbosely internally commented):

  • actionType Adds an actionType prop to Action, used elsewhere for grouping actions (in this case sense actions and travel actions get tagged)
  • _debugObject() A function that enumerates an object’s properties. Only enabled in debugging builds
  • Deadbolt and DoorPair, recently described above
  • findMaxValue() A function that tries to find the largest number of something (like objects in a room) that the VM can handle without throwing an exception
  • gTurn A macro returning the current turn
  • interruptImplicit A macro for interrupting implicit actions
  • iobjScope Logic implementing object scoping rules for indirect objects similar to the existing ones for direct object. Described fairly recently in this thread
  • messageTokens Logic for declaring arbitrary message parameter substitution tokens that are resolved by callback
  • OrdinalThing Mixin for Thing to add ordinal vocabulary (“first pebble”, “second pebble”, and so on)
  • Resource and ResourceFactory Classes for dispensing equivalent objects (harvestable plants and that kind of thing)
  • room Adds a couple methods on Room that test for room adjacency and list a room’s exits and destinations.
  • roomVocab Tweaks Room to make it easier to refer to rooms in commands
  • searchContents Adds methods to Thing: searchContents(fn) which returns the subset of contents that satisfies fn; contains(fn) that returns boolean true if any object in contents satisfies fn, and matchContents(fn) that returns the first object in contents that matches fn or nil if none
  • thingStateDesc, thingStateMulti, and thingStateRoom Extensions to ThingState that add, respectively, a stateDesc property, the ability to have multiple active states, and room-specific tweaks
  • titleCase() A function that returns a string formatted in title case.
  • vocab Tweaks to VocabObject to make it easier to add words and specifically convenience methods for adding weak tokens

If you have any questions or notice any bugs pragmatically the best way to ping me is here; reporting issues on git works but I’m not very diligent about checking (because the main consumers of my repos appear to be me and AI scrapers).

4 Likes

Many thanks for making the repo public and for all your brilliant contributions!

1 Like

Another fairly minor tweak, this time some code to allow toggling some kinds of object announcements on Thing.

First we declare a few flags. These correspond one-to-one with library messages that we want the ability to toggle. This mechanism could in theory be extended to other kinds of object announcement, but this tweak targets a specific set of them unified by identical calling semantics. Anyway, the flags should probably go in some header file, adv3Utils.h in the module:

#define ANNOUNCE_MULTI (1 << 0)
#define ANNOUNCE_AMBIG (1 << 1)
#define ANNOUNCE_DEFAULT (1 << 2)

Then we add a property on Thing that by default has all three of these flags set (so the default behavior will be the same as in stock adv3: always show all the object announcements):

modify Thing
        announcementFlag =
                ( ANNOUNCE_MULTI | ANNOUNCE_AMBIG | ANNOUNCE_DEFAULT )
;

Then finally we tweak the corresponding message methods on libMessages to check the new property:

modify libMessages
        announceMultiActionObject(obj, whichObj, action) {
                if(obj.announcementFlag & ANNOUNCE_MULTI)
                        return(inherited(obj, whichObj, action));
                else
                        return('');
        }

        announceAmbigActionObject(obj, whichObj, action) {
                if(obj.announcementFlag & ANNOUNCE_AMBIG)
                        return(inherited(obj, whichObj, action));
                else
                        return('');
        }

        announceDefaultObject(obj, whichObj, action, resolvedAllObjects) {
                if(obj.announcementFlag & ANNOUNCE_DEFAULT)
                        return(inherited(obj, whichObj, action,
                                resolvedAllObjects));
                else
                        return('');
        }
;

This means that each of the announcement methods fall through via inherited() if the flag is set, and an empty string is returned if it isn’t (effectively suppressing the announcement).

The specific use case I have for this is some furniture-related code that provides an instanceable TableWithChairs class and additional actions such that >SIT AT TABLE is understood to mean the player wants to sit on one of the chairs at the table. But by default that produces something like:

Table and Chair Room 02
This room contains a TableWithChairs.

>sit at table
(the table)
Okay, you're now sitting on the first chair.

…where I think the (the table) announcement is ugly.

4 Likes

Yeah, I did some suppressing of ambig announcements too…

2 Likes

… which I stole, eh, appropriated, hrm, HOMAGED into my WIP! (so this becomes yet ANOTHER post-WIP tweak to adv3_jjmcc. I better start a list…)

2 Likes