OBS: You need to resync your database! Moved cmdsets into the database rather than being dependent on scripts. Moved the creation of the cmdset- and cmdset-handlers into ObjectDB.__init__ rather than bootstrapping it from the typeclass. Added some more script functionality for testing, includong the @script command for assigning a script to an object.
This commit is contained in:
parent
e965830735
commit
126e2ea61f
17 changed files with 370 additions and 216 deletions
|
|
@ -750,6 +750,40 @@ class CmdLink(MuxCommand):
|
|||
# give feedback
|
||||
caller.msg(string)
|
||||
|
||||
class CmdUnLink(CmdLink):
|
||||
"""
|
||||
@unlink - unconnect objects
|
||||
|
||||
Usage:
|
||||
@unlink <Object>
|
||||
|
||||
Unlinks an object, for example an exit, disconnecting
|
||||
it from whatever it was connected to.
|
||||
"""
|
||||
# this is just a child of CmdLink
|
||||
|
||||
key = "@unlink"
|
||||
locks = "cmd:perm(unlink) or perm(Builders)"
|
||||
help_key = "Building"
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
All we need to do here is to set the right command
|
||||
and call func in CmdLink
|
||||
"""
|
||||
|
||||
caller = self.caller
|
||||
|
||||
if not self.args:
|
||||
caller.msg("Usage: @unlink <object>")
|
||||
return
|
||||
|
||||
# This mimics '@link <obj> = ' which is the same as @unlink
|
||||
self.rhs = ""
|
||||
|
||||
# call the @link functionality
|
||||
super(CmdUnLink, self).func()
|
||||
|
||||
|
||||
class CmdListCmdSets(MuxCommand):
|
||||
"""
|
||||
|
|
@ -1585,36 +1619,67 @@ class CmdTeleport(MuxCommand):
|
|||
caller.msg("Teleported.")
|
||||
|
||||
|
||||
class CmdUnLink(CmdLink):
|
||||
class CmdScript(MuxCommand):
|
||||
"""
|
||||
@unlink - unconnect objects
|
||||
attach scripts
|
||||
|
||||
Usage:
|
||||
@unlink <Object>
|
||||
@script[/switch] <obj> = <script.path or scriptkey>
|
||||
|
||||
Switches:
|
||||
start - start a previously added script
|
||||
stop - stop a previously added script
|
||||
|
||||
Unlinks an object, for example an exit, disconnecting
|
||||
it from whatever it was connected to.
|
||||
Attaches the given script to the object and starts it. Script path can be given
|
||||
from the base location for scripts as given in settings.
|
||||
If stopping/starting an already existing script, the script's key
|
||||
can be given instead (if giving a path, *all* scripts with this path
|
||||
on <obj> will be affected).
|
||||
"""
|
||||
# this is just a child of CmdLink
|
||||
|
||||
key = "@script"
|
||||
aliases = "@addscript"
|
||||
|
||||
key = "@unlink"
|
||||
locks = "cmd:perm(unlink) or perm(Builders)"
|
||||
help_key = "Building"
|
||||
locks = "cmd:perm(script) or perm(Wizards)"
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
All we need to do here is to set the right command
|
||||
and call func in CmdLink
|
||||
"""
|
||||
|
||||
caller = self.caller
|
||||
|
||||
if not self.args:
|
||||
caller.msg("Usage: @unlink <object>")
|
||||
return
|
||||
"Do stuff"
|
||||
|
||||
# This mimics '@link <obj> = ' which is the same as @unlink
|
||||
self.rhs = ""
|
||||
caller = self.caller
|
||||
|
||||
if not self.rhs:
|
||||
string = "Usage: @script[/switch] <obj> = <script.path or script key>"
|
||||
caller.msg(string)
|
||||
return
|
||||
|
||||
# call the @link functionality
|
||||
super(CmdUnLink, self).func()
|
||||
inp = self.rhs
|
||||
if not inp.startswith('src.') and not inp.startswith('game.'):
|
||||
# append the default path.
|
||||
inp = "%s.%s" % (settings.BASE_SCRIPT_PATH, inp)
|
||||
|
||||
obj = caller.search(self.lhs)
|
||||
if not obj:
|
||||
return
|
||||
string = ""
|
||||
if "stop" in self.switches:
|
||||
# we are stopping an already existing script
|
||||
ok = obj.scripts.stop(inp)
|
||||
if not ok:
|
||||
string = "Script %s could not be stopped. Does it exist?" % inp
|
||||
else:
|
||||
string = "Script stopped and removed from object."
|
||||
if "start" in self.switches:
|
||||
# we are starting an already existing script
|
||||
ok = obj.scripts.start(inp)
|
||||
if not ok:
|
||||
string = "Script %s could not be (re)started." % inp
|
||||
else:
|
||||
string = "Script started successfully."
|
||||
if not self.switches:
|
||||
# adding a new script, and starting it
|
||||
ok = obj.scripts.add(inp, autostart=True)
|
||||
if not ok:
|
||||
string = "Script %s could not be added." % inp
|
||||
else:
|
||||
string = "Script successfully added and started."
|
||||
caller.msg(string)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ class DefaultCmdSet(CmdSet):
|
|||
self.add(building.CmdExamine())
|
||||
self.add(building.CmdTypeclass())
|
||||
self.add(building.CmdLock())
|
||||
self.add(building.CmdScript())
|
||||
|
||||
# Comm commands
|
||||
self.add(comms.CmdAddCom())
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ class CmdPy(MuxCommand):
|
|||
Usage:
|
||||
@py <cmd>
|
||||
|
||||
In this limited python environment.
|
||||
In this limited python environment, there are a
|
||||
few variables made available to give access to
|
||||
the system.
|
||||
|
||||
available_vars: 'self','me' : caller
|
||||
'here' : caller.location
|
||||
|
|
@ -82,7 +84,7 @@ class CmdPy(MuxCommand):
|
|||
'ConfigValue' ConfigValue class
|
||||
only two
|
||||
variables are defined: 'self'/'me' which refers to one's
|
||||
own object, and 'here' which refers to the current
|
||||
own object, and 'here' which refers to self's current
|
||||
location.
|
||||
"""
|
||||
key = "@py"
|
||||
|
|
@ -102,10 +104,11 @@ class CmdPy(MuxCommand):
|
|||
return
|
||||
# create temporary test objects for playing with
|
||||
script = create.create_script("src.scripts.scripts.DoNothing",
|
||||
'testscript')
|
||||
key = 'testscript')
|
||||
obj = create.create_object("src.objects.objects.Object",
|
||||
'testobject')
|
||||
key='testobject')
|
||||
conf = ConfigValue() # used to access conf values
|
||||
|
||||
available_vars = {'self':caller,
|
||||
'me':caller,
|
||||
'here':caller.location,
|
||||
|
|
@ -131,7 +134,10 @@ class CmdPy(MuxCommand):
|
|||
ret = "\n".join("<<< %s" % line for line in errlist if line)
|
||||
caller.msg(ret)
|
||||
obj.delete()
|
||||
script.delete()
|
||||
try:
|
||||
script.delete()
|
||||
except AssertionError: # this is a strange thing; the script looses its id somehow..?
|
||||
pass
|
||||
|
||||
class CmdScripts(MuxCommand):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue