View/Edit #13:@d*isplay @s*how

Switch to edit mode.

Name(s): @d*isplay @s*how
1:   "@display <object>[.[property]]*[,[inherited_property]]*[:[verb]]*[;[inherited_verb]]*[![file]]*"
2:   "null names for properties and verbs are interpreted as meaning all of them."
3:   if (player != this)
4:     return $msg:mtell("huh")
5:   endif
6:   player:isa($guardian) || set_task_perms(player)
7:   opivuf = {{}, {}, {}, {}, {}, {}}
8:   string = ""
9:   punc = 1
10:  literal = 0
11:  argstr = $string_utils:trimr(argstr)
12:  argstr = player:input_get_raw(argstr)
13:  for jj in [1..length(argstr)]
14:    j = argstr[jj]
15:    if (literal)
16:      string = string + j
17:      literal = 0
18:    elseif (j == "\\")
19:      literal = 1
20:    elseif (j == "." && punc == 6)
21:      "File names can contain periods.  Thanks Hobbes (#9299)"
22:      string = string + j
23:    elseif (y = index(".,:;!", j))
24:      opivuf[punc] = {@opivuf[punc], string}
25:      punc = 1 + y
26:      string = ""
27:    else
28:      string = string + j
29:    endif
30:  endfor
31:  full_linelength = player:linelength() - 4
32:  opivuf[punc] = {@opivuf[punc], string}
33:  "1. Find the object"
34:  objname = opivuf[1][1]
35:  it = this:my_match_object(objname)
36:  if (!valid(it) && string == objname && (spec = $code_utils:parse_verbref(objname)))
37:    "Simple hack to allow $verbs.  spec = {'#0', 'verb'}"
38:    "Also allows $props that aren't obj numbers."
39:    if (spec[1] != "#0")
40:      return player:tell("There is a bug in @d.  Tell a wizard what you did.")
41:    elseif ($has_property(spec[2]))
42:      opivuf = {{"#0"}, {spec[2]}, {}, {}, {}}
43:      punc = 2
44:    elseif ($has_verb(spec[2]))
45:      opivuf = {{"#0"}, {}, {}, {spec[2]}, {}}
46:      punc = 4
47:    else
48:      return player:tell("No such property or verb, \"", spec[2], "\" on #0")
49:    endif
50:    string = spec[2]
51:    objname = "#0"
52:    it = #0
53:  elseif ($command_utils:object_match_failed(it, objname))
54:    return
55:  endif
56:  readable = `properties(it) ! E_PERM' != E_PERM
57:  cant = {}
58:  "3. Verify all the inherited properties."
59:  specific_prop = {}
60:  inh = {}
61:  if ("" in opivuf[3])
62:    for what in ({it, @$object_utils:ancestors(it)})
63:      if ((cache = `properties(what) ! E_PERM') != E_PERM)
64:        for x in (cache)
65:          inh = {@inh, {what, x}}
66:        endfor
67:      else
68:        cant = setadd(cant, what)
69:      endif
70:    endfor
71:    "We already have all the props."
72:    opivuf[2] = {}
73:  else
74:    specific_prop = {@specific_prop, @opivuf[3]}
75:  endif
76:  "2. Verify all the defined properties."
77:  prop = {}
78:  if ("" in opivuf[2])
79:    if (readable)
80:      prop = properties(it)
81:    else
82:      cant = setadd(cant, it)
83:    endif
84:    what = it
85:    if (!this:display_option("thisonly"))
86:      while (!prop && valid(what = parent(what)))
87:        if ((cache = `properties(what) ! E_PERM') != E_PERM)
88:          prop = cache
89:        else
90:          cant = setadd(cant, what)
91:        endif
92:      endwhile
93:    endif
94:    for n in [1..length(prop)]
95:      prop[n] = {what, prop[n]}
96:    endfor
97:  else
98:    specific_prop = {@specific_prop, @opivuf[2]}
99:  endif
100: "These properties were specifically asked for by name."
101: for x in (specific_prop)
102:   if (y = it:property_location(x))
103:     if (y[1] == it)
104:       prop = setadd(prop, {it, x})
105:     else
106:       inh = setadd(inh, {y[1], x})
107:     endif
108:   else
109:     this:notify_direct(tostr("No such property, \"", x, "\""))
110:   endif
111: endfor
112: "5. Verify all the inherited verbs."
113: specific_verb = {}
114: vrb = {}
115: if ("" in opivuf[5])
116:   for what in ({it, @it:ancestors()})
117:     if ((cache = `verbs(what) ! E_PERM') != E_PERM)
118:       for n in [1..length(cache)]
119:         vrb = setadd(vrb, {what, n})
120:       endfor
121:     else
122:       cant = setadd(cant, what)
123:     endif
124:   endfor
125:   "We already have all the verbs."
126:   opivuf[4] = {}
127: else
128:   specific_verb = {@specific_verb, @opivuf[5]}
129: endif
130: "4. Verify all the defined verbs."
131: if ("" in opivuf[4])
132:   if (readable)
133:     vrb = verbs(it)
134:   else
135:     cant = setadd(cant, it)
136:   endif
137:   what = it
138:   if (!this:display_option("thisonly"))
139:     while (!vrb && valid(what = parent(what)))
140:       if ((cache = `verbs(what) ! E_PERM') != E_PERM)
141:         vrb = cache
142:       else
143:         cant = setadd(cant, what)
144:       endif
145:     endwhile
146:   endif
147:   for n in [1..length(vrb)]
148:     vrb[n] = {what, n}
149:   endfor
150: else
151:   specific_verb = {@specific_verb, @opivuf[4]}
152: endif
153: for x in (specific_verb)
154:   if (y = it:has_verb(x))
155:     vrb = setadd(vrb, {y[1], x})
156:   else
157:     this:notify_direct(tostr("No such verb, \"", x, "\""))
158:   endif
159: endfor
160: "6. Verify all the files."
161: file = {}
162: if ("" in opivuf[6])
163:   if (readable)
164:     for x in (it:filelist())
165:       file = {@file, {it, x}}
166:     endfor
167:   else
168:     cant = setadd(cant, it)
169:   endif
170:   what = it
171: else
172:   for x in (opivuf[6])
173:     if (it:fileexists(x))
174:       file = setadd(file, {it, x})
175:     else
176:       this:notify_direct(tostr("No such file, \"", x, "\""))
177:     endif
178:   endfor
179: endif
180: "Print general information."
181: if ({""} in opivuf || opivuf[2..6] == {{}, {}, {}, {}, {}})
182:   this:tell(it.name, " (", it, ") [ ", it.r ? "readable " | "", it.f ? "fertile " | "", is_player(it) ? "(player) " | "", it.programmer ? "programmer " | "", it.wizard ? "wizard " | "", "]")
183:   if (it.owner != (is_player(it) ? it | this))
184:     this:tell("  Owned by ", valid(p = it.owner) ? p.name | "** extinct **", " (", p, ").")
185:   endif
186:   this:tell("  Child of ", valid(p = parent(it)) ? p.name | "** none **", " (", p, ").")
187:   if (it.location != $nothing)
188:     this:tell("  Location ", valid(p = it.location) ? p.name | "** unplace **", " (", p, ").")
189:   endif
190: endif
191: "Print the verbs."
192: blankargs = this:display_option("blank_tnt") ? {"this", "none", "this"} | #-1
193: for b in (vrb)
194:   $command_utils:suspend_if_needed()
195:   {where, q} = b
196:   if (typeof(q) == $STR)
197:     short = strsub(y = index(q, " ") ? q[1..y - 1] | q, "*", "")
198:   else
199:     short = q
200:   endif
201:   inf = `verb_info(where, short) ! E_PERM'
202:   if (typeof(inf) == $LIST || inf == E_PERM)
203:     name = typeof(inf) == $LIST ? inf[3] | tostr(q)
204:     name = index(name, " ") ? "\"" + name + "\"" | name
205:     nameside_size = full_linelength - 43
206:     line = $string_utils:left(tostr($string_utils:right(tostr(where), 6), ":", name[1..1] == "\"" ? "\"" + $html_utils:literal_text(name[2..$ - 1]) + "\"" | $html_utils:literal_text(name), " "), nameside_size)
207:     if (inf == E_PERM)
208:       line = line + "   ** unreadable **"
209:     else
210:       inf[2] = inf[2] + "  "
211:       inf[2][1] != "r" && (inf[2][1..0] = " ")
212:       "(inf[2][2] != \"w\") && (inf[2][2..1] = \" \");"
213:       inf[2][2] != "x" && (inf[2][2..1] = " ")
214:       inf[2][3] != "d" && (inf[2][3..2] = " ")
215:       line = $string_utils:left(tostr(line, $string_utils:nn(inf[1]), " "), nameside_size + 21) + inf[2][1..5]
216:       vargs = verb_args(where, short)
217:       if (vargs != blankargs)
218:         if (this:display_option("shortprep") && !(vargs[2] in {"any", "none"}))
219:           vargs[2] = $code_utils:short_prep(vargs[2])
220:         endif
221:         line = $string_utils:left(line + " ", nameside_size + 28) + $string_utils:from_list(vargs, " ")
222:       endif
223:     endif
224:     this:notify_direct(line)
225:   else
226:     this:tell("There is a bug in @d.  Tell a wizard what you did.")
227:   endif
228: endfor
229: "Print the props."
230: all = {@prop, @inh}
231: max = length(all) < 4 ? 999 | full_linelength - 56
232: depth = length(all) < 4 ? -1 | 1
233: truncate_owner_names = length(all) > 1
234: for b in (all)
235:   $command_utils:suspend_if_needed()
236:   {where, q} = b
237:   inf = `property_info(it, q) ! E_PERM, E_PROPNF'
238:   if (!player.wizard && (typeof(inf) == $LIST && inf[1].wizard) && !index(inf[2], "r"))
239:     "Guardians may see -r props, but not if they are wiz owned."
240:     inf = E_PERM
241:   endif
242:   if (inf == E_PROPNF)
243:     if (q in $code_utils.builtin_props)
244:       prop_data = it.(q)
245:       this:notify_direct(tostr($string_utils:left("," + q, 25), "Built in property            ", length(y = $string_utils:from_value(prop_data, 1, depth)) > max ? y[1..max] + ".." | y))
246:     else
247:       this:tell("There is a bug in @d.  Tell a wizard what you did.")
248:     endif
249:   else
250:     pname = $string_utils:left(tostr($string_utils:right(tostr(where), 6), it == where ? "." | (inf != E_PERM && is_clear_property(it, q) ? " " | ","), $html_utils:literal_text(q), " "), 25)
251:     if (inf == E_PERM)
252:       this:notify_direct(pname + "   ** unreadable **")
253:     else
254:       oname = inf[1].name
255:       truncate_owner_names && (length(oname) > 12 && (oname = oname[1..12]))
256:       inf[2] = inf[2] + "  "
257:       inf[2][1] != "r" && (inf[2][1..0] = " ")
258:       "(inf[2][2] != \"w\") && (inf[2][2..1] = \" \");"
259:       prop_data = it.(q)
260:       typeof(prop_data) == $LIST && length(prop_data) > 100 && (prop_data = prop_data[1..100])
261:       this:notify_direct($string_utils:left(tostr($string_utils:left(tostr(pname, oname, " (", inf[1], ") "), 47), inf[2][1..3], " "), 54) + (length(y = $string_utils:from_value(prop_data, 1, depth)) > max ? y[1..max] + ".." | y))
262:     endif
263:   endif
264: endfor
265: "Print the files."
266: for b in (file)
267:   $command_utils:suspend_if_needed()
268:   {where, q} = b
269:   "This file should exist (unless it was deleted while we were suspended...)."
270:   perms = (it:fileaccess(q) + " ")[1]
271:   bytes = $string_utils:group_number(it:filesize(q)) + " bytes"
272:   fname = $string_utils:left(tostr($string_utils:right(tostr(where), 6), "!", $html_utils:literal_text(q), " "), 40)
273:   this:notify_direct(tostr(fname, perms, $string_utils:right(bytes, 16)))
274: endfor
275: "Gripe about not being able to read various -r objects"
276: if (cant)
277:   failed = {}
278:   for k in (cant)
279:     failed = listappend(failed, tostr(k.name, " (", k, ")"))
280:   endfor
281:   this:notify_direct($string_utils:centre(tostr(" no permission to read ", $string_utils:english_list(failed, ", ", " or ", " or "), ". "), 75, "-"))
282: else
283:   this:notify_direct($string_utils:centre(" finished ", full_linelength, "-"))
284: endif
285: "Last modified by whiz (#3135) on Sun Jan 13 01:16:24 2008 EST."

Verb arguments: any none none
Verb perms: Readable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]