From 109627090e86e622db0fd8ec377cac12dd0b4aae Mon Sep 17 00:00:00 2001 From: Andrew Bastien Date: Mon, 13 Apr 2020 14:16:22 -0700 Subject: [PATCH] Made initial_setup.py replaceable in settings.py --- CHANGELOG.md | 2 +- evennia/server/server.py | 3 ++- evennia/settings_default.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c72d7deda..f6bb5ad088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ - Added `content_types` indexing to DefaultObject's ContentsHandler. (volund) - Made most of the networking classes such as Protocols and the SessionHandlers replaceable via `settings.py` for modding enthusiasts. (volund) - +- The `initial_setup.py` file can now be substituted in `settings.py` to customize initial game database state. (volund) ### Already in master - `is_typeclass(obj (Object), exact (bool))` now defaults to exact=False diff --git a/evennia/server/server.py b/evennia/server/server.py index 2093b5b88c..5e65b7429b 100644 --- a/evennia/server/server.py +++ b/evennia/server/server.py @@ -22,6 +22,7 @@ import django django.setup() import evennia +import importlib evennia._init() @@ -31,7 +32,6 @@ from django.conf import settings from evennia.accounts.models import AccountDB from evennia.scripts.models import ScriptDB from evennia.server.models import ServerConfig -from evennia.server import initial_setup from evennia.utils.utils import get_evennia_version, mod_import, make_iter from evennia.utils import logger @@ -333,6 +333,7 @@ class Evennia(object): Once finished the last_initial_setup_step is set to -1. """ global INFO_DICT + initial_setup = importlib.import_module(settings.INITIAL_SETUP_MODULE) last_initial_setup_step = ServerConfig.objects.conf("last_initial_setup_step") if not last_initial_setup_step: # None is only returned if the config does not exist, diff --git a/evennia/settings_default.py b/evennia/settings_default.py index e9e7e98bb2..517562c675 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -332,6 +332,10 @@ CONNECTION_SCREEN_MODULE = "server.conf.connection_screens" # cause issues with menu-logins and autoconnects since the menu will not have # started when the autoconnects starts sending menu commands. DELAY_CMD_LOGINSTART = 0.3 +# A module that must exist - this holds the instructions Evennia will use to +# first prepare the database for use. Generally should not be changed. If this +# cannot be imported, bad things will happen. +INITIAL_SETUP_MODULE = "evennia.server.initial_setup" # An optional module that, if existing, must hold a function # named at_initial_setup(). This hook method can be used to customize # the server's initial setup sequence (the very first startup of the system).