mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Allow scripts command to operate on range dbrefs. Resolve #2397.
This commit is contained in:
parent
e70337b6d2
commit
7b014f0fa0
2 changed files with 26 additions and 1 deletions
|
|
@ -3129,6 +3129,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
script/stop myobj = scriptname - stop script on object
|
||||
script/pause foo.Bar.Script - pause global script
|
||||
script/delete myobj - delete ALL scripts on object
|
||||
script/delete #dbref[-#dbref] - delete script or range by dbref
|
||||
|
||||
When given with an `<obj>` as left-hand-side, this creates and
|
||||
assigns a new script to that object. Without an `<obj>`, this
|
||||
|
|
@ -3170,6 +3171,13 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
scripts = ScriptDB.objects.filter(db_typeclass_path__iendswith=args)
|
||||
if scripts:
|
||||
return scripts
|
||||
if "-" in args:
|
||||
# may be a dbref-range
|
||||
val1, val2 = (dbref(part.strip()) for part in args.split('-', 1))
|
||||
if val1 and val2:
|
||||
scripts = ScriptDB.objects.filter(id__in=(range(val1, val2 + 1)))
|
||||
if scripts:
|
||||
return scripts
|
||||
|
||||
def func(self):
|
||||
"""implement method"""
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ from evennia.commands.default.muxcommand import MuxCommand
|
|||
from evennia.commands.command import Command, InterruptCommand
|
||||
from evennia.commands import cmdparser
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.utils import ansi, utils, gametime
|
||||
from evennia.utils import ansi, utils, gametime, create
|
||||
from evennia.server.sessionhandler import SESSIONS
|
||||
from evennia import search_object
|
||||
from evennia import DefaultObject, DefaultCharacter
|
||||
|
|
@ -1728,6 +1728,23 @@ class TestBuilding(EvenniaCommandTest):
|
|||
"Global Script Deleted -"
|
||||
)
|
||||
|
||||
def test_script_multi_delete(self):
|
||||
|
||||
script1 = create.create_script()
|
||||
script2 = create.create_script()
|
||||
script3 = create.create_script()
|
||||
|
||||
self.call(
|
||||
building.CmdScripts(),
|
||||
"/delete #{}-#{}".format(script1.id, script3.id),
|
||||
"Global Script Deleted - #2 (evennia.scripts.scripts.DefaultScript)|"
|
||||
"Global Script Deleted - #3 (evennia.scripts.scripts.DefaultScript)|"
|
||||
"Global Script Deleted - #4 (evennia.scripts.scripts.DefaultScript)",
|
||||
inputs=["y"]
|
||||
)
|
||||
self.assertFalse(script1.pk)
|
||||
self.assertFalse(script2.pk)
|
||||
self.assertFalse(script3.pk)
|
||||
|
||||
def test_teleport(self):
|
||||
oid = self.obj1.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue