SYNOPSIS

#include <sys/driver_hooks.h>
set_driver_hook( H_COMMAND, value)

DESCRIPTION

Arguments:
  • value (closure) – int <closure>(string command, object command_giver)
  • value (string) – int <name>(string command, object command_giver)

Optional hook to parse and execute commands. If this hook is used, it bypasses the normal command parsing done by the driver (including the MODIFY_COMMAND and NOTIFY_FAIL hooks).

The hook is called with two parameters: the command received from the living (interactive user or NPC), and the living object (the ‘command giver’) itself. The hook has to return non-0 if the command was found and executed, and 0 otherwise.

At the time the hook is called, query_command(E) returns the command string and this_player(E) returns the living object. query_verb(E) and query_notify_fail(E) return 0.

If the hook is a string, it is the name of an lfun in the command giver; if the hook is a lambda closure, it is bound to the command giver before the call.