Make script obj= required for targeting obj-based scripts. Resolve #3096
This commit is contained in:
parent
f250a3e7ce
commit
328ddf9936
4 changed files with 78 additions and 55 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Main branch (git)
|
## Main branch (git)
|
||||||
|
|
||||||
|
- Bug fix: Change so `script obj = [scriptname|id]` is required to manipulate scripts
|
||||||
|
on objects; `script scriptname|id` only works on global scripts.
|
||||||
- Doc: Add warning about `Django-wiki` (in wiki tutorial) only supporting Django <4.0.
|
- Doc: Add warning about `Django-wiki` (in wiki tutorial) only supporting Django <4.0.
|
||||||
- Doc: Expanded `XYZGrid` docstring to clarify `MapLink` class will not itself
|
- Doc: Expanded `XYZGrid` docstring to clarify `MapLink` class will not itself
|
||||||
spawn anything, children must define their prototypes explicitly.
|
spawn anything, children must define their prototypes explicitly.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Main branch (git)
|
## Main branch (git)
|
||||||
|
|
||||||
|
- Bug fix: Change so `script obj = [scriptname|id]` is required to manipulate scripts
|
||||||
|
on objects; `script scriptname|id` only works on global scripts.
|
||||||
- Doc: Add warning about `Django-wiki` (in wiki tutorial) only supporting Django <4.0.
|
- Doc: Add warning about `Django-wiki` (in wiki tutorial) only supporting Django <4.0.
|
||||||
- Doc: Expanded `XYZGrid` docstring to clarify `MapLink` class will not itself
|
- Doc: Expanded `XYZGrid` docstring to clarify `MapLink` class will not itself
|
||||||
spawn anything, children must define their prototypes explicitly.
|
spawn anything, children must define their prototypes explicitly.
|
||||||
|
|
|
||||||
|
|
@ -3304,8 +3304,8 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
||||||
scripts.
|
scripts.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
script[/switches] [script-#dbref, key, script.path or <obj>]
|
script[/switches] [script-#dbref, key, script.path]
|
||||||
script[/start||stop] <obj> = <script.path or script-key>
|
script[/start||stop] <obj> = [<script.path or script-key>]
|
||||||
|
|
||||||
Switches:
|
Switches:
|
||||||
start - start/unpause an existing script's timer.
|
start - start/unpause an existing script's timer.
|
||||||
|
|
@ -3314,19 +3314,21 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
||||||
delete - deletes script. This will also stop the timer as needed
|
delete - deletes script. This will also stop the timer as needed
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
script - list scripts
|
script - list all scripts
|
||||||
script myobj - list all scripts on object
|
script foo.bar.Script - create a new global Script
|
||||||
script foo.bar.Script - create a new global Script
|
script/pause foo.bar.Script - pause global script
|
||||||
script scriptname - examine named existing global script
|
script scriptname|#dbref - examine named existing global script
|
||||||
script myobj = foo.bar.Script - create and assign script to object
|
script/delete #dbref[-#dbref] - delete script or range by #dbref
|
||||||
script/stop myobj = scriptname - stop script on object
|
|
||||||
script/pause foo.Bar.Script - pause global script
|
script myobj = - list all scripts on object
|
||||||
script/delete myobj - delete ALL scripts on object
|
script myobj = foo.bar.Script - create and assign script to object
|
||||||
script/delete #dbref[-#dbref] - delete script or range by dbref
|
script/stop myobj = name|#dbref - stop named script on object
|
||||||
|
script/delete myobj = name|#dbref - delete script on object
|
||||||
|
script/delete myobj = - delete ALL scripts on object
|
||||||
|
|
||||||
When given with an `<obj>` as left-hand-side, this creates and
|
When given with an `<obj>` as left-hand-side, this creates and
|
||||||
assigns a new script to that object. Without an `<obj>`, this
|
assigns a new script to that object. Without an `<obj>`, this
|
||||||
manages and inspects global scripts
|
manages and inspects global scripts.
|
||||||
|
|
||||||
If no switches are given, this command just views all active
|
If no switches are given, this command just views all active
|
||||||
scripts. The argument can be either an object, at which point it
|
scripts. The argument can be either an object, at which point it
|
||||||
|
|
@ -3403,11 +3405,16 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
||||||
if self.rhs:
|
if self.rhs:
|
||||||
obj_query = self.lhs
|
obj_query = self.lhs
|
||||||
script_query = self.rhs
|
script_query = self.rhs
|
||||||
|
elif self.rhs is not None:
|
||||||
|
# an empty "="
|
||||||
|
obj_query = self.lhs
|
||||||
|
script_query = None
|
||||||
else:
|
else:
|
||||||
obj_query = script_query = self.args
|
obj_query = None
|
||||||
|
script_query = self.args
|
||||||
|
|
||||||
scripts = self._search_script(script_query)
|
scripts = self._search_script(script_query) if script_query else None
|
||||||
objects = caller.search(obj_query, quiet=True)
|
objects = caller.search(obj_query, quiet=True) if obj_query else None
|
||||||
obj = objects[0] if objects else None
|
obj = objects[0] if objects else None
|
||||||
|
|
||||||
if not self.switches:
|
if not self.switches:
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,6 @@ from unittest.mock import MagicMock, Mock, patch
|
||||||
from anything import Anything
|
from anything import Anything
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
from parameterized import parameterized
|
|
||||||
from twisted.internet import task
|
|
||||||
|
|
||||||
from evennia import (
|
from evennia import (
|
||||||
DefaultCharacter,
|
DefaultCharacter,
|
||||||
DefaultExit,
|
DefaultExit,
|
||||||
|
|
@ -41,6 +38,8 @@ from evennia.server.sessionhandler import SESSIONS
|
||||||
from evennia.utils import create, gametime, utils
|
from evennia.utils import create, gametime, utils
|
||||||
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
|
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
|
||||||
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest
|
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest
|
||||||
|
from parameterized import parameterized
|
||||||
|
from twisted.internet import task
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Command testing
|
# Command testing
|
||||||
|
|
@ -199,33 +198,41 @@ class TestHelp(BaseEvenniaCommandTest):
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"test", # main help entry
|
"test", # main help entry
|
||||||
"Help for test\n\n"
|
(
|
||||||
"Main help text\n\n"
|
"Help for test\n\n"
|
||||||
"Subtopics:\n"
|
"Main help text\n\n"
|
||||||
" test/creating extra stuff"
|
"Subtopics:\n"
|
||||||
" test/something else"
|
" test/creating extra stuff"
|
||||||
" test/more",
|
" test/something else"
|
||||||
|
" test/more"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/creating extra stuff", # subtopic, full match
|
"test/creating extra stuff", # subtopic, full match
|
||||||
"Help for test/creating extra stuff\n\n"
|
(
|
||||||
"Help on creating extra stuff.\n\n"
|
"Help for test/creating extra stuff\n\n"
|
||||||
"Subtopics:\n"
|
"Help on creating extra stuff.\n\n"
|
||||||
" test/creating extra stuff/subsubtopic\n",
|
"Subtopics:\n"
|
||||||
|
" test/creating extra stuff/subsubtopic\n"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/creating", # startswith-match
|
"test/creating", # startswith-match
|
||||||
"Help for test/creating extra stuff\n\n"
|
(
|
||||||
"Help on creating extra stuff.\n\n"
|
"Help for test/creating extra stuff\n\n"
|
||||||
"Subtopics:\n"
|
"Help on creating extra stuff.\n\n"
|
||||||
" test/creating extra stuff/subsubtopic\n",
|
"Subtopics:\n"
|
||||||
|
" test/creating extra stuff/subsubtopic\n"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/extra", # partial match
|
"test/extra", # partial match
|
||||||
"Help for test/creating extra stuff\n\n"
|
(
|
||||||
"Help on creating extra stuff.\n\n"
|
"Help for test/creating extra stuff\n\n"
|
||||||
"Subtopics:\n"
|
"Help on creating extra stuff.\n\n"
|
||||||
" test/creating extra stuff/subsubtopic\n",
|
"Subtopics:\n"
|
||||||
|
" test/creating extra stuff/subsubtopic\n"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/extra/subsubtopic", # partial subsub-match
|
"test/extra/subsubtopic", # partial subsub-match
|
||||||
|
|
@ -242,19 +249,23 @@ class TestHelp(BaseEvenniaCommandTest):
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/More/Second-more",
|
"test/More/Second-more",
|
||||||
"Help for test/more/second-more\n\n"
|
(
|
||||||
"The Second More text.\n\n"
|
"Help for test/more/second-more\n\n"
|
||||||
"Subtopics:\n"
|
"The Second More text.\n\n"
|
||||||
" test/more/second-more/more again"
|
"Subtopics:\n"
|
||||||
" test/more/second-more/third more",
|
" test/more/second-more/more again"
|
||||||
|
" test/more/second-more/third more"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/More/-more", # partial match
|
"test/More/-more", # partial match
|
||||||
"Help for test/more/second-more\n\n"
|
(
|
||||||
"The Second More text.\n\n"
|
"Help for test/more/second-more\n\n"
|
||||||
"Subtopics:\n"
|
"The Second More text.\n\n"
|
||||||
" test/more/second-more/more again"
|
"Subtopics:\n"
|
||||||
" test/more/second-more/third more",
|
" test/more/second-more/more again"
|
||||||
|
" test/more/second-more/third more"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"test/more/second/more again",
|
"test/more/second/more again",
|
||||||
|
|
@ -1506,7 +1517,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(building.CmdFind(), f"=#{id1}-{id2}", f"{mdiff} Matches(#{id1}-#{id2}):")
|
self.call(building.CmdFind(), f"=#{id1}-{id2}", f"{mdiff} Matches(#{id1}-#{id2}):")
|
||||||
|
|
||||||
def test_script(self):
|
def test_script(self):
|
||||||
self.call(building.CmdScripts(), "Obj", "No scripts defined on Obj")
|
self.call(building.CmdScripts(), "Obj =", "No scripts defined on Obj")
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdScripts(),
|
building.CmdScripts(),
|
||||||
"Obj = scripts.scripts.DefaultScript",
|
"Obj = scripts.scripts.DefaultScript",
|
||||||
|
|
@ -1518,12 +1529,12 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
"evennia.scripts.scripts.DoNothing",
|
"evennia.scripts.scripts.DoNothing",
|
||||||
"Global Script Created - sys_do_nothing ",
|
"Global Script Created - sys_do_nothing ",
|
||||||
)
|
)
|
||||||
self.call(building.CmdScripts(), "Obj ", "dbref ")
|
self.call(building.CmdScripts(), "Obj =", "dbref ")
|
||||||
|
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdScripts(), "/start Obj", "Script on Obj Started "
|
building.CmdScripts(), "/start Obj = ", "Script on Obj Started "
|
||||||
) # we allow running start again; this should still happen
|
) # we allow running start again; this should still happen
|
||||||
self.call(building.CmdScripts(), "/stop Obj", "Script on Obj Stopped - ")
|
self.call(building.CmdScripts(), "/stop Obj =", "Script on Obj Stopped - ")
|
||||||
|
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdScripts(),
|
building.CmdScripts(),
|
||||||
|
|
@ -1586,9 +1597,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdTeleport(),
|
building.CmdTeleport(),
|
||||||
"Obj = Room2",
|
"Obj = Room2",
|
||||||
"Obj(#{}) is leaving Room(#{}), heading for Room2(#{}).|Teleported Obj -> Room2.".format(
|
"Obj(#{}) is leaving Room(#{}), heading for Room2(#{}).|Teleported Obj -> Room2."
|
||||||
oid, rid, rid2
|
.format(oid, rid, rid2),
|
||||||
),
|
|
||||||
)
|
)
|
||||||
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
||||||
self.call(
|
self.call(
|
||||||
|
|
@ -1704,7 +1714,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
|
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
|
||||||
"'key':'goblin', 'location':'%s'}" % spawnLoc.dbref,
|
"'key':'goblin', 'location':'%s'}"
|
||||||
|
% spawnLoc.dbref,
|
||||||
"Spawned goblin",
|
"Spawned goblin",
|
||||||
)
|
)
|
||||||
goblin = get_object(self, "goblin")
|
goblin = get_object(self, "goblin")
|
||||||
|
|
@ -1752,7 +1763,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdSpawn(),
|
building.CmdSpawn(),
|
||||||
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
|
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
|
||||||
" 'location':'%s'}" % spawnLoc.dbref,
|
" 'location':'%s'}"
|
||||||
|
% spawnLoc.dbref,
|
||||||
"Spawned Ball",
|
"Spawned Ball",
|
||||||
)
|
)
|
||||||
ball = get_object(self, "Ball")
|
ball = get_object(self, "Ball")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue