View/Edit #8756:@prog*ram

Switch to edit mode.

Name(s): @prog*ram
1:   "Copied from Generic Programmer (#14):@prog by Slacker (#55)Mar 15 20:05:41 2001"
2:   "This version of @program deals with multiple verbs having the same name."
3:   "... @program <object>:<verbname> <dobj> <prep> <iobj>  picks the right one."
4:   if (player != caller)
5:     return
6:   endif
7:   set_task_perms(player)
8:   "..."
9:   "...catch usage errors first..."
10:  "..."
11:  punt = "...set punt to 0 only if everything works out..."
12:  if (!player.programmer)
13:    return player:tell("Sorry, programmers only.")
14:  elseif (!(args && (spec = $code_utils:parse_verbref(args[1]))))
15:    player:notify(tostr("Usage: ", verb, " &lt;object&gt;:&lt;verb&gt; [&lt;dobj&gt; &lt;prep&gt; &lt;iobj&gt;]"))
16:  elseif ($command_utils:object_match_failed(object = player:my_match_object(spec[1]), spec[1]))
17:    "...bogus object..."
18:  elseif (typeof(argspec = $code_utils:parse_argspec(@listdelete(args, 1))) != $LIST)
19:    player:notify(tostr(argspec))
20:  elseif (argspec[2])
21:    player:notify($string_utils:from_list(argspec[2], " ") + "??")
22:  elseif (length(argspec = argspec[1]) in {1, 2})
23:    player:notify({"Missing preposition", "Missing iobj specification"}[length(argspec)])
24:  else
25:    punt = 0
26:    if (`verb_info(object, spec[2]) ! E_VERBNF')
27:      verbname = spec[2]
28:    elseif (match(spec[2], "^[0-9]+$"))
29:      verbname = toint(spec[2])
30:    else
31:      return player:tell("Verb not found, ", object, ":", spec[2], ".")
32:    endif
33:    if (index(verbname, "*") > 1)
34:      verbname = strsub(verbname, "*", "")
35:    endif
36:  endif
37:  "..."
38:  "...if we have an argspec, we'll need to reset verbname..."
39:  "..."
40:  if (punt)
41:  elseif (argspec)
42:    if (!(argspec[2] in {"none", "any"}))
43:      argspec[2] = $code_utils:full_prep(argspec[2])
44:    endif
45:    loc = $code_utils:find_verb_named(object, verbname)
46:    while (loc > 0 && verb_args(object, loc) != argspec)
47:      loc = $code_utils:find_verb_named(object, verbname, loc + 1)
48:    endwhile
49:    if (loc < 0)
50:      punt = "...can't find it...."
51:      player:notify("That object has no verb matching that name + args.")
52:    else
53:      verbname = loc
54:    endif
55:  else
56:    loc = -1
57:  endif
58:  "..."
59:  "...get verb info..."
60:  "..."
61:  if (punt || !(punt = "...reset punt to TRUE..."))
62:  elseif (`info = verb_info(object, verbname) ! ANY' == E_VERBNF)
63:    player:notify("That object does not have that verb definition.")
64:  elseif (typeof(info) == $ERR)
65:    player:notify(tostr(info))
66:  else
67:    punt = 0
68:    aliases = info[3]
69:    if (loc < 0)
70:      loc = aliases in (verbs(object) || {})
71:    endif
72:  endif
73:  "..."
74:  "...read the code..."
75:  "..."
76:  if (punt)
77:    player:notify(tostr("Now ignoring code for ", args ? args[1] | "nothing in particular", "."))
78:    $command_utils:read_lines()
79:    player:notify("Verb code ignored.")
80:  else
81:    player:notify(tostr("Now programming ", object.name, ":", aliases, "(", loc < 0 ? "??" | loc, ")."))
82:    try
83:      lines = $command_utils:read_lines()
84:    except (E_INVARG)
85:      "User disconnected, don't harass em with a TB mail"
86:      return
87:    endtry
88:    if (result = set_verb_code(object, verbname, lines))
89:      player:notify(result)
90:      player:notify(tostr(length(result), " error(s)."))
91:      player:notify("Verb not programmed.")
92:    elseif (typeof(result) == $ERR)
93:      player:notify(tostr(result))
94:      player:notify("Verb not programmed.")
95:    else
96:      player:notify("0 errors.")
97:      player:notify("Verb programmed.")
98:    endif
99:  endif
100: "Last modified by Dax (#789) on Wed May  4 06:46:05 2005 MDT."

Verb arguments: any any any
Verb perms: Readable NOT-Debug
Verb owned by: Ghost (#8756)

You are not logged in.

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