Article #1048
Subject: Property referencing
Author: Gavin Lambert
Posted: 3/1/2001 04:24:06 PM
I've discovered that I want to refer to "subobjects" a lot; for example, I want to use "$local.ship" in place of "#123", "$local.ship.help" in place of "#125", etc. I've changed $code_utils:parse_propref to the following, which seems to do the trick... can anyone see any nasty side-effects that I haven't thought of? ----- snip ----- "$code_utils:parse_propref(string)"; "Parses string as a MOO-code property reference, returning {object-string, prop-name-string} for a successful parse and false otherwise. It always returns the right object-string to pass to, for example, this-room:match_object."; ""; "Extended to call $string_utils:literal_object on everything before the last dot; one of the main reasons for that is so that subcore refs work (e.g. $coreobj.oneprop.anotherprop). As a side effect it will also translate ~player and *mailing-list references, but doesn't allow extensions for those (or for #xxxx refs)."; s = args[1]; if (dot = rindex(s, ".")) object = s[1..dot - 1]; prop = s[dot + 1..$]; if (!(object && prop)) return 0; elseif (valid(lit = $string_utils:literal_object(object))) object = tostr(lit); else "Restore original behaviour for non-literal objects."; dot = index(s, "."); object = s[1..dot - 1]; prop = s[dot + 1..$]; endif elseif (index(s, "$") == 1) object = "#0"; prop = s[2..$]; else return 0; endif return {object, prop}; ----- snip ----- If nobody can pick any holes in this, then I'll have to make similar changes to :parse_verbref; are there any other verbs that will need to be changed? -- Gavin Lambert, Ultra Enterprises, uecasm@nospam <http://ue.cjb.net/>, <http://crash.ihug.co.nz/~brianc/> ICQ: 2274180 (<www.icq.com>) For a dynamic signature like this, <http://ue.cjb.net/dynasig/> ---- "Beam me aboard, Scotty!" "How about A 2x4, sir?"