Multiple Verbs Per Subject Patch (Adv3Lite)

If there is already a known way to do this in Adv3Lite, then I apologize, and would really love to know.

However, I was having a bit of trouble trying to get a series of verbs to agree with the same subject.

For example, here are example strings to print:

"{I} {hold} onto the ledge, drop{s/?ed},
and land{s/ed} on the floor below.";
"{He actor} {hold} onto the ledge, drop{s/?ed},
and land{s/ed} on the floor below.";

Despite my best efforts, I always got this result:

I hold onto the ledge, drops, and lands on the floor below.

(OLD CODE! See my updated code on the reply below!)

So I added the following custom dummy to my code:

// When the actor has multiple verbs per sentence,
// we can use this to keep the expansion on track.
actorActionContinuer_: Thing {
    dummyName = ''
    name = ''
    theName = ''
    // Not sure why this would be necessary,
    // but I'm trying to follow the pattern
    // set by dummy_ in Adv3Lite:
    noteName(src) {
        name = src;
        theName = 'the ' + src;
    }
    person = (gActor == nil ? 3 : gActor.person)
    plural = (gActor == nil ? nil : gActor.plural)
}

Now, if I do the following:

local aac = actorActionContinuer_;
gMessageParams(aac);
"{I} {hold} onto the ledge,{the subj aac}
drop{s/?ed},{the subj aac}
and land{s/ed} on the floor below.";

I finally get this result:

I hold onto the ledge, drop, and land on the floor below.


I feel like I re-invented the wheel, and probably missed something in the Adv3Lite docs, but this is how I solved it, in case anyone else was having the same problem.

Again, if anyone knows how this is supposed to be done, please let me know!

1 Like

I updated my code to get this working a lot more easily!

EDIT: Jan 5 12:56 am I did another tiny change to my below code. It doesn’t alter the function at all, but makes it a little cleaner…!
New code, which gets added before the rest of the game code:

// When the actor has multiple verbs per sentence,
// we can use this to keep the expansion on track.
actorActionContinuer_: dummy_ {
    person = (gActor == nil ? 3 : gActor.person)
    plural = (gActor == nil ? nil : gActor.plural)
}

// A modified englishMessageParams will have our new token.
modify englishMessageParams {
    construct() {
        // Add the simplified message token
        params = params.append(['aac', { ctx, params:
            cmdInfo(ctx, actorActionContinuer_, &dummyName, vSubject)
        }]);

        inherited();
    }
}

With this new code, we can now format our sentences like so:

"{I} {hold} onto the ledge,{aac} drop{s/?ed},{aac}
and land{s/ed} on the floor below.";

This not only skips the need for gMessageParams() in my old code, but also makes the string quite a bit easier to write up!

We still get our desired output:

I hold onto the ledge, drop, and land on the floor below.

I’m definitely going to include this in all of my projects; it’s that useful. You should consider adding it to the TADS cookbook.

2 Likes

Wait…there’s a TADS cookbook?? And I could append something to it???

I was actually tempted to release this as a mini-extension, but that would work too, I suppose!

There is indeed: https://github.com/jimbonator/tads-cookbook/wiki

Yes! https://github.com/jimbonator/tads-cookbook/wiki/Contributing

The idea of the cookbook is to accumulate “recipes” for dealing with common situations when coding in TADS (such as when to use initSpecialDesc or specialDesc, etc.)

You could do that too. Since your solution is so short, I think it could work either way.

2 Likes

I’ll take a look at adding it to the next release of adv3Lite (after double checking it doesn’t duplicate anything that’s already there, but I don’t think it does, off the top of my head).

2 Likes

Absolutely stellar!! :smiley:

Heck yeah, I have likely contributed!! :grin:

I haven’t looked through the source code or done really exhaustive tests, but I think that there is some partial support for correct multiple consecutive verb-substitutions already there.

It seems that especially the {s/?ed} substitution construct resets (or swallows or leads to losing) the subject reference, whereas at least some other substitutions work fine consecutively with the same subject. For example:

{I} {run}, {eat}, {hold} a bottle, balance{s/d} a tray and smile{s/d} at the same time.

leads to the correct output:

I run, eat, hold a bottle, balance a tray and smile at the same time.

This:

{I} also walk{s/ed} and talk{s/ed} and {think} at the same time.

… is fine, too:

I also walk and talk and think at the same time.

But this:

In another experiment, {i} {run}, then walk{s/ed}, then jog{s/?ed}, then {run} again.

… leads to the loss of the correct subject reference after the jog{s/?ed} substitution, resulting in the incorrect “runs” at the end:

In another experiment, I run, then walk, then jog, then runs again.

2 Likes

Okay, so, based on what @StJohnLimbo has found, I may have actually discovered a bug?

But in case you were still interested, I have submitted the aac token to the cookbook…!

Yes, you’ve discovered a bug. The message builder was treating the ? in the {s/?ed} message substitution parameter as an end of sentence marker so that the subject of successive verbs was reset (to dummy_). I’ve now fixed this for version 1.61 and uploaded the fix to GitHub.

At the same time I’ve incorporated your {aac} token in case it’s useful for other cases.

2 Likes

Yay, I found a bug!! :grin:

And I’m quite happy to hear that the {aac} token has been deemed useful enough to be added! :smiley: