diff --git a/CHANGELOG.md b/CHANGELOG.md index 948e2cfc14..f58279085b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ Update to Python 3 - Add new `@force` command to have another object perform a command. - Add the Portal uptime to the `@time` command. - Make the `@link` command first make a local search before a global search. +- Have the default Unloggedin-look command look for optional `connection_screen()` callable in + `mygame/server/conf/connection_screen.py`. This allows for more flexible welcome screens + that are calculated on the fly. ### Web diff --git a/evennia/commands/default/unloggedin.py b/evennia/commands/default/unloggedin.py index a1f3c462d2..2af3c6bd95 100644 --- a/evennia/commands/default/unloggedin.py +++ b/evennia/commands/default/unloggedin.py @@ -234,9 +234,14 @@ class CmdUnconnectedLook(COMMAND_DEFAULT_CLASS): def func(self): """Show the connect screen.""" - connection_screen = utils.random_string_from_module(CONNECTION_SCREEN_MODULE) - if not connection_screen: - connection_screen = "No connection screen found. Please contact an admin." + + callables = utils.callables_from_module(CONNECTION_SCREEN_MODULE) + if "connection_screen" in callables: + connection_screen = callables['connection_screen']() + else: + connection_screen = utils.random_string_from_module(CONNECTION_SCREEN_MODULE) + if not connection_screen: + connection_screen = "No connection screen found. Please contact an admin." self.caller.msg(connection_screen) diff --git a/evennia/game_template/server/conf/connection_screens.py b/evennia/game_template/server/conf/connection_screens.py index 9ccf42718c..cc85287f8a 100644 --- a/evennia/game_template/server/conf/connection_screens.py +++ b/evennia/game_template/server/conf/connection_screens.py @@ -1,17 +1,22 @@ # -*- coding: utf-8 -*- """ -Connection screen +Connection screen -Texts in this module will be shown to the user at login-time. +This is the text to show the user when they first connect to the game (before +they log in). -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. +To change the login screen in this module, do one of the following: + +- Define a function `connection_screen()`, taking no arguments. This will be + called first and must return the full string to act as the connection screen. + This can be used to produce more dynamic screens. +- Alternatively, define a string variable in the outermost scope of this module + with the connection string that should be displayed. If more than one such + variable is given, Evennia will pick one of them at random. 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. +are defined in evennia.default_cmds.UnloggedinCmdSet. The parsing and display +of the screen is done by the unlogged-in "look" command. """