Working on getting command tables implemented on individual objects. It's probably not a good idea to update to this revision in a 'production' environment yet.
This commit is contained in:
parent
6ca32cd5e0
commit
df69011134
6 changed files with 115 additions and 20 deletions
|
|
@ -289,10 +289,7 @@ def cmd_examine(command):
|
|||
source_object.emit_to("Desc: %s" % target_obj.get_description(no_parsing=True))
|
||||
source_object.emit_to("Owner: %s " % (target_obj.get_owner(),))
|
||||
source_object.emit_to("Zone: %s" % (target_obj.get_zone(),))
|
||||
|
||||
parent_str = target_obj.script_parent
|
||||
if parent_str and parent_str != '':
|
||||
source_object.emit_to("Parent: %s " % (parent_str,))
|
||||
source_object.emit_to("Parent: %s " % target_obj.get_script_parent())
|
||||
|
||||
for attribute in target_obj.get_all_attributes():
|
||||
source_object.emit_to(attribute.get_attrline())
|
||||
|
|
|
|||
|
|
@ -30,19 +30,64 @@ def show_cached_scripts(command):
|
|||
retval += "%d cached parents" % len(cache_dict)
|
||||
command.source_object.emit_to(retval)
|
||||
|
||||
def cmd_parent(command):
|
||||
def cmd_scriptcache(command):
|
||||
"""
|
||||
Figure out what form of the command the user is using and branch off
|
||||
accordingly.
|
||||
"""
|
||||
if "showcache" in command.command_switches:
|
||||
if "show" in command.command_switches:
|
||||
show_cached_scripts(command)
|
||||
return
|
||||
|
||||
if "clearcache" in command.command_switches:
|
||||
if "clear" in command.command_switches:
|
||||
clear_cached_scripts(command)
|
||||
return
|
||||
|
||||
command.source_object.emit_to("Must be specified with one of the following switches: showcache, clearcache")
|
||||
command.source_object.emit_to("Must be specified with one of the following switches: show, clear")
|
||||
GLOBAL_CMD_TABLE.add_command("@scriptcache", cmd_scriptcache,
|
||||
priv_tuple=("genperms.builder"))
|
||||
|
||||
def cmd_parent(command):
|
||||
"""
|
||||
Sets an object's script parent.
|
||||
"""
|
||||
source_object = command.source_object
|
||||
|
||||
if not command.command_argument:
|
||||
source_object.emit_to("Change the parent of what?")
|
||||
return
|
||||
|
||||
eq_args = command.command_argument.split('=', 1)
|
||||
target_name = eq_args[0]
|
||||
parent_name = eq_args[1]
|
||||
|
||||
if len(target_name) == 0:
|
||||
source_object.emit_to("Change the parent of what?")
|
||||
return
|
||||
|
||||
if len(eq_args) > 1:
|
||||
target_obj = source_object.search_for_object(target_name)
|
||||
# Use search_for_object to handle duplicate/nonexistant results.
|
||||
if not target_obj:
|
||||
return
|
||||
|
||||
if not source_object.controls_other(target_obj):
|
||||
source_object.emit_to(defines_global.NOCONTROL_MSG)
|
||||
return
|
||||
|
||||
# Allow the clearing of a zone
|
||||
if parent_name.lower() == "none":
|
||||
target_obj.set_script_parent(None)
|
||||
source_object.emit_to("%s reverted to default parent." % (target_obj))
|
||||
return
|
||||
|
||||
target_obj.set_script_parent(parent_name)
|
||||
source_object.emit_to("%s is now a child of %s." % (target_obj, parent_name))
|
||||
|
||||
else:
|
||||
# We haven't provided a target zone.
|
||||
source_object.emit_to("What should the object's parent be set to?")
|
||||
return
|
||||
GLOBAL_CMD_TABLE.add_command("@parent", cmd_parent,
|
||||
priv_tuple=("genperms.builder")),
|
||||
priv_tuple=("genperms.builder"))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue