Adv3Lite Transforming a Set to SetTo, Attack to AttackWith, etc

I was looking for some setup advice or curious if it’s even possible to achieve what I’m trying to achieve.

I have certain situations where the appropriate verb is attack x with y or set x to y and not attack x or set x For example, attacking a training dummy. You could conceivably do it with your bear hands and I can give a message saying “try attacking with something” or some such. But it really looks like there was intention in the library to allow for missing questions in these cases:

VerbRule(AttackWith)
    ('attack' | 'kill' | 'hit' | 'strike')
        singleDobj 'with' singleIobj
    : VerbProduction
    action = AttackWith
    verbPhrase = 'attack/attacking (whom) (with what)'
    missingQ = 'whom do you want to attack;what do you want to attack it with'
    dobjReply = singleNoun
    iobjReply = withSingleNoun
;

VerbRule(SetTo)
    'set' singleDobj 'to' literalIobj
    : VerbProduction
    action = SetTo
    verbPhrase = 'set/setting (what) (to what)'
    missingQ = 'what do you want to set;what do you want to set it to'
    dobjReply = singleNoun
;

Is there any way to get the missingQ prompt behavior of SetTo / AttackWith and all their friends when you want it?

1 Like

You can achieve this by using askForIob() in the dobjFor action section, for example:

    dobjFor(Attack)
    {
        action()
        {
            askForIobj(AttackWith);
        }
    }

The SetTo case is trickier, since the iobj is literal, not a a Thing, but the following does the job:

    isSettable = true
    
    dobjFor(Set)
    {
        action()
        {
            "What do you want to set it to?\b";
            local val = inputManager.getInputLine();
                        
            doInstead (SetTo, self, val);
        }
    }
5 Likes

That worked perfectly Eric. Thanks for the great solution.

1 Like

I’m glad it worked for you,

That said, I believe the library should make it a bit easier for game authors to handle cases that involve literals, such as the SetTo example above, so I’ve now defined a new askMissingLiteral() method that would allow you to just write:

    dobjFor(Set)
    {
        action() { askMissingLiteral(SetTo); }
    }   

Instead of the code above – except you won’t have to, since I’ve now also gone through the library applying this kind of change to the handling of all LiteralActions and LiteralTActions where it can appropriately be applied, which I hope will make things a bit easier for game authors.

These changes will thus form part of the next release.

3 Likes