Switch to edit mode.
Name(s): @dump 2dump1: "@dump something [with [id=...] [noprops] [noverbs] [create]]"
2: "This spills out all properties and verbs on an object, calling suspend at appropriate intervals."
3: " id=#nnn -- specifies an idnumber to use in place of the object's actual id (for porting to another MOO)"
4: " noprops -- don't show properties."
5: " noverbs -- don't show verbs."
6: " create -- indicates that a @create command should be generated and all of the verbs be introduced with @verb rather than @args; the default assumption is that the object already exists and you're just doing this to have a look at it."
7: " owner=#n - Uses #n in place of the actual owner (in case you're not actually going to be creating the object for yourself)."
8: " wiz=#nn -- Uses #nn in place of the actual owner of any wiz-permed verbs on the object, that are not owned by the object's owner."
9: "nonwiz=#n - Uses #n in place of the actual owner of any non-wiz-permed verbs on the object, that are not owned by the object's owner."
10: "no_oflags - ignore any 'o' permissions that may appear on any of the verbs."
11: " nohold -- Do not enable output stream locking while the dump is in progress (?)"
12: if (player != this)
13: return $msg:mtell("huh")
14: endif
15: set_task_perms(this)
16: "dobj = player:my_match_object(dobjstr);"
17: "lazy object matching ($match_object)"
18: if ($command_utils:object_match_failed(dobj, dobjstr))
19: return
20: elseif (prepstr && prepstr != "with")
21: return player:tell("Usage: ", verb, " something [with [id=...] [noprops] [noverbs] [create]]")
22: endif
23: player:tell("Compiling @dump...")
24: {text, targname, options, create, o_flags, owner, nogag, explicit, wiztargname, nonwiztargname} = {{}, tostr(dobj), {"props", "verbs"}, 0, 1, tostr(dobj.owner), 0, 0, $hacker, $hacker}
25: if (iobjstr)
26: for o in ($string_utils:explode(iobjstr))
27: if (index(o, "id=") == 1)
28: targname = o[4..$]
29: elseif (index(o, "owner=") == 1)
30: owner = o[7..$]
31: elseif (o in {"noprops", "noverbs"})
32: options = setremove(options, o[3..$])
33: elseif (o in {"create"})
34: create = 1
35: elseif (o in {"nogag"})
36: nogag = 1
37: elseif (o in {"explicit"})
38: explicit = 1
39: elseif (o in {"no_oflag"})
40: o_flags = 0
41: elseif (index(o, "wiz=") == 1)
42: wiztargname = o[5..$]
43: elseif (index(o, "nonwiz=") == 1)
44: nonwiztargname = o[8..$]
45: endif
46: endfor
47: endif
48: if (create)
49: parent = parent(dobj)
50: pstring = tostr(parent)
51: for p in ($all_properties())
52: if (`#0.(p) == parent ! E_PERM => 0')
53: pstring = "$" + p
54: endif
55: endfor
56: text = {@text, tostr("@create ", pstring, " named ", dobj.name, ":", $string_utils:from_list(dobj.aliases, ","))}
57: endif
58: if (filelist = `dobj:filelist() ! E_PERM => {"E_PERM (Permission denied)"}')
59: text = {@text, tostr(";\"Files in off-line dir: ", $string_utils:english_list(filelist), "\"")}
60: endif
61: for p in ("props" in options ? properties(dobj) | {})
62: pquoted = toliteral(p)
63: info = property_info(dobj, p)
64: value = dobj.(p)
65: if (create)
66: uvalue = typeof(value) == $LIST ? "{}" | 0
67: text = {@text, tostr("@prop ", targname, ".", pquoted, " ", uvalue || toliteral(value), " ", info[2] || "\"\"", info[1] == dobj.owner && !explicit ? "" | (info[1] == dobj.owner ? tostr(" ", owner) | `info[1].wizard ? tostr(" ", wiztargname || owner) | tostr(" ", nonwiztargname || owner) ! E_VARNF => tostr(" ", owner)'))}
68: if (uvalue && value)
69: text = {@text, tostr(";;", targname, ".(", pquoted, ") = ", toliteral(value))}
70: endif
71: else
72: if (info[2] != "rc")
73: text = {@text, tostr("@chmod ", targname, ".", pquoted, " ", info[2])}
74: endif
75: if (info[1] != dobj.owner)
76: text = {@text, tostr("@chown ", targname, ".", pquoted, " to ", info[1])}
77: endif
78: text = {@text, tostr(";;", targname, ".(", pquoted, ") = ", toliteral(value))}
79: endif
80: $command_utils:suspend_if_needed()
81: endfor
82: for a in ("props" in options ? $object_utils:ancestors(dobj) | {})
83: for p in (properties(a))
84: $command_utils:suspend_if_needed()
85: pquoted = toliteral(p)
86: "Error catching added by Amuck 20/01/2008"
87: value = `dobj.(p) ! ANY'
88: avalue = `a.(p) ! ANY'
89: if (typeof(value) == $ERR)
90: text = {@text, tostr("\"", targname, ".(", pquoted, ") => ", $code_utils:error_name(value), " (", value, ")")}
91: elseif (typeof(avalue) == $ERR || !is_clear_property(dobj, p))
92: text = {@text, tostr(";;", targname, ".(", pquoted, ") = ", toliteral(value))}
93: endif
94: endfor
95: $command_utils:suspend_if_needed()
96: endfor
97: if ("verbs" in options)
98: text = {@text, ""}
99: v = 1
100: while ((info = `verb_info(dobj, v) ! ANY') || info == E_PERM)
101: suspend(0)
102: if (typeof(info) == $ERR)
103: text = {@text, tostr("\"", dobj, ":", v, " --- ", info, "\";")}
104: else
105: if (i = index(vname = info[3], " "))
106: vname = vname[1..i - 1]
107: endif
108: if (vname[1] != "*")
109: vname = strsub(vname, "*", "")
110: endif
111: args = verb_args(dobj, v)
112: prep = args[2] in {"any", "none"} ? args[2] | $code_utils:short_prep(args[2])
113: perms = info[2] != (args == {"this", "none", "this"} ? "rxo" | "ro") ? info[2] || "\"\"" | (explicit ? info[2] | "")
114: " perms = o_verbs ? perms | (y = index(perms, \"o\") ? perms[1..y - 1] | perms);"
115: "Fixed by Amuck 20/01/2008"
116: vown = info[1] == dobj.owner ? owner | (info[1].wizard ? wiztargname | nonwiztargname)
117: vown = vown == E_VARNF ? info[1] | vown
118: if (create)
119: if (info[1] == dobj.owner && !explicit)
120: tail = perms ? tostr(" ", perms) | ""
121: else
122: tail = tostr(" ", perms || info[2], " ", vown)
123: endif
124: text = {@text, tostr("@verb ", targname, ":\"", info[3], "\" ", args[1], " ", prep, " ", args[3], tail)}
125: else
126: text = {@text, tostr("@args ", targname, ":\"", info[3], "\" ", args[1], " ", prep, " ", args[3])}
127: if (info[1] != dobj.owner)
128: text = {@text, tostr("@chown ", targname, ":", vname, " to ", info[1])}
129: endif
130: if (perms)
131: text = {@text, tostr("@chmod ", targname, ":", vname, " ", perms)}
132: endif
133: endif
134: if (code = verb_code(dobj, v, 1, 1))
135: text = {@text, tostr("@program ", targname, ":", vname), @code, ".", ""}
136: endif
137: endif
138: v = v + 1
139: $command_utils:suspend_if_needed()
140: endwhile
141: endif
142: text = {@text, "\"***finished***"}
143: player:notify_direct_suspended(text)
144: "Last modified by whiz (#3135) on Fri Jan 23 10:35:58 2009 EST."