Added more overloading modules and cleaned up the template some more.

This commit is contained in:
Griatch 2015-01-07 18:21:28 +01:00
parent ad3f19896c
commit 2c46ede247
19 changed files with 269 additions and 236 deletions

View file

@ -1,12 +1,6 @@
"""
At_initial_setup module template
Copy this module up one level to /gamesrc/conf, name it what you like
and then use it as a template to modify.
Then edit settings.AT_INITIAL_SETUP_HOOK_MODULE to point to your new
module.
Custom at_initial_setup method. This allows you to hook special
modifications to the initial server startup process. Note that this
will only be run once - when the server starts up for the very first

View file

@ -0,0 +1,90 @@
"""
Search and multimatch handling
This module allows for overloading two functions used by Evennia's
search functionality:
at_search_result:
This is called whenever a result is returned from an object
search (a common operation in commands). It should (together
with at_multimatch_input below) define some way to present and
differentiate between multiple matches (by default these are
presented as 1-ball, 2-ball etc)
at_multimatch_input:
This is called with a search term and should be able to
identify if the user wants to separate a multimatch-result
(such as that from a previous search). By default, this
function understands input on the form 1-ball, 2-ball etc as
indicating that the 1st or 2nd match for "ball" should be
used.
This module is not called by default. To overload the defaults, add
one or both of the following lines to your settings.py file:
SEARCH_AT_RESULT = "server.conf.at_search.at_search_result"
SEARCH_AT_MULTIMATCH_INPUT = "server.conf.at_search.at_multimatch_input"
"""
def at_search_result(msg_obj, ostring, results, global_search=False,
nofound_string=None, multimatch_string=None, quiet=False):
"""
Called by search methods after a result of any type has been found.
Takes a search result (a list) and
formats eventual errors.
msg_obj - object to receive feedback.
ostring - original search string
results - list of found matches (0, 1 or more)
global_search - if this was a global_search or not
(if it is, there might be an idea of supplying
dbrefs instead of only numbers)
nofound_string - optional custom string for not-found error message.
multimatch_string - optional custom string for multimatch error header
quiet - work normally, but don't echo to caller, just return the
results.
Multiple matches are returned to the searching object
as a list of results ["1-object", "2-object","3-object",...]
A single match is returned on its own.
"""
pass
def at_multimatch_input(ostring):
"""
This parser will be called by the engine when a user supplies
a search term. The search term must be analyzed to determine
if the user wants to differentiate between multiple matches
(usually found during a previous search).
This method should separate out any identifiers from the search
string used to differentiate between same-named objects. The
result should be a tuple (index, search_string) where the index
gives which match among multiple matches should be used (1 being
the lowest number, rather than 0 as in Python).
The default parser will intercept input on the following form:
2-object
This will be parsed to (2, "object") and, if applicable, will tell
the engine to pick the second from a list of same-named matches of
objects called "object".
Ex for use in a game session:
> look
You see: ball, ball, ball and ball.
> get ball
There where multiple matches for ball:
1-ball
2-ball
3-ball
4-ball
> get 3-ball
You get the ball.
"""
pass

View file

@ -1,21 +1,11 @@
"""
Server startstop hooks
At_server_startstop module template
This module contains functions called by Evennia at various
points during its startup, reload and shutdown sequence. It
allows for customizing the server operation as desired.
Copy this module one level up, to gamesrc/conf/, name it what you
will and use it as a template for your modifications.
Then edit settings.AT_SERVER_STARTSTOP_MODULE to point to your new
module.
This module contains functions that are imported and called by the
server whenever it changes its running status. At the point these
functions are run, all applicable hooks on individual objects have
already been executed. The main purpose of this is module is to have a
safe place to initialize eventual custom modules that your game needs
to start up or load.
The module should define at least these global functions:
This module must contain at least these global functions:
at_server_start()
at_server_stop()
@ -37,8 +27,8 @@ def at_server_start():
def at_server_stop():
"""
This is called just before a server is shut down, regardless
of it is fore a reload, reset or shutdown.
This is called just before the server is shut down, regardless
of it is for a reload, reset or shutdown.
"""
pass
@ -67,6 +57,7 @@ def at_server_cold_start():
def at_server_cold_stop():
"""
This is called only when the server goes down due to a shutdown or reset.
This is called only when the server goes down due to a shutdown or
reset.
"""
pass

View file

