From 340b979d0dc9b78625c4d3a6a5e5dcde40ee8686 Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 7 Nov 2022 23:37:23 +0100 Subject: [PATCH] Fix bug if red button demo losing cmdset after reload --- evennia/commands/cmdset.py | 6 ------ .../contrib/tutorials/red_button/red_button.py | 15 +++++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/evennia/commands/cmdset.py b/evennia/commands/cmdset.py index ad30ee2d70..863d754151 100644 --- a/evennia/commands/cmdset.py +++ b/evennia/commands/cmdset.py @@ -515,12 +515,6 @@ class CmdSet(object, metaclass=_CmdSetMeta): existing ones to make a unique set. """ - if hasattr(cmd, "key") and (cmd.key in ("say", "whisper")): - from evennia.utils import calledby - - print(calledby(2)) - print(f"cmdset.add {cmd.__class__}") - if inherits_from(cmd, "evennia.commands.cmdset.CmdSet"): # cmd is a command set so merge all commands in that set # to this one. We raise a visible error if we created diff --git a/evennia/contrib/tutorials/red_button/red_button.py b/evennia/contrib/tutorials/red_button/red_button.py index 28689fa015..51ee69060f 100644 --- a/evennia/contrib/tutorials/red_button/red_button.py +++ b/evennia/contrib/tutorials/red_button/red_button.py @@ -32,10 +32,9 @@ such as when closing the lid and un-blinding a character. """ import random -from evennia import DefaultObject -from evennia import Command, CmdSet -from evennia.utils.utils import delay, repeat, interactive +from evennia import CmdSet, Command, DefaultObject +from evennia.utils.utils import delay, interactive, repeat # Commands on the button (not all awailable at the same time) @@ -385,8 +384,7 @@ class BlindCmdSet(CmdSet): def at_cmdset_creation(self): "Setup the blind cmdset" - from evennia.commands.default.general import CmdSay - from evennia.commands.default.general import CmdPose + from evennia.commands.default.general import CmdPose, CmdSay self.add(CmdSay()) self.add(CmdPose()) @@ -434,7 +432,7 @@ class RedButton(DefaultObject): # these on the fly. desc_closed_lid = ( - "This is a large red button, inviting yet evil-looking. " "A closed glass lid protects it." + "This is a large red button, inviting yet evil-looking. A closed glass lid protects it." ) desc_open_lid = ( "This is a large red button, inviting yet evil-looking. " @@ -520,7 +518,7 @@ class RedButton(DefaultObject): # remove lidopen-state, if it exists self.cmdset.remove(LidOpenCmdSet) # add lid-closed cmdset - self.cmdset.add(LidClosedCmdSet) + self.cmdset.add(LidClosedCmdSet, persistent=True) if msg and self.location: self.location.msg_contents(msg) @@ -535,7 +533,7 @@ class RedButton(DefaultObject): # remove lidopen-state, if it exists self.cmdset.remove(LidClosedCmdSet) # add lid-open cmdset - self.cmdset.add(LidOpenCmdSet) + self.cmdset.add(LidOpenCmdSet, persistent=True) # wait 20s then call self.to_closed_state with a message as argument delay( @@ -566,6 +564,7 @@ class RedButton(DefaultObject): # we don't need to remove other cmdsets, this will replace all, # then restore whatever was there when it goes away. + # we don't make this persistent, to make sure any problem is just a reload away caller.cmdset.add(BlindCmdSet) # wait 20s then call self._unblind to remove blindness effect. The