Made a better template for custom oob commands.
This commit is contained in:
parent
6e66eec0b8
commit
a24b79bb97
1 changed files with 40 additions and 18 deletions
|
|
@ -4,33 +4,55 @@ OOB configuration.
|
||||||
This module should be included in (or replace) the
|
This module should be included in (or replace) the
|
||||||
default module set in settings.OOB_PLUGIN_MODULES
|
default module set in settings.OOB_PLUGIN_MODULES
|
||||||
|
|
||||||
All functions defined in this module are made available
|
A function oob_error will be used as optional error management.
|
||||||
to be called by the OOB handler.
|
The available OOB commands can be extended by changing
|
||||||
|
|
||||||
See src/server/oob_msdp.py for more information.
|
`settings.OOB_PLUGIN_MODULES`
|
||||||
|
|
||||||
function execution - the oob protocol can execute a function directly on
|
CMD_MAP: This module must contain a global dictionary CMD_MAP. This is
|
||||||
the server. The available functions must be defined
|
a dictionary that maps the call-name available to a function in this
|
||||||
as global functions via settings.OOB_PLUGIN_MODULES.
|
module (this allows you to map multiple oob cmdnames to a single
|
||||||
repeat func execution - the oob protocol can request a given function be
|
actual Python function, for example).
|
||||||
executed repeatedly at a regular interval. This
|
|
||||||
uses an internal script pool.
|
|
||||||
tracking - the oob protocol can request Evennia to track changes to
|
|
||||||
fields on objects, as well as changes in Attributes. This is
|
|
||||||
done by dynamically adding tracker-objects on entities. The
|
|
||||||
behaviour of those objects can be customized via
|
|
||||||
settings.OOB_PLUGIN_MODULES.
|
|
||||||
|
|
||||||
oob functions have the following call signature:
|
oob functions have the following call signature:
|
||||||
function(caller, session, *args, **kwargs)
|
|
||||||
|
|
||||||
oob trackers should inherit from the OOBTracker class in src/server.oob_msdp.py
|
function(session, *args, **kwargs)
|
||||||
and implement a minimum of the same functionality.
|
|
||||||
|
|
||||||
a global function oob_error will be used as optional error management.
|
where session is the active session and *args, **kwargs are extra
|
||||||
|
arguments sent with the oob command.
|
||||||
|
|
||||||
|
A function mapped to the key "oob_error" will retrieve error strings
|
||||||
|
if it is defined. It will get the error message as its 1st argument.
|
||||||
|
|
||||||
|
oob_error(session, error, *args, **kwargs)
|
||||||
|
|
||||||
|
This allows for customizing error handling.
|
||||||
|
|
||||||
|
Data is usually returned to the user via a return OOB call:
|
||||||
|
|
||||||
|
session.msg(oob=(oobcmdname, (args,), {kwargs}))
|
||||||
|
|
||||||
|
Oobcmdnames are case-sensitive. Note that args, kwargs must be
|
||||||
|
iterable. Non-iterables will be interpreted as a new command name (you
|
||||||
|
can send multiple oob commands with one msg() call))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# import the contents of the default msdp module
|
# import the contents of the default msdp module
|
||||||
from evennia.server.oob_cmds import *
|
from evennia.server.oob_cmds import *
|
||||||
|
|
||||||
|
|
||||||
|
# def oob_echo(session, *args, **kwargs):
|
||||||
|
# """
|
||||||
|
# Example echo function. Echoes args, kwargs sent to it.
|
||||||
|
#
|
||||||
|
# Args:
|
||||||
|
# session (Session): The Session to receive the echo.
|
||||||
|
# args (list of str): Echo text.
|
||||||
|
# kwargs (dict of str, optional): Keyed echo text
|
||||||
|
#
|
||||||
|
# """
|
||||||
|
# session.msg(oob=("echo", args, kwargs))
|
||||||
|
#
|
||||||
|
## oob command map
|
||||||
|
# CMD_MAP = {"ECHO": oob_echo}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue