Complete permanent->persistent rename of cmdset kwarg for consistency

This commit is contained in:
Griatch 2021-08-06 17:16:44 +02:00
parent 6e38d0ae4c
commit a815db4ca9
20 changed files with 362 additions and 362 deletions

View file

@ -98,7 +98,7 @@ remove the latest added cmdset.
If you want the cmdset to survive a reload, you can do:
```
@py self.cmdset.add(commands.mycmdset.MyCmdSet, permanent=True)
@py self.cmdset.add(commands.mycmdset.MyCmdSet, persistent=True)
```
Or you could add the cmdset as the *default* cmdset:

View file

@ -190,7 +190,7 @@ class Mech(Object):
def at_object_creation(self):
"This is called only when object is first created"
self.cmdset.add_default(default_cmds.CharacterCmdSet)
self.cmdset.add(MechCmdSet, permanent=True)
self.cmdset.add(MechCmdSet, persistent=True)
self.locks.add("puppet:all();call:false()")
self.db.desc = "This is a huge mech. It has missiles and stuff."
```

View file

@ -126,7 +126,7 @@ class BlockingCmdSet(CmdSet):
class BlockingRoom(Room):
def at_object_creation(self):
self.cmdset.add(BlockingCmdSet, permanent=True)
self.cmdset.add(BlockingCmdSet, persistent=True)
# only share commands with players in the room that
# are NOT Builders or higher
self.locks.add("call:not perm(Builders)")

View file

@ -232,7 +232,7 @@ from evennia.utils.create import create_object
# class for our front shop room
class NPCShop(DefaultRoom):
def at_object_creation(self):
# we could also use add(ShopCmdSet, permanent=True)
# we could also use add(ShopCmdSet, persistent=True)
self.cmdset.add_default(ShopCmdSet)
self.db.storeroom = None

View file

@ -244,9 +244,9 @@ You will get the docstring you put in your Command-class.
### Making our cmdset persistent
It's getting a little annoying to have to re-add our cmdset every time we reload, right? It's simple
enough to make `echo` a _permanent_ change though:
enough to make `echo` a _persistent_ change though:
> py self.cmdset.add("commands.mycommands.MyCmdSet", permanent=True)
> py self.cmdset.add("commands.mycommands.MyCmdSet", persistent=True)
Now you can `reload` as much as you want and your code changes will be available directly without
needing to re-add the MyCmdSet again. To remove the cmdset again, do
@ -341,7 +341,7 @@ A lot of things to dissect here:
In that case, `target` will be `None` and we should just directly `return`.
- **Lines 22-23**: At this point we have a suitable target and can send our punching strings to each.
Finally we must also add this to a CmdSet. Let's add it to `MyCmdSet` which we made permanent earlier.
Finally we must also add this to a CmdSet. Let's add it to `MyCmdSet` which we made persistent earlier.
```python
# ...

View file

