From eb738ebad8c7df29b6c8c61a24eb196fccfddbfc Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 10 Feb 2015 10:26:08 +0100 Subject: [PATCH] Made tutorial_world run on devel, it had a few deprecated imports and also the path to the build file given in the limbo desc was not right anymore. --- evennia/contrib/tutorial_world/mob.py | 8 +-- evennia/contrib/tutorial_world/objects.py | 4 +- evennia/contrib/tutorial_world/rooms.py | 23 ++++----- evennia/server/initial_setup.py | 59 ++++++++++++++--------- 4 files changed, 54 insertions(+), 40 deletions(-) diff --git a/evennia/contrib/tutorial_world/mob.py b/evennia/contrib/tutorial_world/mob.py index 0a837bef90..faffbfd5f0 100644 --- a/evennia/contrib/tutorial_world/mob.py +++ b/evennia/contrib/tutorial_world/mob.py @@ -8,9 +8,9 @@ object based on that mobile class. import random, time from django.conf import settings -from evennia import search_object, utils, Script -from contrib.tutorial_world import objects as tut_objects -from contrib.tutorial_world import scripts as tut_scripts +from evennia import search_object, utils, DefaultScript +from evennia.contrib.tutorial_world import objects as tut_objects +from evennia.contrib.tutorial_world import scripts as tut_scripts BASE_CHARACTER_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS @@ -88,7 +88,7 @@ class Mob(tut_objects.TutorialObject): # #------------------------------------------------------------ -class AttackTimer(Script): +class AttackTimer(DefaultScript): """ This script is what makes an eneny "tick". """ diff --git a/evennia/contrib/tutorial_world/objects.py b/evennia/contrib/tutorial_world/objects.py index c35c6c1c28..6fa2ff5e75 100644 --- a/evennia/contrib/tutorial_world/objects.py +++ b/evennia/contrib/tutorial_world/objects.py @@ -23,7 +23,7 @@ import time import random from evennia import create_object -from evennia import DefaultObject, DefaultExit, Command, CmdSet, Script +from evennia import DefaultObject, DefaultExit, Command, CmdSet, DefaultScript #------------------------------------------------------------ # @@ -224,7 +224,7 @@ class Obelisk(TutorialObject): # #------------------------------------------------------------ -class StateLightSourceOn(Script): +class StateLightSourceOn(DefaultScript): """ This script controls how long the light source is burning. When it runs out of fuel, the lightsource goes out. diff --git a/evennia/contrib/tutorial_world/rooms.py b/evennia/contrib/tutorial_world/rooms.py index be768cdfac..905d152a93 100644 --- a/evennia/contrib/tutorial_world/rooms.py +++ b/evennia/contrib/tutorial_world/rooms.py @@ -5,10 +5,10 @@ Room Typeclasses for the TutorialWorld. """ import random -from evennia import CmdSet, Script, Command, DefaultRoom +from evennia import CmdSet, DefaultScript, Command, DefaultRoom from evennia import utils, create_object, search_object -from contrib.tutorial_world import scripts as tut_scripts -from contrib.tutorial_world.objects import LightSource, TutorialObject +from evennia.contrib.tutorial_world import scripts as tut_scripts +from evennia.contrib.tutorial_world.objects import LightSource, TutorialObject #------------------------------------------------------------ @@ -241,7 +241,7 @@ class DarkCmdSet(CmdSet): # Darkness room two-state system # -class DarkState(Script): +class DarkState(DefaultScript): """ The darkness state is a script that keeps tabs on when a player in the room carries an active light source. It places @@ -276,7 +276,7 @@ class DarkState(Script): self.obj.scripts.add(LightState) -class LightState(Script): +class LightState(DefaultScript): """ This is the counterpart to the Darkness state. It is active when the lantern is on. @@ -695,12 +695,13 @@ class IntroRoom(TutorialRoom): character.db.health_max = health if character.is_superuser: - string = "-"*78 - string += "\nWARNING: YOU ARE PLAYING AS A SUPERUSER (%s). TO EXPLORE NORMALLY YOU NEED " % character.key - string += "\nTO CREATE AND LOG IN AS A REGULAR USER INSTEAD. IF YOU CONTINUE, KNOW THAT " - string += "\nMANY FUNCTIONS AND PUZZLES WILL IGNORE THE PRESENCE OF A SUPERUSER.\n" - string += "-"*78 - character.msg("{r%s{n" % string) + string = "-"*78 + "\n" \ + "WARNING: You are playing as a superuser ({name}). Use the {quell} command to\n" \ + "play without superuser privileges (many functions and puzzles ignore the \n" \ + "presence of a superuser, making this mode useful for exploring things behind \n" \ + "the scenes later).\n" \ + + "-"*78 + character.msg("{r%s{n" % string.format(name=character.key, quell="{w@quell{r")) #------------------------------------------------------------ diff --git a/evennia/server/initial_setup.py b/evennia/server/initial_setup.py index ca60511b94..5944d4e534 100644 --- a/evennia/server/initial_setup.py +++ b/evennia/server/initial_setup.py @@ -13,6 +13,39 @@ from evennia.players.models import PlayerDB from evennia.server.models import ServerConfig from evennia.utils import create + +ERROR_NO_SUPERUSER = \ + """ + No superuser exists yet. The superuser is the 'owner' account on + the Evennia server. Create a new superuser using the command + + evennia createsuperuser + + Follow the prompts, then restart the server. + """ + + +LIMBO_DESC = \ + _(""" +Welcome to your new {wEvennia{n-based game. From here you are +ready to begin development. Visit http://evennia.com if you should +need help or would like to participate in community discussions. +If you are logged in as user #1 you can create a demo/tutorial +area with {w@batchcommand tutorial_world.build{n. Use {w@quell{n +or login as normal player to play the demo properly. + """) + + +WARNING_POSTGRESQL_FIX = \ + """ + PostgreSQL-psycopg2 compatability fix: + The in-game channels {chan1}, {chan2} and {chan3} were created, + but the superuser was not yet connected to them. Please use in + game commands to connect Player #1 to those channels when first + logging in. + """ + + def create_config_values(): """ Creates the initial config values. @@ -27,12 +60,7 @@ def get_god_player(): try: god_player = PlayerDB.objects.get(id=1) except PlayerDB.DoesNotExist: - txt = "\n\nNo superuser exists yet. The superuser is the 'owner'\n" \ - "account on the Evennia server. Create a new superuser using\n" \ - "the command\n\n" \ - " evennia createsuperuser\n\n" \ - "Follow the prompts, then restart the server." - raise Exception(txt) + raise PlayerDB.DoesNotExist(ERROR_NO_SUPERUSER) return god_player @@ -83,15 +111,7 @@ def create_objects(): limbo_obj = create.create_object(room_typeclass, _('Limbo'), nohome=True) limbo_obj.id = 2 limbo_obj.save() - string = \ - "Welcome to your new {wEvennia{n-based game. From here you are ready " \ - "to begin development. Visit http://evennia.com if you should need " \ - "help or would like to participate in community discussions. If you " \ - "are logged in as user #1 you can create a demo/tutorial area with " \ - "{w@batchcommand contrib.tutorial_world.build{n. Use {w@quell{n or login " \ - "as normal player to play the demo properly." - string = _(string) - limbo_obj.db.desc = string + limbo_obj.db.desc = LIMBO_DESC.strip() limbo_obj.save() # Now that Limbo exists, try to set the user up in Limbo (unless @@ -127,14 +147,7 @@ def create_channels(): or (hasattr(settings, 'DATABASES') and settings.DATABASES.get("default", {}).get('ENGINE', None) == 'django.db.backends.postgresql_psycopg2')): - warning = """ - PostgreSQL-psycopg2 compatability fix: - The in-game channels %s, %s and %s were created, - but the superuser was not yet connected to them. Please use in - game commands to onnect Player #1 to those channels when first - logging in. - """ % (key1, key2, key3) - print warning + print WARNING_POSTGRESQL_FIX.format(chan1=key1, chan2=key2, chan3=key3) return # connect the god user to all these channels by default.