Optionally read connection screen from connection_screen() callable

This commit is contained in:
Griatch 2019-03-22 08:04:25 +01:00
parent 1d0d6bc7cf
commit c4d178c6c7
3 changed files with 24 additions and 11 deletions

View file

@ -14,6 +14,9 @@ Update to Python 3
- Add new `@force` command to have another object perform a command. - Add new `@force` command to have another object perform a command.
- Add the Portal uptime to the `@time` command. - Add the Portal uptime to the `@time` command.
- Make the `@link` command first make a local search before a global search. - 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 ### Web

View file

@ -234,6 +234,11 @@ class CmdUnconnectedLook(COMMAND_DEFAULT_CLASS):
def func(self): def func(self):
"""Show the connect screen.""" """Show the connect screen."""
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) connection_screen = utils.random_string_from_module(CONNECTION_SCREEN_MODULE)
if not connection_screen: if not connection_screen:
connection_screen = "No connection screen found. Please contact an admin." connection_screen = "No connection screen found. Please contact an admin."

View file

@ -2,16 +2,21 @@
""" """
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 To change the login screen in this module, do one of the following:
at the "outermost" scope of this module and use it as the
connection screen. If there are more than one, Evennia will - Define a function `connection_screen()`, taking no arguments. This will be
randomize which one it displays. 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 The commands available to the user when the connection screen is shown
are defined in commands.default_cmdsets. UnloggedinCmdSet and the are defined in evennia.default_cmds.UnloggedinCmdSet. The parsing and display
screen is read and displayed by the unlogged-in "look" command. of the screen is done by the unlogged-in "look" command.
""" """