AfterSuccessfulCommand Block
AfterSuccessfulCommand Block

AfterSuccessfulCommand Block

AfterSuccessfulCommand ( )

A block that describes what to do after a "successful command" is processed.

Valid on Elements

Parameters

No Parameters

When it is Called

The AfterSuccessfulCommand() block on the world element is called after a "successful command" (and the first set of enqueued commands during its execution) are processed. Generally, a "successful command" is a command that is processed that is the result of a valid interpreted action (no errors, no "unknown" names).

Example

Lifecycle Example


action general a_quit named "quit";
action transitive a_examine named "examine", "look at", "x";

object o_inf_ball named "infinity ball", "ball" uses determiners "the"
{
	// not examinable.
	
	onWorldBrowse()
	{
		textln("There is an infinity ball here.");
	}
	
}

object o_solid_ball named "solid ball", "ball" uses determiners "the"
{
	onAction (a_examine)
	{
		textln("Looks like a ball.");
	}

	onWorldBrowse()
	{
		textln("There is a solid ball here.");
	}
	
}

world
{
	init()
	{
		giveObject(this, o_inf_ball);
		giveObject(this, o_solid_ball);
	}
	
	function splash()
	{
		textln("Examine things with \"examine\".");
		textln("Type \"quit\" to quit.");
		browse(world);
	}
	
	start()
	{
		splash();
		textln("Try to hit all of the error conditions with your input!");
	}

	onAction(a_quit)
	{
		quit;
	}
	
	onUnhandledAction(a_examine)
	{
		textln("I can't examine that.");
	}
	
	onMalformedCommand(a_examine)
	{
		textln("I don't understand what you want to examine.");
	}
	
	onIncompleteCommand(a_examine)
	{
		textln("What should I examine?");
	}
	
	onAmbiguousCommand(a_examine)
	{
		textln("I need to be more specific.");
	}
	
	afterSuccessfulCommand()
	{
		textln("Command successful.");
	}
	
	afterFailedCommand()
	{
		textln("Command failed.");
	}
	
	afterEveryCommand()
	{
		splash();
	}
	
}

See Also

AfterFailedCommand() — "Lifecycle" block: called if interpretation fails.
AfterEveryCommand() — "Lifecycle" block: called after every command.

Additional Technical Notes

Initializing a context is wrapped in one request-response loop. The response cues that come back are the result of all init() blocks plus start(). All operations executed contribute towards the operations and function depth limits, which is TAME's soft protection against infinite loops and stack overflows. This may vary by implementation, but the author can override these in the module header.

TAME's general flow of handling commands are:

  • Interpret Input.
  • If "successful command", Else (failed command),
    • Call appropriate block.
    • Process all Queued Commands.
    • Call afterFailedCommand().
    • Process all Queued Commands.
  • Call afterEveryCommand().
  • Process all Queued Commands.

There's a full diagram available that outlines TAME's logic.

×

Modal Header