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