@ -149,7 +149,7 @@ also has many examples of objects with commands on them.
To show how this could work, let's put our 'hit' Command on our simple `sword` object from the previous section.
> self.search("sword").cmdset.add("commands.mycommands.MyCmdSet", permanent=True)
> self.search("sword").cmdset.add("commands.mycommands.MyCmdSet", persistent=True)
We find the sword (it's still in our inventory so `self.search` should be able to find it), then
add `MyCmdSet` to it. This actually adds both `hit` and `echo` to the sword, which is fine.

View file

@ -206,10 +206,10 @@ class ChargenRoom(Room):
"""
def at_object_creation(self):
"this is called only at first creation"
self.cmdset.add(ChargenCmdset, permanent=True)
self.cmdset.add(ChargenCmdset, persistent=True)
```
Note how new rooms created with this typeclass will always start with `ChargenCmdset` on themselves.
Don't forget the `permanent=True` keyword or you will lose the cmdset after a server reload. For
Don't forget the `persistent=True` keyword or you will lose the cmdset after a server reload. For
more information about [Command Sets](../../../Components/Command-Sets) and [Commands](../../../Components/Commands), see the respective
links.

View file

@ -847,7 +847,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
def delete(self, *args, **kwargs):
"""
Deletes the account permanently.
Deletes the account persistently.
Notes:
`*args` and `**kwargs` are passed on to the base delete
@ -1196,7 +1196,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
self.locks.add(lockstring)
# The ooc account cmdset
self.cmdset.add_default(_CMDSET_ACCOUNT, permanent=True)
self.cmdset.add_default(_CMDSET_ACCOUNT, persistent=True)
def at_account_creation(self):
"""

View file

@ -177,7 +177,7 @@ class CmdSet(object, metaclass=_CmdSetMeta):
# merge-stack, every cmdset in the stack must have `duplicates` set explicitly.
duplicates = None
permanent = False
persistent = False
key_mergetypes = {}
errmessage = ""
# pre-store properties to duplicate straight off
@ -187,7 +187,7 @@ class CmdSet(object, metaclass=_CmdSetMeta):
"no_exits",
"no_objs",
"no_channels",
"permanent",
"persistent",
"mergetype",
"priority",
"duplicates",
@ -357,7 +357,7 @@ class CmdSet(object, metaclass=_CmdSetMeta):
commands (str): Representation of commands in Cmdset.
"""
perm = "perm" if self.permanent else "non-perm"
perm = "perm" if self.persistent else "non-perm"
options = ", ".join([
"{}:{}".format(opt, "T" if getattr(self, opt) else "F")
for opt in ("no_exits", "no_objs", "no_channels", "duplicates")

View file

@ -305,7 +305,7 @@ class CmdSetHandler(object):
self.mergetype_stack = ["Union"]
# the subset of the cmdset_paths that are to be stored in the database
self.permanent_paths = [""]
self.persistent_paths = [""]
if init_true:
self.update(init_mode=True) # is then called from the object __init__.
@ -363,7 +363,7 @@ class CmdSetHandler(object):
Args:
init_mode (bool, optional): Used automatically right after
this handler was created; it imports all permanent cmdsets
this handler was created; it imports all persistent cmdsets
from the database.
Notes:
@ -378,7 +378,7 @@ class CmdSetHandler(object):
"""
if init_mode:
# reimport all permanent cmdsets
# reimport all persistent cmdsets
storage = self.obj.cmdset_storage
if storage:
self.cmdset_stack = []
@ -408,7 +408,7 @@ class CmdSetHandler(object):
if _IN_GAME_ERRORS:
self.obj.msg(err)
continue
cmdset.permanent = cmdset.key != "_CMDSET_ERROR"
cmdset.persistent = cmdset.key != "_CMDSET_ERROR"
self.cmdset_stack.append(cmdset)
# merge the stack into a new merged cmdset
@ -423,7 +423,7 @@ class CmdSetHandler(object):
self.mergetype_stack.append(new_current.actual_mergetype)
self.current = new_current
def add(self, cmdset, emit_to_obj=None, persistent=True, default_cmdset=False,
def add(self, cmdset, emit_to_obj=None, persistent=False, default_cmdset=False,
**kwargs):
"""
Add a cmdset to the handler, on top of the old ones, unless it
@ -465,7 +465,7 @@ class CmdSetHandler(object):
# this is (maybe) a python path. Try to import from cache.
cmdset = self._import_cmdset(cmdset)
if cmdset and cmdset.key != "_CMDSET_ERROR":
cmdset.permanent = persistent # TODO change on cmdset too
cmdset.persistent = persistent
if persistent and cmdset.key != "_CMDSET_ERROR":
# store the path permanently
storage = self.obj.cmdset_storage or [""]
@ -514,7 +514,7 @@ class CmdSetHandler(object):
# remove the default cmdset only
if self.cmdset_stack:
cmdset = self.cmdset_stack[0]
if cmdset.permanent:
if cmdset.persistent:
storage = self.obj.cmdset_storage or [""]
storage[0] = ""
self.obj.cmdset_storage = storage
@ -531,7 +531,7 @@ class CmdSetHandler(object):
if not cmdset:
# remove the last one in the stack
cmdset = self.cmdset_stack.pop()
if cmdset.permanent:
if cmdset.persistent:
storage = self.obj.cmdset_storage
storage.pop()
self.obj.cmdset_storage = storage
@ -548,12 +548,12 @@ class CmdSetHandler(object):
]
storage = []
if any(cset.permanent for cset in delcmdsets):
if any(cset.persistent for cset in delcmdsets):
# only hit database if there's need to
storage = self.obj.cmdset_storage
updated = False
for cset in delcmdsets:
if cset.permanent:
if cset.persistent:
try:
storage.remove(cset.path)
updated = True

View file

@ -162,7 +162,7 @@ def _menu_savefunc(caller, buf):
def _menu_quitfunc(caller):
caller.cmdset.add(
BuildingMenuCmdSet,
permanent=caller.ndb._building_menu and caller.ndb._building_menu.persistent or False,
persistent=caller.ndb._building_menu and caller.ndb._building_menu.persistent or False,
)
if caller.ndb._building_menu:
caller.ndb._building_menu.move(back=True)
@ -951,7 +951,7 @@ class BuildingMenu(object):
if caller.cmdset.has(BuildingMenuCmdSet):
caller.cmdset.remove(BuildingMenuCmdSet)
self.caller.cmdset.add(BuildingMenuCmdSet, permanent=self.persistent)
self.caller.cmdset.add(BuildingMenuCmdSet, persistent=self.persistent)
self.display()
def open_parent_menu(self):

View file

@ -50,7 +50,7 @@ class EvscapeRoom(EvscaperoomObject, DefaultRoom):
"total_achievements": 14,
}
self.cmdset.add(CmdSetEvScapeRoom, permanent=True)
self.cmdset.add(CmdSetEvScapeRoom, persistent=True)
self.log("Room created and log started.")

View file

@ -1550,7 +1550,7 @@ class ContribRPCharacter(DefaultCharacter, ContribRPObject):
self.db._recog_obj2regex = {}
self.db._recog_obj2recog = {}
self.cmdset.add(RPSystemCmdSet, permanent=True)
self.cmdset.add(RPSystemCmdSet, persistent=True)
# initializing sdesc
self.sdesc.add("A normal person")

View file

@ -130,4 +130,4 @@ class TalkingNPC(DefaultObject):
"This is called when object is first created."
self.db.desc = "This is a talkative NPC."
# assign the talk command to npc
self.cmdset.add_default(TalkingCmdSet, permanent=True)
self.cmdset.add_default(TalkingCmdSet, persistent=True)

View file

@ -112,7 +112,7 @@ class Mob(tut_objects.TutorialObject):
Called the first time the object is created.
We set up the base properties and flags here.
"""
self.cmdset.add(MobCmdSet, permanent=True)
self.cmdset.add(MobCmdSet, persistent=True)
# Main AI flags. We start in dead mode so we don't have to
# chase the mob around when building.
self.db.patrolling = True

View file

@ -129,7 +129,7 @@ class TutorialReadable(TutorialObject):
)
self.db.readable_text = "There is no text written on %s." % self.key
# define a command on the object.
self.cmdset.add_default(CmdSetReadable, permanent=True)
self.cmdset.add_default(CmdSetReadable, persistent=True)
# -------------------------------------------------------------
@ -195,7 +195,7 @@ class TutorialClimbable(TutorialObject):
def at_object_creation(self):
"""Called at initial creation only"""
self.cmdset.add_default(CmdSetClimbable, permanent=True)
self.cmdset.add_default(CmdSetClimbable, persistent=True)
# -------------------------------------------------------------
@ -343,7 +343,7 @@ class LightSource(TutorialObject):
# when created.
self.db.desc = "A splinter of wood with remnants of resin on it, enough for burning."
# add the Light command
self.cmdset.add_default(CmdSetLight, permanent=True)
self.cmdset.add_default(CmdSetLight, persistent=True)
def _burnout(self):
"""
@ -670,7 +670,7 @@ class CrumblingWall(TutorialObject, DefaultExit):
# exit_open is set to True.
self.locks.add("cmd:locattr(is_lit);traverse:objattr(exit_open)")
# set cmdset
self.cmdset.add(CmdSetCrumblingWall, permanent=True)
self.cmdset.add(CmdSetCrumblingWall, persistent=True)
def open_wall(self):
"""
@ -950,7 +950,7 @@ class TutorialWeapon(TutorialObject):
self.db.parry = 0.8 # parry chance
self.db.damage = 1.0
self.db.magic = False
self.cmdset.add_default(CmdSetWeapon, permanent=True)
self.cmdset.add_default(CmdSetWeapon, persistent=True)
def reset(self):
"""
@ -1148,7 +1148,7 @@ class TutorialWeaponRack(TutorialObject):
"""
called at creation
"""
self.cmdset.add_default(CmdSetWeaponRack, permanent=True)
self.cmdset.add_default(CmdSetWeaponRack, persistent=True)
self.db.rack_id = "weaponrack_1"
# these are prototype names from the prototype
# dictionary above.

View file

@ -429,7 +429,7 @@ class IntroRoom(TutorialRoom):
"This assigns the health Attribute to "
"the account."
)
self.cmdset.add(CmdSetEvenniaIntro, permanent=True)
self.cmdset.add(CmdSetEvenniaIntro, persistent=True)
def at_object_receive(self, character, source_location):
"""
@ -732,7 +732,7 @@ class BridgeRoom(WeatherRoom):
self.db.east_exit = "gate"
self.db.fall_exit = "cliffledge"
# add the cmdset on the room.
self.cmdset.add(BridgeCmdSet, permanent=True)
self.cmdset.add(BridgeCmdSet, persistent=True)
# since the default Character's at_look() will access the room's
# return_description (this skips the cmdset) when
# first entering it, we need to explicitly turn off the room
@ -957,7 +957,7 @@ class DarkRoom(TutorialRoom):
self.db.tutorial_info = "This is a room with custom command sets on itself."
# the room starts dark.
self.db.is_lit = False
self.cmdset.add(DarkCmdSet, permanent=True)
self.cmdset.add(DarkCmdSet, persistent=True)
def at_init(self):
"""
@ -1009,7 +1009,7 @@ class DarkRoom(TutorialRoom):
# noone is carrying light - darken the room
self.db.is_lit = False
self.locks.add("view:false()")
self.cmdset.add(DarkCmdSet, permanent=True)
self.cmdset.add(DarkCmdSet, persistent=True)
for char in (obj for obj in self.contents if obj.has_account):
if char.is_superuser:
char.msg("You are Superuser, so you are not affected by the dark state.")