@ -0,0 +1,54 @@
"""
Changing the default command parser
The cmdparser is responsible for parsing the raw text inserted by the
user, identifying which command/commands match and return one or more
matching command objects. It is called by Evennia's cmdhandler and
must accept input and return results on the same form. The default
handler is very generic so you usually don't need to overload this
unless you have very exotic parsing needs; advanced parsing is best
done at the Command.parse level.
The default cmdparser understands the following command combinations
(where [] marks optional parts.)
[cmdname[ cmdname2 cmdname3 ...] [the rest]
A command may consist of any number of space-separated words of any
length, and contain any character. It may also be empty.
The parser makes use of the cmdset to find command candidates. The
parser return a list of matches. Each match is a tuple with its first
three elements being the parsed cmdname (lower case), the remaining
arguments, and the matched cmdobject from the cmdset.
This module is not accessed by default. To tell Evennia to use it
instead of the default command parser, add the following line to
your settings file:
COMMAND_PARSER = "server.conf.cmdparser.cmdparser"
"""
def cmdparser(raw_string, cmdset, caller, match_index=None):
"""
This function is called by the cmdhandler once it has
gathered and merged all valid cmdsets valid for this particular parsing.
raw_string - the unparsed text entered by the caller.
cmdset - the merged, currently valid cmdset
caller - the caller triggering this parsing
match_index - an optional integer index to pick a given match in a
list of same-named command matches.
Returns:
list of tuples: [(cmdname, args, cmdobj, cmdlen, mratio), ...]
where cmdname is the matching command name and args is
everything not included in the cmdname. Cmdobj is the actual
command instance taken from the cmdset, cmdlen is the length
of the command name and the mratio is some quality value to
(possibly) separate multiple matches.
"""
# Your implementation here

View file

