View/Edit #7165:@d-old

Switch to edit mode.

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

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]