View/Edit #29:match_player_or_object

Switch to edit mode.

Name(s): match_player_or_object
1:  "Accepts any number of strings, attempts to match those strings first against objects in the room, and if no objects by those names exist, matches against player names (and \"#xxxx\" style strings regardless of location).  Returns a list of valid objects so found."
2:  "Unlike $string_utils:match_player, does not include in the list the failed and ambiguous matches; instead has built-in error messages for such objects.  This should probably be improved.  Volunteers?"
3:  if (!args)
4:    return
5:  endif
6:  unknowns = {}
7:  objs = {}
8:  "We have to do something icky here.  Parallel walk the victims and args lists.  When it's a valid object, then it's a player.  If it's an invalid object, try to get an object match from the room.  If *that* fails, complain."
9:  for i in [1..length(args)]
10:   if (valid(o = player.location:match_object(args[i], player)))
11:     objs = {@objs, o}
12:   else
13:     unknowns = {@unknowns, args[i]}
14:   endif
15: endfor
16: victims = $string_utils:match_player(unknowns)
17: for i in [1..length(victims)]
18:   if (!valid(victims[i]))
19:     player:tell("Could not find ", unknowns[i], " as either an object or a player.")
20:   else
21:     objs = {@objs, victims[i]}
22:   endif
23: endfor
24: return objs
25: "Last modified by Cecil (#7407) on Sat Jul 27 21:04:08 2002 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Hacker (#60)

You are not logged in.

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