@ -1,58 +1,33 @@
# -*- coding: utf-8 -*-
"""
Connect screen module template
Connection screen
Copy this module one level up, to gamesrc/conf/, name it what
you want and modify it to your liking.
Texts in this module will be shown to the user at login-time.
Then you set settings.CONNECTION_SCREEN_MODULE to point to your
new module.
Evennia will look at global string variables (variables defined
at the "outermost" scope of this module and use it as the
connection screen. If there are more than one, Evennia will
randomize which one it displays.
This module holds textual connection screen definitions. All global
string variables (only) in this module are read by Evennia and
assumed to define a Connection screen.
The names of the string variables doesn't matter (but names starting
with an underscore will be ignored), but each should hold a string
defining a connection screen - as seen when first connecting to the
game (before having logged in).
OBS - If there are more than one global string variable in this
module, a random one is picked!
After adding new connection screens to this module you must either
reboot or reload the server to make them available.
The commands available to the user when the connection screen is shown
are defined in commands.default_cmdsets.UnloggedinCmdSet and the
screen is read and displayed by the unlogged-in "look" command.
"""
# comment this out if wanting to completely remove the default screen
from src.commands.connection_screen import DEFAULT_SCREEN
from django.conf import settings
from evennia import utils
## uncomment these for showing the name and version
# from django.conf import settings
# from src.utils import utils
CONNECTION_SCREEN = \
"""{b=============================================================={n
Welcome to {g%s{n, version %s!
## A copy of the default screen to modify
If you have an existing account, connect to it by typing:
{wconnect <username> <password>{n
If you need to create an account, type (without the <>'s):
{wcreate <username> <password>{n
# CUSTOM_SCREEN = \
#"""{b=============================================================={n
# Welcome to {g%s{n, version %s!
#
# If you have an existing account, connect to it by typing:
# {wconnect <username> <password>{n
# If you need to create an account, type (without the <>'s):
# {wcreate <username> <password>{n
#
# If you have spaces in your username, enclose it in quotes.
# Enter {whelp{n for more info. {wlook{n will re-show this screen.
#{b=============================================================={n""" \
# % (settings.SERVERNAME, utils.get_evennia_version())
## Minimal header for use with contrib/menu_login.py
# MENU_SCREEN = \
# """{b=============================================================={n
# Welcome to {g%s{n, version %s!
# {b=============================================================={n""" \
# % (settings.SERVERNAME, utils.get_evennia_version())
If you have spaces in your username, enclose it in quotes.
Enter {whelp{n for more info. {wlook{n will re-show this screen.
{b=============================================================={n""" \
% (settings.SERVERNAME, utils.get_evennia_version())

View file

@ -1,33 +1,30 @@
"""
Lockfuncs module template
Lockfuncs
Copy this module one level up, to gamesrc/conf/, name it what
you will and edit it to your liking.
Then add the new module's path to the end of the tuple
defined in settings.LOCK_FUNC_MODULES.
Lock functions are functions available when defining lock strings,
which in turn limits access to various game systems.
All functions defined globally in this module are assumed to be
available for use in lockstrings to determine access. See
http://code.google.com/p/evennia/wiki/Locks
available for use in lockstrings to determine access. See the
Evennia documentation for more info on locks.
A lock function is always called with two arguments, accessing_obj and
accessed_obj, followed by any number of arguments. All possible
arguments should be handled (excess ones calling magic (*args,
**kwargs) to avoid errors). The lock function should handle all
eventual tracebacks by logging the error and returning False.
arguments should be handled with *args, **kwargs. The lock function
should handle all eventual tracebacks by logging the error and
returning False.
See many more examples of lock functions in src.locks.lockfuncs.
Lock functions in this module extend (and will overload same-named)
lock functions from evennia.locks.lockfuncs.
"""
def myfalse(accessing_obj, accessed_obj, *args, **kwargs):
"""
called in lockstring with myfalse().
A simple logger that always returns false. Prints to stdout
for simplicity, should use utils.logger for real operation.
"""
print "%s tried to access %s. Access denied." % (accessing_obj, accessed_obj)
return False
#def myfalse(accessing_obj, accessed_obj, *args, **kwargs):
# """
# called in lockstring with myfalse().
# A simple logger that always returns false. Prints to stdout
# for simplicity, should use utils.logger for real operation.
# """
# print "%s tried to access %s. Access denied." % (accessing_obj, accessed_obj)
# return False

View file

@ -1,22 +1,16 @@
"""
MSSP module template
MSSP (Mud Server Status Protocol) meta information
Copy this module one level up, to gamesrc/conf/, name it
what you want and edit it to your satisfaction.
MUD website listings (that you have registered with) can use this
information to keep up-to-date with your game stats as you change
them. Also number of currently active players and uptime will
automatically be reported. You don't have to fill in everything
(and most are not used by all crawlers); leave the default
if so needed. You need to @reload the game before updated
information is made available to crawlers (reloading does not
affect uptime).
Then change settings.MSSP_META_MODULE to point to your new module.
MSSP (Mud Server Status Protocol) meta information
MUD website listings (that you have registered with) can use this
information to keep up-to-date with your game stats as you change
them. Also number of currently active players and uptime will
automatically be reported. You don't have to fill in everything
(and most are not used by all crawlers); leave the default
if so needed. You need to @reload the game before updated
information is made available to crawlers (reloading does not
affect uptime).
"""
MSSPTable = {

View file

@ -1,24 +1,23 @@
"""
Start plugin services
This plugin module can define user-created services for the Server to start.
This plugin module can define user-created services for the Portal to
start.
To use, copy this module up one level to game/gamesrc/conf/ and set
settings.SERVER_SERVICES_PLUGIN_MODULE to point to this module.
This module must handle all imports and setups required to start a twisted
services (see examples in src/server/server.py). It must also contain a
function start_plugin_services(application). Evennia will call this function
with the main Server application (so your services can be added to it). The
function should not return anything. Plugin services are started last in
the Server startup process.
This module must handle all imports and setups required to start
twisted services (see examples in src/server/server.py). It must also
contain a function start_plugin_services(application). Evennia will
call this function with the main Portal application (so your services
can be added to it). The function should not return anything. Plugin
services are started last in the Portal startup process.
"""
def start_plugin_services(server):
def start_plugin_services(portal):
"""
This hook is called by Evennia, last in the Server startup process.
This hook is called by Evennia, last in the Portal startup process.
server - a reference to the main server application.
portal - a reference to the main portal application.
"""
pass

View file

@ -1,24 +1,23 @@
"""
This plugin module can define user-created services for the Portal to start.
Server plugin services
To use, copy this module up one level to game/gamesrc/conf/ and set
settings.PORTAL_SERVICES_PLUGIN_MODULE to point to this module.
This plugin module can define user-created services for the Server to start.
This module must handle all imports and setups required to start a twisted
service (see examples in src/server/server.py). It must also contain a
function start_plugin_services(application). Evennia will call this function
with the main Portal application (so your services can be added to it). The
with the main Server application (so your services can be added to it). The
function should not return anything. Plugin services are started last in
the Portal startup process.
the Server startup process.
"""
def start_plugin_services(portal):
def start_plugin_services(server):
"""
This hook is called by Evennia, last in the Portal startup process.
This hook is called by Evennia, last in the Server startup process.
portal - a reference to the main portal application.
server - a reference to the main server application.
"""
pass