View file

@ -1310,7 +1310,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
def at_object_delete(self):
"""
Called just before the database object is permanently
Called just before the database object is persistently
delete()d from the database. If this method returns False,
deletion is aborted.
@ -2261,7 +2261,7 @@ class DefaultCharacter(DefaultObject):
";".join(["get:false()", "call:false()"]) # noone can pick up the character
) # no commands can be called on character from outside
# add the default cmdset
self.cmdset.add_default(settings.CMDSET_CHARACTER, permanent=True)
self.cmdset.add_default(settings.CMDSET_CHARACTER, persistent=True)
def at_after_move(self, source_location, **kwargs):
"""
@ -2711,7 +2711,7 @@ class DefaultExit(DefaultObject):
if "force_init" in kwargs or not self.cmdset.has_cmdset("ExitCmdSet", must_be_default=True):
# we are resetting, or no exit-cmdset was set. Create one dynamically.
self.cmdset.add_default(self.create_exit_cmdset(self), permanent=False)
self.cmdset.add_default(self.create_exit_cmdset(self), persistent=False)
def at_init(self):
"""

View file

@ -893,7 +893,7 @@ class EvEditor:
persistent = False
# Create the commands we need
caller.cmdset.add(EvEditorCmdSet, permanent=persistent)
caller.cmdset.add(EvEditorCmdSet, persistent=persistent)
# echo inserted text back to caller
self._echo_mode = True

View file

@ -665,7 +665,7 @@ class EvMenu:
menu_cmdset = EvMenuCmdSet()
menu_cmdset.mergetype = str(cmdset_mergetype).lower().capitalize() or "Replace"
menu_cmdset.priority = int(cmdset_priority)
self.caller.cmdset.add(menu_cmdset, permanent=persistent)
self.caller.cmdset.add(menu_cmdset, persistent=persistent)
reserved_startnode_kwargs = set(("nodename", "raw_string"))
startnode_kwargs = {}