From a8fc52c5972440cefde703cea36230b4fff86102 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 4 Oct 2020 19:50:49 +0200 Subject: [PATCH] Add intro-menu to tutorial-world --- evennia/contrib/tutorial_world/build.ev | 25 +++++++------ evennia/contrib/tutorial_world/intro_menu.py | 39 ++++++++++++++------ evennia/contrib/tutorial_world/rooms.py | 27 +++++++++++++- evennia/server/initial_setup.py | 2 +- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/evennia/contrib/tutorial_world/build.ev b/evennia/contrib/tutorial_world/build.ev index 2ecd4fd121..a980b1fece 100644 --- a/evennia/contrib/tutorial_world/build.ev +++ b/evennia/contrib/tutorial_world/build.ev @@ -105,21 +105,24 @@ tutorial # @desc |gWelcome to the Evennia tutorial-world!|n + This small quest shows some examples of Evennia usage. - To get into the mood of this miniature quest, imagine you are an - adventurer out to find fame and fortune. You have heard rumours of an - old castle ruin by the coast. In its depth a warrior princess was - buried together with her powerful magical weapon - a valuable prize, - if it's true. Of course this is a chance to adventure that you - cannot turn down! + |gDo you want help with how to play? Write |yintro|g to get an introduction to + Evennia and the basics of playing!|n - You reach the coast in the midst of a raging thunderstorm. With wind - and rain screaming in your face you stand where the moor meet the sea - along a high, rocky coast ... + To get into the mood of this miniature quest, imagine you are an adventurer + out to find fame and fortune. You have heard rumours of an old castle ruin by + the coast. In its depth a warrior princess was buried together with her + powerful magical weapon - a valuable prize, if it's true. Of course this is a + chance to adventure that you cannot turn down! -Try 'tutorial' to get behind-the-scenes help anywhere, and 'give up' -if you want to abort. + You reach the coast in the midst of a raging thunderstorm. With wind and rain + screaming in your face you stand where the moor meet the sea along a high, + rocky coast ... + +Try '|yintro|n' for usage help. During the quest, write '|ytutorial|n' to get +behind-the-scenes help anywhere, and '|ygive up|n' to abandon the quest. |gwrite 'begin' to start your quest!|n diff --git a/evennia/contrib/tutorial_world/intro_menu.py b/evennia/contrib/tutorial_world/intro_menu.py index 237587bd49..4dcb68281d 100644 --- a/evennia/contrib/tutorial_world/intro_menu.py +++ b/evennia/contrib/tutorial_world/intro_menu.py @@ -229,8 +229,11 @@ def _maintain_demo_room(caller, delete=False): # make the linking exits door_out = create_object( - "evennia.objects.objects.DefaultExit", key="Door", location=room1, - destination=room2, locks=["get:false()"], + "evennia.objects.objects.DefaultExit", + key="Door", + location=room1, + destination=room2, + locks=["get:false()"], ) door_out.db.desc = _DOOR_DESC_OUT.strip() door_in = create_object( @@ -239,7 +242,7 @@ def _maintain_demo_room(caller, delete=False): aliases=["door", "in", "entrance"], location=room2, destination=room1, - locks=["get:false()"] + locks=["get:false()"], ) door_in.db.desc = _DOOR_DESC_IN.strip() @@ -574,10 +577,9 @@ If you are alone on the server, put your own name as |w|n to test it and page yourself. Write just |ypage|n to see your latest pages. This will also show you if anyone paged you while you were offline. -(By the way - do you think that the use of |y=|n above is strange? This is a -MUSH/MUX-style of syntax. If you don't like it, you can change it for your own -game by simply changing how the |wpose|n command parses its input.) - +(By the way - depending on which games you are used to, you may think that the +use of |y=|n above is strange. This is a MUSH/MUX-style of syntax. For your own +game you can change the |wpose|n command to work however you prefer). ## OPTIONS @@ -721,7 +723,18 @@ Thanks for trying out the tutorial! """ +# ------------------------------------------------------------------------------------------- +# +# EvMenu implementation and access function +# +# ------------------------------------------------------------------------------------------- + + class TutorialEvMenu(EvMenu): + """ + Custom EvMenu for displaying the intro-menu + """ + def close_menu(self): """Custom cleanup actions when closing menu""" self.caller.cmdset.remove(DemoCommandSetHelp) @@ -743,16 +756,18 @@ class TutorialEvMenu(EvMenu): else: other.append((key, desc)) navigation = ( - (" " + " |W|||n ".join(navigation) + " |W|||n " + "|wQ|Wuit|n") - if navigation - else "" + (" " + " |W|||n ".join(navigation) + " |W|||n " + "|wQ|Wuit|n") if navigation else "" ) other = super().options_formatter(other) sep = "\n\n" if navigation and other else "" return f"{navigation}{sep}{other}" -def testmenu(caller): + +def init_menu(caller): + """ + Call to initialize the menu. + + """ menutree = parse_menu_template(caller, MENU_TEMPLATE, GOTO_CALLABLES) - # we'll use a custom EvMenu child later TutorialEvMenu(caller, menutree) diff --git a/evennia/contrib/tutorial_world/rooms.py b/evennia/contrib/tutorial_world/rooms.py index fa7840683b..16eae80a1d 100644 --- a/evennia/contrib/tutorial_world/rooms.py +++ b/evennia/contrib/tutorial_world/rooms.py @@ -385,6 +385,31 @@ SUPERUSER_WARNING = ( # # ------------------------------------------------------------- +class CmdEvenniaIntro(Command): + """ + Start the Evennia intro wizard. + + Usage: + intro + + """ + key = "intro" + + def func(self): + from .intro_menu import init_menu + # quell also superusers + if self.caller.account: + self.caller.account.execute_cmd("quell") + self.caller.msg("(Auto-quelling)") + init_menu(self.caller) + + +class CmdSetEvenniaIntro(CmdSet): + key = "Evennia Intro StartSet" + + def at_cmdset_creation(self): + self.add(CmdEvenniaIntro()) + class IntroRoom(TutorialRoom): """ @@ -404,6 +429,7 @@ class IntroRoom(TutorialRoom): "This assigns the health Attribute to " "the account." ) + self.cmdset.add(CmdSetEvenniaIntro, permanent=True) def at_object_receive(self, character, source_location): """ @@ -426,7 +452,6 @@ class IntroRoom(TutorialRoom): character.account.execute_cmd("quell") character.msg("(Auto-quelling while in tutorial-world)") - # ------------------------------------------------------------- # # Bridge - unique room diff --git a/evennia/server/initial_setup.py b/evennia/server/initial_setup.py index 67e5318973..8a6db3e2a3 100644 --- a/evennia/server/initial_setup.py +++ b/evennia/server/initial_setup.py @@ -29,7 +29,7 @@ LIMBO_DESC = _( """ Welcome to your new |wEvennia|n-based game! Visit http://www.evennia.com if you need help, want to contribute, report issues or just join the community. -As Account #1 you can create a demo/tutorial area with |w@batchcommand tutorial_world.build|n. +As Account #1 you can create a demo/tutorial area with '|wbatchcommand tutorial_world.build|n'. """ )