@verb #13:"_copy_prop _copy!_prop" this none this rxdo #55 @program #13:"_copy_prop _copy!_prop" this none this "Returns 1 if copy was successful." "Copy a property. Called by @copy & _move_prop." set_task_perms(caller_perms()) {object, pname, iobjstr} = args info = `property_info(object, pname) ! ANY' if (info == E_PROPNF) "SourceObject has no property called foo." $msg:mtell("noprop", object, pname) return elseif (typeof(info) == $ERR) "Can't copy someone else's -r property" player:tell(info) return elseif (iobjstr[1] == ".") "@copy me.foo to .bar" to = {object, iobjstr[2..$], "prop"} elseif (valid(iobj)) "@copy me.foo to $ref" to = {iobj, pname, "prop"} elseif (to = $code_utils:parse_propref(iobjstr)) "@copy me.foo to here.bar" if ($command_utils:object_match_failed(tobj = player:my_match_object(to[1]), to[1])) return endif to = {tobj, to[2], "prop"} elseif (iobjstr[1] == "!") "@copy me.foo to !bar" to = {object, iobjstr[2..$], "file"} elseif (to = $code_utils:parse_fileref(iobjstr)) "@copy me.foo to here!bar" if ($command_utils:object_match_failed(tobj = player:my_match_object(to[1]), to[1])) return endif to = {tobj, to[2], "file"} elseif (iobjstr[1] == ":") "@copy me.foo to :bar" to = {object, iobjstr[2..$], "verb"} elseif (to = $code_utils:parse_verbref(iobjstr)) "@copy me.foo to here:bar" if ($command_utils:object_match_failed(tobj = player:my_match_object(to[1]), to[1])) return endif to = {tobj, to[2], "verb"} else "@copy me.foo to here" iobj = player:my_match_object(iobjstr) if ($command_utils:object_match_failed(iobj, iobjstr)) return endif to = {iobj, pname, "prop"} endif "----------------------------------" "All required info has been parsed." "----------------------------------" if (to[3] == "verb") player:tell("Sorry, unable to automatically copy properties to verbs.") player:tell("For security reasons it is safer to copy and paste them yourself.") return elseif (to[3] == "file") if (verb == "_copy_prop" && to[1]:fileexists(to[2])) player:tell(to[1], "!", to[2], " already exists. Either @rmfile it, or use @copy! to overwrite it.") return endif try data = object.(pname) except v (ANY) player:tell("Reading ", object, ".", pname, " --> ", v[1]) return endtry "In most cases, we'll just toliteral the data." "The exception is a list of strings which we'll leave as they are." if (data && typeof(data) == $LIST) for line in (data) if (typeof(line) != STR) data = {toliteral(data)} break line endif endfor else data = {toliteral(data)} endif try result = to[1]:filewrite(to[2], data) except v (ANY) player:tell("Writing ", to[1], "!", to[2], " --> ", v[1]) return endtry player:tell(to[1], "!", to[2], " written.") elseif (to[3] == "prop") if (!to[1]:has_property(to[2])) if (!caller_perms().wizard) info[1] = caller_perms() endif if (E_INVARG == (e = `add_property(@to[1..2], object.(pname), info) ! ANY')) player:tell("Property is already defined on one or more descendents.") player:tell("Try @check-prop ", to[1], ".", to[2]) return elseif ($ERR == typeof(e)) player:tell("Adding ", to[1], ".", to[2], " --> ", e) return endif elseif (to[2] in $code_utils.builtin_props) player:tell("Can't set builtin properties this way.") player:tell("Use @rename for .name, @move/@eject for .location/.contents, and @chmod for .r, .w, and .f") return elseif (verb == "_copy_prop") player:tell(to[1], ".", to[2], " already exists. Either @rmprop it, or use @copy! to overwrite it.") return endif try to[1].(to[2]) = object.(pname) except v (ANY) player:tell("Copying ", object, ".", pname, " to ", to[1], ".", to[2], " --> ", v[1]) return endtry player:tell(to[1], ".", to[2], " value set.") else raise(E_VARNF, "This error can't happen!") endif return 1 "Last modified by Dax (#789) on Tue May 3 15:38:52 2005 MDT." .