View/Edit #12:@addalias @add-alias 2addalias

Switch to edit mode.

Name(s): @addalias @add-alias 2addalias
1:   "Syntax: @addalias <alias>[,...,<alias>] to <object>"
2:   "        @addalias <alias>[,...,<alias>] to <object>:<verb>"
3:   ""
4:   "The first form is used to add aliases to an object's list of aliases.  You can separate multiple aliases with commas.  The aliases will be checked against the object's current aliases and all aliases not already in the object's list of aliases will be added."
5:   ""
6:   "Example:"
7:   "Muchkin wants to add new aliases to Rover the Wonder Dog:"
8:   "  @addalias Dog,Wonder Dog to Rover"
9:   "Since Rover the Wonder Dog already has the alias \"Dog\" but does not have the alias \"Wonder Dog\", Munchkin sees:"
10:  "  Rover the Wonder Dog(#4237) already has the alias Dog."
11:  "  Alias Wonder Dog added to Rover the Wonder Dog(#4237)."
12:  ""
13:  "If the object is a player, spaces will also be assumed to be separations between aliases and each alias will be checked against the Player Name Database to make sure no one else is using it. Any already used aliases will be identified."
14:  ""
15:  "Example:"
16:  "Munchkin wants to add his nicknames to his own list of aliases:"
17:  "  @addalias Foobar Davey to me"
18:  "@Addalias recognizes that Munchkin is trying to add an alias to a valid player and checks the aliases against the Player Name Database.  Unfortunately, DaveTheMan is already using the alias \"Davey\" so Munchkin sees:"
19:  "  DaveTheMan(#5432) is already using the alias Davey"
20:  "  Alias Foobar added to Munchkin(#1523)."
21:  ""
22:  "The second form of the @addalias command is for use by programmers, to add aliases to a verb they own.  All commas and spaces are assumed to be separations between aliases."
23:  if (player != this)
24:    return $msg:mtell("huh")
25:  endif
26:  set_task_perms(player)
27:  spec = $code_utils:parse_verbref(iobjstr)
28:  if (spec)
29:    object = player:my_match_object(spec[1])
30:    if (!$command_utils:object_match_failed(object, spec[1]))
31:      vname = spec[2]
32:      info = verb_info(object, vname)
33:      if (info == E_VERBNF)
34:        player:tell("That object does not define that verb.")
35:      elseif (typeof(info) == $ERR)
36:        player:tell(tostr(info))
37:      else
38:        old_aliases = $string_utils:explode(info[3])
39:        used = {}
40:        for alias in (new_aliases = $list_utils:remove_duplicates($string_utils:explode(strsub(dobjstr, ",", " "))))
41:          if (alias in old_aliases)
42:            used = {@used, alias}
43:            new_aliases = setremove(new_aliases, alias)
44:          endif
45:        endfor
46:        if (used)
47:          player:tell(object.name, "(", object, "):", vname, " already has the alias", length(used) > 1 ? "es" | "", " ", $string_utils:english_list(used), ".")
48:        endif
49:        if (new_aliases)
50:          aliases = $string_utils:from_list({@old_aliases, @new_aliases}, " ")
51:          info[3] = aliases
52:          result = set_verb_info(object, vname, info)
53:          if (typeof(result) == $ERR)
54:            player:tell(result)
55:          else
56:            player:tell("Alias", length(new_aliases) > 1 ? "es" | "", " ", $string_utils:english_list(new_aliases), " added to verb ", $string_utils:nn(object), ":", vname)
57:            player:tell("Verbname is now ", $string_utils:nn(object), ":\"", aliases, "\"")
58:          endif
59:        endif
60:      endif
61:    endif
62:  else
63:    object = player:my_match_object(iobjstr)
64:    if (!$command_utils:object_match_failed(object, iobjstr))
65:      old_aliases = object.aliases
66:      used = {}
67:      for alias in (new_aliases = $list_utils:remove_duplicates($list_utils:map_arg($string_utils, "trim", $string_utils:explode(is_player(object) ? strsub(dobjstr, " ", ",") | dobjstr, ","))))
68:        if (alias in old_aliases)
69:          used = {@used, alias}
70:          new_aliases = setremove(new_aliases, alias)
71:        elseif (is_player(object) && valid(someone = $player_db:find_exact(alias)))
72:          player:tell(tostr(someone.name, "(", someone, ") is already using the alias ", alias, "."))
73:          new_aliases = setremove(new_aliases, alias)
74:        endif
75:      endfor
76:      if (used)
77:        player:tell(object.name, "(", object, ") already has the alias", length(used) > 1 ? "es" | "", " ", $string_utils:english_list(used), ".")
78:      endif
79:      if (new_aliases)
80:        try
81:          player:tell("Attempting to add alias", length(new_aliases) > 1 ? "es" | "", " ", $string_utils:english_list(new_aliases), " to ", object.name, "(", object, ")...")
82:          r = object:set_aliases({@old_aliases, @new_aliases})
83:          if (r != 1)
84:            "          player:tell(r);"
85:            "Something more intelligent should be done here."
86:          endif
87:          player:tell("Aliases for ", $su:nn(object), " are now ", toliteral(object.aliases))
88:        except (E_INVARG)
89:          player:tell("That particular name change not allowed (see help @rename or help @addalias).")
90:        except (E_NACC)
91:          player:tell("Oops.  You can't update that object's aliases right now; try again in a few minutes.")
92:        except (E_QUOTA)
93:          player:tell("The maximum number of aliases you can have is ", $max_num_aliases, "!")
94:        except (E_PERM)
95:          player:tell(E_PERM)
96:        endtry
97:      endif
98:    endif
99:  endif
100: "Last modified by Dax (#789) on Thu May  5 17:13:35 2005 MDT."

Verb arguments: any at/to any
Verb perms: Readable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

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