mirror of
https://github.com/evennia/evennia.git
synced 2026-04-05 15:37:17 +02:00
Renamed GLOBAL_HANDLER to GLOBAL_SCRIPTS and cleaned up to PEP8
This commit is contained in:
parent
1bdeb270c4
commit
11814691d0
3 changed files with 17 additions and 15 deletions
|
|
@ -109,7 +109,7 @@ TASK_HANDLER = None
|
|||
TICKER_HANDLER = None
|
||||
MONITOR_HANDLER = None
|
||||
CHANNEL_HANDLER = None
|
||||
GLOBAL_HANDLER = None
|
||||
GLOBAL_SCRIPTS = None
|
||||
|
||||
|
||||
def _create_version():
|
||||
|
|
@ -153,7 +153,7 @@ def _init():
|
|||
global search_object, search_script, search_account, search_channel, search_help, search_tag, search_message
|
||||
global create_object, create_script, create_account, create_channel, create_message, create_help_entry
|
||||
global settings, lockfuncs, logger, utils, gametime, ansi, spawn, managers
|
||||
global contrib, TICKER_HANDLER, MONITOR_HANDLER, SESSION_HANDLER, CHANNEL_HANDLER, TASK_HANDLER, GLOBAL_HANDLER
|
||||
global contrib, TICKER_HANDLER, MONITOR_HANDLER, SESSION_HANDLER, CHANNEL_HANDLER, TASK_HANDLER, GLOBAL_SCRIPTS
|
||||
global EvMenu, EvTable, EvForm, EvMore, EvEditor
|
||||
global ANSIString
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ def _init():
|
|||
from .server.sessionhandler import SESSION_HANDLER
|
||||
from .comms.channelhandler import CHANNEL_HANDLER
|
||||
from .scripts.monitorhandler import MONITOR_HANDLER
|
||||
from .scripts.globalhandler import GLOBAL_HANDLER
|
||||
from .scripts.globalhandler import GLOBAL_SCRIPTS
|
||||
|
||||
# initialize the doc string
|
||||
global __doc__
|
||||
|
|
|
|||
|
|
@ -6,23 +6,23 @@ class GlobalHandler(object):
|
|||
"""
|
||||
Simple Handler object loaded by the Evennia API to contain and manage a game's Global Scripts.
|
||||
|
||||
This is accessed like a dictionary.
|
||||
This is accessed like a dictionary. Alternatively you can access Properties on it.
|
||||
|
||||
Example:
|
||||
import evennia
|
||||
evennia.GLOBAL_HANDLER['key']
|
||||
evennia.GLOBAL_SCRIPTS['key']
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.typeclass_storage = dict()
|
||||
self.script_storage = dict()
|
||||
for k, v in settings.GLOBAL_SCRIPTS.items():
|
||||
self.typeclass_storage[k] = class_from_module(v)
|
||||
for k, v in self.typeclass_storage.items():
|
||||
found = v.objects.filter_family(db_key=k).first()
|
||||
for key, typeclass_path in settings.GLOBAL_SCRIPTS.items():
|
||||
self.typeclass_storage[key] = class_from_module(typeclass_path)
|
||||
for key, typeclass in self.typeclass_storage.items():
|
||||
found = typeclass.objects.filter(db_key=key).first()
|
||||
if not found:
|
||||
found = v.create(key=k, typeclass=v, persistent=True)
|
||||
self.script_storage[k] = found
|
||||
found = typeclass.create(key=key, typeclass=typeclass, persistent=True)
|
||||
self.script_storage[key] = found
|
||||
|
||||
def __getitem__(self, item):
|
||||
|
||||
|
|
@ -40,6 +40,9 @@ class GlobalHandler(object):
|
|||
self.script_storage[item] = reloaded
|
||||
return reloaded
|
||||
|
||||
def __getattr__(self, item):
|
||||
return self[item]
|
||||
|
||||
|
||||
# Create singleton of the GlobalHandler for the API.
|
||||
GLOBAL_HANDLER = GlobalHandler()
|
||||
GLOBAL_SCRIPTS = GlobalHandler()
|
||||
|
|
|
|||
|
|
@ -549,9 +549,8 @@ PROTOTYPEFUNC_MODULES = ["evennia.utils.prototypefuncs",
|
|||
# this for Scripts that absolutely MUST be running for your game as a
|
||||
# simple way to get them launched.
|
||||
|
||||
# One limitation with this system is that each Script must be have a
|
||||
# unique Typeclass. The 'key' is a way to quickly index them but is
|
||||
# not necessarily the Script Typeclasss's key.
|
||||
# The 'key' is a way to quickly index them, and it will also be the
|
||||
# Script Typeclasss's key so it can be quickly retrieved.
|
||||
|
||||
GLOBAL_SCRIPTS = {
|
||||
# 'key': 'typeclass.path.here',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue