diff --git a/CHANGELOG.md b/CHANGELOG.md index 1700f28e3a..14f2d8c944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,8 @@ Up requirements to Django 3.2+ on-object Scripts. Moved `CmdScripts` and `CmdObjects` to `commands/default/building.py`. - Keep GMCP function case if outputfunc starts with capital letter (so `cmd_name` -> `Cmd.Name` but `Cmd_nAmE` -> `Cmd.nAmE`). This helps e.g Mudlet's legacy `Client_GUI` implementation) +- Prototypes now allow setting `prototype_parent` directly to a prototype-dict. + This makes it easier when dynamically building in-module prototypes. ### Evennia 0.9.5 (2019-2020) diff --git a/docs/source/Contribs/XYZGrid.md b/docs/source/Contribs/XYZGrid.md index fb89b4e8e6..5b0c823d4d 100644 --- a/docs/source/Contribs/XYZGrid.md +++ b/docs/source/Contribs/XYZGrid.md @@ -56,6 +56,12 @@ Exits: northeast and east command line. It will also make the `xyz_room` and `xyz_exit` prototypes available for use as prototype-parents when spawning the grid. 3. Run `evennia xyzgrid help` for available options. +4. (Optional): By default, the xyzgrid will only spawn module-based + [prototypes](Prototypes). This is an optimization and usually makes sense + since the grid is entirely defined outside the game anyway. If you want to + also make use of in-game (db-) created prototypes, add + `XYZGRID_USE_DB_PROTOTYPES = True` to settings. + ## Overview @@ -1002,8 +1008,8 @@ should be included as `prototype_parents` for prototypes on the map. Would it not be nice to be able to change these and have the change apply to all of the grid? You can, by adding the following to your `mygame/server/conf/settings.py`: - XYZROOM_PARENT_PROTOTYPE_OVERRIDE = {"typeclass": "myxyzroom.MyXYZRoom"} - XYZEXIT_PARENT_PROTOTYPE_OVERRIDE = {...} + XYZROOM_PROTOTYPE_OVERRIDE = {"typeclass": "myxyzroom.MyXYZRoom"} + XYZEXIT_PROTOTYPE_OVERRIDE = {...} > If you override the typeclass in your prototypes, the typeclass used **MUST** diff --git a/evennia/contrib/xyzgrid/example.py b/evennia/contrib/xyzgrid/example.py index 5e01268c8e..d9f357d7ab 100644 --- a/evennia/contrib/xyzgrid/example.py +++ b/evennia/contrib/xyzgrid/example.py @@ -23,16 +23,24 @@ from evennia.contrib.xyzgrid import xymap_legend # the typeclass inherits from the XYZRoom (or XYZExit) # if adding the evennia.contrib.xyzgrid.prototypes to # settings.PROTOTYPE_MODULES, one could just set the -# prototype_parent to 'xyz_room' and 'xyz_exit' respectively +# prototype_parent to 'xyz_room' and 'xyz_exit' here # instead. -PARENT = { +ROOM_PARENT = { "key": "An empty room", - "prototype_key": "xyzmap_room_map1", - "typeclass": "evennia.contrib.xyzgrid.xyzroom.XYZRoom", + "prototype_key": "xyz_exit_prototype", + "prototype_parent": "xyz_room", + # "typeclass": "evennia.contrib.xyzgrid.xyzroom.XYZRoom", "desc": "An empty room.", } +EXIT_PARENT = { + "prototype_key": "xyz_exit_prototype", + "prototype_parent": "xyz_exit", + # "typeclass": "evennia.contrib.xyzgrid.xyzroom.XYZExit", + "desc": "A path to the next location.", +} + # ---------------------------------------- map1 # The large tree @@ -134,13 +142,17 @@ PROTOTYPES_MAP1 = { "desc": "These branches are wide enough to easily walk on. There's green all around." }, # directional prototypes - (3, 0, 'w'): { + (3, 0, 'e'): { "desc": "A dark passage into the underworld." }, } -for prot in PROTOTYPES_MAP1.values(): - prot['prototype_parent'] = PARENT +for key, prot in PROTOTYPES_MAP1.items(): + if len(key) == 2: + # we don't want to give exits the room typeclass! + prot['prototype_parent'] = ROOM_PARENT + else: + prot['prototype_parent'] = EXIT_PARENT XYMAP_DATA_MAP1 = { @@ -253,8 +265,12 @@ PROTOTYPES_MAP2 = { # this is required by the prototypes, but we add it all at once so we don't # need to add it to every line above -for prot in PROTOTYPES_MAP2.values(): - prot['prototype_parent'] = PARENT +for key, prot in PROTOTYPES_MAP2.items(): + if len(key) == 2: + # we don't want to give exits the room typeclass! + prot['prototype_parent'] = ROOM_PARENT + else: + prot['prototype_parent'] = EXIT_PARENT XYMAP_DATA_MAP2 = { diff --git a/evennia/contrib/xyzgrid/launchcmd.py b/evennia/contrib/xyzgrid/launchcmd.py index c69c1d26a5..b84380920d 100644 --- a/evennia/contrib/xyzgrid/launchcmd.py +++ b/evennia/contrib/xyzgrid/launchcmd.py @@ -18,9 +18,11 @@ Use `evennia xyzgrid help` for usage help. from os.path import join as pathjoin from django.conf import settings +import evennia from evennia.utils import ansi from evennia.contrib.xyzgrid.xyzgrid import get_xyzgrid + _HELP_SHORT = """ evennia xyzgrid help | list | init | add | spawn | initpath | delete [] Manages the XYZ grid. Use 'xyzgrid help