Fix bug if red button demo losing cmdset after reload
This commit is contained in:
parent
789b8784d5
commit
340b979d0d
2 changed files with 7 additions and 14 deletions
|
|
@ -515,12 +515,6 @@ class CmdSet(object, metaclass=_CmdSetMeta):
|
||||||
existing ones to make a unique set.
|
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"):
|
if inherits_from(cmd, "evennia.commands.cmdset.CmdSet"):
|
||||||
# cmd is a command set so merge all commands in that set
|
# cmd is a command set so merge all commands in that set
|
||||||
# to this one. We raise a visible error if we created
|
# to this one. We raise a visible error if we created
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,9 @@ such as when closing the lid and un-blinding a character.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import random
|
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)
|
# Commands on the button (not all awailable at the same time)
|
||||||
|
|
||||||
|
|
@ -385,8 +384,7 @@ class BlindCmdSet(CmdSet):
|
||||||
|
|
||||||
def at_cmdset_creation(self):
|
def at_cmdset_creation(self):
|
||||||
"Setup the blind cmdset"
|
"Setup the blind cmdset"
|
||||||
from evennia.commands.default.general import CmdSay
|
from evennia.commands.default.general import CmdPose, CmdSay
|
||||||
from evennia.commands.default.general import CmdPose
|
|
||||||
|
|
||||||
self.add(CmdSay())
|
self.add(CmdSay())
|
||||||
self.add(CmdPose())
|
self.add(CmdPose())
|
||||||
|
|
@ -434,7 +432,7 @@ class RedButton(DefaultObject):
|
||||||
# these on the fly.
|
# these on the fly.
|
||||||
|
|
||||||
desc_closed_lid = (
|
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 = (
|
desc_open_lid = (
|
||||||
"This is a large red button, inviting yet evil-looking. "
|
"This is a large red button, inviting yet evil-looking. "
|
||||||
|
|
@ -520,7 +518,7 @@ class RedButton(DefaultObject):
|
||||||
# remove lidopen-state, if it exists
|
# remove lidopen-state, if it exists
|
||||||
self.cmdset.remove(LidOpenCmdSet)
|
self.cmdset.remove(LidOpenCmdSet)
|
||||||
# add lid-closed cmdset
|
# add lid-closed cmdset
|
||||||
self.cmdset.add(LidClosedCmdSet)
|
self.cmdset.add(LidClosedCmdSet, persistent=True)
|
||||||
|
|
||||||
if msg and self.location:
|
if msg and self.location:
|
||||||
self.location.msg_contents(msg)
|
self.location.msg_contents(msg)
|
||||||
|
|
@ -535,7 +533,7 @@ class RedButton(DefaultObject):
|
||||||
# remove lidopen-state, if it exists
|
# remove lidopen-state, if it exists
|
||||||
self.cmdset.remove(LidClosedCmdSet)
|
self.cmdset.remove(LidClosedCmdSet)
|
||||||
# add lid-open cmdset
|
# 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
|
# wait 20s then call self.to_closed_state with a message as argument
|
||||||
delay(
|
delay(
|
||||||
|
|
@ -566,6 +564,7 @@ class RedButton(DefaultObject):
|
||||||
|
|
||||||
# we don't need to remove other cmdsets, this will replace all,
|
# we don't need to remove other cmdsets, this will replace all,
|
||||||
# then restore whatever was there when it goes away.
|
# 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)
|
caller.cmdset.add(BlindCmdSet)
|
||||||
|
|
||||||
# wait 20s then call self._unblind to remove blindness effect. The
|
# wait 20s then call self._unblind to remove blindness effect. The
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue