AfterFailedCommand Block
AfterFailedCommand Block

AfterFailedCommand Block

AfterFailedCommand ( )

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

Valid on Elements

Parameters

No Parameters

When it is Called

The AfterFailedCommand() block on the world element is called after a "failed command" (and the first set of enqueued commands during its execution) are processed. Generally, a "failed command" is a command that is processed that is the result of a bad interpreted action (errors, or "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

AfterSuccessfulCommand() — "Lifecycle" block: called if interpretation succeeds.
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