[adv3lite] Invoking a Command Programmatically

This is an odd situation, and I haven’t found anything in the docs that seems relevant. I’d like to be able to issue a new command in an embedded expression – something like this (in an EventList, perhaps):


I know I can call methods from an embedded expression, and that will probably do as a workaround, but what I’d really like is a sort of doInstead functionality, where a topicResponse from one Actor’s DefaultAnyTopic will trigger an entirely different command-line-type command.

I don’t think a Doer will quite do the job, because a Doer reroutes an existing command; it doesn’t create one from scratch. Again, a Doer could be employed as a workaround.

The reason I’m seeking this functionality has to do with the fact that individual actors are part of a CollectiveGroup, and I want the CollectiveGroup, rather than an individual NPC, to handle the player’s conversational gambit.

I’ve solved the immediate problem by employing a simple workaround, but I’m still curious about the basic question. I know a command can be entered as a hyperlink using aHref, but I’m not looking for a clickable command. I’m wondering about an action that can be invoked silently, by my own code.

The adv3Lite library provides the functions replaceAction(), replaceActorAction(), nestedAction() and nestedActorAction() for this purpose. The versions with ‘replace’ in their name replace the current action with a new one while those with “nested” in their name carry out the new action and then continue with the existing one. The ones with “Actor” in their name allow you specify which actor will carry out the action, while the others simply assume it’s the current actor (gActor).

So, for example, instead of:

'<<put greenBall in redBox>>',

You might write:

{: replaceActorAction(gPlayerChar, PutIn, greenBall, redBox) }

If you wanted the player character to put the green ball in the red box.

Alternatively, since ActorTopicEntry inherits from the Redirector class, the doInstead method should also be available:

{: doInstead(PutIn, greenBall, redBox) }

This doesn’t allow you to specify which actor will carry out the action, though (so it will always be the current actor).

Thanks – I haven’t worked on the game for three months, so I’m a little rusty.

BTW, I notice that replaceAction is not mentioned in the Learning book, though replaceActorAction is mentioned in the NPC section. (Ditto for nestedAction and nestedActorAction.) If you’re considering doing a few revisions of the docs at any point, you might want to consider adding a short section on replacing actions at the end of Chapter Six.