View/Edit #12:@recycle*!

Switch to edit mode.

Name(s): @recycle*!
1:  "Recycle the specified object, and optionally deal with its children."
2:  dobj = player:my_match_object(dobjstr)
3:  if (dobj == $nothing)
4:    $msg:mtell("no_dobj", verb)
5:  elseif ($command_utils:object_match_failed(dobj, dobjstr))
6:    "...bogus object..."
7:  elseif (player == dobj)
8:    $msg:mtell("recycle_self")
9:  else
10:   if (!player:controls(dobj))
11:     if (!this.wizard)
12:       return player:tell(E_PERM)
13:     elseif (!$cmd_utils:yes_or_no(tostr("Hey!  Recycle ", $su:nn(dobj), ", even though it's not yours?")))
14:       return player:tell("Aborted.")
15:     endif
16:   endif
17:   if (descendants = dobj:descendants_suspended())
18:     if (verb[$] != "!")
19:       if (length(children(dobj)) == length(descendants))
20:         player:tell("This object has ", length(descendants), " children; use <A xch_cmd='@children ", dobj, "'>@children</A> to see them all.")
21:       else
22:         player:tell("This object has ", length(descendants), " descendants; use <A xch_cmd='@tree ", dobj, "'>@tree</A> to see them all.")
23:       endif
24:       player:tell("Either @disown them first, or use @recycle! to recycle everything.")
25:       return
26:     endif
27:     for victim in ($list_utils:reversed(descendants))
28:       "Only recycle this object if you control all its parents up to the original object"
29:       p = parent(victim)
30:       while (p != dobj)
31:         if (!player:controls(p))
32:           continue victim
33:         endif
34:         p = parent(p)
35:       endwhile
36:       "If you contol this object, recycle it, otherwise disown it."
37:       if (!player:controls(victim))
38:         force_input(player, tostr("@disown ", victim))
39:       else
40:         name = victim.name
41:         result = $recycler:recycle(victim)
42:         if (typeof(result) == $ERR)
43:           player:tell(result)
44:         else
45:           $msg:mtell("recycled", name, victim)
46:         endif
47:       endif
48:       suspend(0)
49:     endfor
50:     "Pass through and recycle the original object."
51:   endif
52:   name = dobj.name
53:   result = $recycler:recycle(dobj)
54:   if (typeof(result) == $ERR)
55:     player:tell(result)
56:   else
57:     $msg:mtell("recycled", name, dobj)
58:   endif
59: endif
60: "Last modified by Dax (#789) on Mon Aug  7 21:17:28 2006 MDT."

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

You are not logged in.

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