Switch to edit mode.
Name(s): pronoun_sub1: "Pronoun (and other things) substitution. See 'help pronouns' for details."
2: "syntax: $string_utils:pronoun_sub(text[,who[,thing[,location]]])"
3: "%s,%o,%p,%q,%r => <who>'s pronouns. <who> defaults to player."
4: "%n,%d,%i,%t,%l,%% => <who>, dobj, iobj, <thing>, location and %"
5: "<thing> defaults to caller; <location> defaults to who.location"
6: "%S,%O,%P,%Q,%R, %N,%D,%I,%T,%L have corresponding capitalized substitutions."
7: " %[#n], %[#d], ... => <who>, dobj, etc.'s object number"
8: "%(foo) => <who>.foo and %(Foo) => <who>.foo capitalized. %[dfoo] => dobj.foo, etc.."
9: "%<foo> -> whatever <who> does when normal people foo. This is determined by calling :verb_sub() on the <who>."
10: "%<d:foo> -> whatever <dobj> does when normal people foo."
11: who = length(args) >= 2 ? args[2] | player
12: thing = length(args) >= 3 ? args[3] | caller
13: where = length(args) >= 4 ? args[4] | (valid(who) ? who.location | $nothing)
14: set_task_perms($no_one)
15: if (typeof(args[1]) == $LIST)
16: plines = {}
17: for line in (args[1])
18: plines = {@plines, this:(verb)(line, who, thing, where)}
19: $cmd_utils:suspend_if_needed()
20: endfor
21: return plines
22: endif
23: old = tostr(args[1])
24: new = ""
25: objspec = "nditl"
26: objects = {who, length(args) >= 5 ? args[5] | dobj, length(args) >= 6 ? args[6] | iobj, thing, where}
27: prnspec = "sopqrSOPQR"
28: prprops = {"ps", "po", "pp", "pq", "pr", "Ps", "Po", "Pp", "Pq", "Pr"}
29: oldlen = length(old)
30: while ((prcnt = index(old, "%")) && prcnt < oldlen)
31: s = old[k = prcnt + 1]
32: if (s == "<" && (gt = index(old[k + 2..length(old)], ">")))
33: "handling %<verb> "
34: gt = gt + k + 1
35: vb = old[k + 1..gt - 1]
36: vbs = who
37: if (length(vb) > 2 && vb[2] == ":")
38: " %<d:verb>"
39: vbs = objects[index(objspec, vb[1]) || 1]
40: vb = vb[3..length(vb)]
41: endif
42: vb = $object_utils:has_verb(vbs, "verb_sub") ? vbs:verb_sub(vb) | this:(verb)(vb, vbs)
43: new = new + old[1..prcnt - 1] + vb
44: k = gt
45: else
46: cp_args = {}
47: if (brace = index("([", s))
48: if (!(w = index(old[k + 1..oldlen], ")]"[brace])))
49: return new + old
50: else
51: p = old[prcnt + 2..(k = k + w) - 1]
52: if (brace == 1)
53: "%(property)"
54: cp_args = {who, p}
55: elseif (p[1] == "#")
56: "%[#n] => object number"
57: s = (o = index(objspec, p[2])) ? tostr(objects[o]) | "[" + p + "]"
58: elseif (!(o = index(objspec, p[1])))
59: s = "[" + p + "]"
60: else
61: " %[dproperty] "
62: cp_args = {objects[o], p[2..w - 1], strcmp(p[1], "a") < 0}
63: endif
64: endif
65: elseif (o = index(objspec, s))
66: cp_args = {objects[o], "", strcmp(s, "a") < 0}
67: elseif (w = index(prnspec, s, 1))
68: cp_args = {who, prprops[w]}
69: elseif (s == "#")
70: s = tostr(who)
71: elseif (s != "%")
72: s = "%" + s
73: endif
74: new = new + old[1..prcnt - 1] + (!cp_args ? s | (typeof(sub = $string_utils:_cap_property(@cp_args)) != $ERR ? sub | "%(" + tostr(sub) + ")"))
75: endif
76: old = old[k + 1..oldlen]
77: oldlen = oldlen - k
78: endwhile
79: return new + old
80: "Last modified by Dax (#789) on Mon Aug 7 21:49:26 2006 MDT."