View/Edit #12:add_feature

Switch to edit mode.

Name(s): add_feature
1:  "Add a feature to this player's features list.  Caller must be this or have suitable permissions (this or wizardly)."
2:  "If this is a nonprogrammer, then ask feature if it is feature_ok (that is, if it has a verb :feature_ok which returns a true value, or a property .feature_ok which is true)."
3:  "After adding feature, call feature:feature_add(this)."
4:  "Returns true if successful, E_INVARG if not a valid object, and E_PERM if !feature_ok or if caller doesn't have permission."
5:  if (caller == this || $perm_utils:controls(caller_perms(), this))
6:    feature = args[1]
7:    if (typeof(feature) != $obj || !$recycler:valid(feature))
8:      return player:tell("That does not even appear to be a valid object.")
9:    endif
10:   if (`$code_utils:verb_or_property(feature, "feature_ok", this) ! $failed_match')
11:     "The object is willing to be a feature."
12:     if (typeof(this.features) == $LIST)
13:       "If list, we can simply setadd the feature."
14:       if (length(args) > 1 && args[2])
15:         this.features = $list_utils:remove_duplicates({feature, @this.features})
16:       else
17:         this.features = setadd(this.features, feature)
18:       endif
19:     else
20:       "If not, we erase the old value and create a new list."
21:       this.features = {feature}
22:     endif
23:     "Tell the feature it's just been added."
24:     `feature:feature_add(this) ! E_VERBNF => 0'
25:     return 1
26:     "We're done."
27:   else
28:     return player:tell("You are not permitted to add that feature.")
29:   endif
30: else
31:   raise(E_PERM)
32: endif
33: "Last modified by Dax (#789) on Mon Aug  7 21:47:19 2006 MDT."

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

You are not logged in.

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