Self-Cleaning Room #27777
Aliases: Self-Cleaning Room
16 verbs · 17 properties · 1 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
enterfunc | this none this | | #27777 | 49 |
exitfunc | this none this | | #27777 | 7 |
eject eject_basic | this none this | rxd | #27777 | 15 |
remove_object_msg | this none this | | #27777 | 1 |
litterp | this none this | rx | #27777 | 10 |
acceptable | this none this | | #27777 | 11 |
deleteitem | this none this | | #27777 | 8 |
too_full | this none this | rxd | #27777 | 10 |
most_idle_player | this none this | rx | #27777 | 8 |
shove_out | this none this | rxd | #27777 | 23 |
check_if_too_full | this none this | rxd | #27777 | 10 |
shove_through_exit | this none this | rxd | #27777 | 29 |
flush_item_now | this none this | | #27777 | 6 |
forget_trash | this none this | | #27777 | 5 |
@self-clean | any any none | rxd | #27777 | 27 |
set_self_cleaning | this none this | | #27777 | 5 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
trigger_delay | #27777 | rc | — | 20 |
delay | #27777 | rc | — | 3600 |
remove_object_msg | #27777 | rc | — | "The housekeeper arrives to remove %[tcurrent_names] from %t." |
trashtimes | #27777 | r | — | {} |
trashobjects | #27777 | r | — | {} |
current_names | #27777 | r | — | "nothing" |
ejected | #27777 | r | #49853 | {} |
maximum_players | #27777 | rc | — | 50 |
idle_max | #27777 | rc | — | 300 |
being_shoved | #27777 | r | #49853 | {} |
self_cleaning | #27777 | r | — | 0 |
entrances | #27777 | | — | not readable (E_PERM) |
exits | #27777 | | — | not readable (E_PERM) |
key | #27777 | | — | not readable (E_PERM) |
aliases | #27777 | | — | {"Self-Cleaning Room"} |
description | #27777 | | — | value (646 chars)"This room optionally keeps itself relatively free of garbage. If this.self_cleaning is set, nonplayer objects which are not present in .residents are only allowed to remain for this.delay seconds (default one hour). This is not perfect; it uses :enterfunc as its trigger instead of forking. Messages: @remove_object gets printed to everyone in the room when an object is ejected. [Note kluge: instead of %n to describe the object being removed, use %[tcurrent_names]; this is so multiple items will be mentioned correctly in one message.]. @self-clean commandline verb toggles self cleaning, :set_self_cleaning permits programmatic shift." |
object_size | #27777 | | — | {11115, 1141286549} |
Ancestry
Ancestors (nearest first): none
Children: #3879 Matching Room
Call graph
Source
enterfunc
Referenced by
- #1610:enterfunc line 3:
pass(
Source
1pass(@args); 2if (!this.self_cleaning) 3 return; 4endif 5item = args[1]; 6now = time(); 7if (this:litterp(item)) 8 if (loc = item in this.trashobjects) 9 this.trashtimes[loc] = now; 10 else 11 this.trashobjects = {@this.trashobjects, item}; 12 this.trashtimes = {@this.trashtimes, now}; 13 endif 14else 15 this:check_if_too_full(item); 16endif 17ejectables = {}; 18deleteables = {}; 19for i in [1..length(this.trashobjects)] 20 item = this.trashobjects[i]; 21 if ((!valid(item)) || (!this:litterp(item))) 22 "Maybe a player who connected, no longer litter."; 23 "Also, if a !valid object gets in here, we're in trouble and better flush it."; 24 deleteables = {@deleteables, item}; 25 elseif (this:flush_item_now(i, now)) 26 ejectables = {@ejectables, item}; 27 endif 28endfor 29for x in (deleteables) 30 this:deleteitem(x); 31endfor 32if (ejectables) 33 fork (this.trigger_delay) 34 for x in (ejectables) 35 if (x.location == this) 36 this:eject_basic(x); 37 else 38 ejectables = setremove(ejectables, x); 39 if (x in this.trashobjects) 40 this:deleteitem(x); 41 endif 42 endif 43 this.current_names = $string_utils:english_list($list_utils:map_verb(ejectables, "title")); 44 endfor 45 if (ejectables) 46 this:announce_all($string_utils:pronoun_sub(this.remove_object_msg)); 47 endif 48 endfork 49endif
exitfunc
Referenced by
- #258:exitfunc line 6:
pass(
Source
1if (callers()[1][1..4] != {#-1, "move", #-1, #-1}) 2 return E_PERM; 3endif 4pass(@args); 5if (this.self_cleaning) 6 this:deleteitem(args[1]); 7endif
eject eject_basic
Referenced by
- #258:_eject line 5:
this:eject_basic - #258:_eject(old) line 3:
this:eject_basic - #27777:enterfunc line 36:
this:eject_basic - #27777:shove_through_exit line 19:
this:eject_basic - #27777:shove_through_exit line 25:
this:eject_basic
Source
1set_task_perms($wiz_utils:random_wizard()); 2if (caller in {this, this.owner}) 3 if (this.self_cleaning) 4 x = args[1]; 5 if (x.location == this) 6 this.ejected = setadd(this.ejected, x); 7 fork (this.delay * 5) 8 this.ejected = setremove(this.ejected, x); 9 endfork 10 endif 11 endif 12 return pass(@args); 13else 14 return E_PERM; 15endif
remove_object_msg
Referenced by
none
Source
1return this.(verb);
litterp
Referenced by
- #27777:enterfunc line 7:
this:litterp - #27777:enterfunc line 21:
this:litterp - #27777:acceptable line 3:
this:litterp
Source
1item = args[1]; 2if (item == this.owner) 3 return 0; 4elseif (is_player(item) && (!(item in this.residents))) 5 "nonresident idling players are litter, even if sessile"; 6 return (typeof(idle_seconds(item)) == ERR) && ((time() - item.last_disconnect_time) > 300); 7else 8 "non-resident objects are litter"; 9 return !(item in this.residents); 10endif
acceptable
Referenced by
- #258:acceptable line 15:
pass(
Source
1"Modified 10/19/98 by TheCat to exclude sleeping players who don't belong."; 2what = args[1]; 3if ((this.self_cleaning && (ticks_left() < 15000)) && ((what in this.ejected) || this:litterp(what))) 4 "If less than 15000 ticks, we are either a spammy command line task, or, more likely, a suspended or forked task trying to auto-return. Deny those."; 5 result = 0; 6elseif ((is_player(what) && (!$object_utils:connected(what))) && (!this:basic_accept_for_abode(what))) 7 result = 0; 8else 9 result = pass(@args); 10endif 11return result;
deleteitem
Referenced by
- #27777:enterfunc line 30:
this:deleteitem - #27777:enterfunc line 40:
this:deleteitem - #27777:exitfunc line 6:
this:deleteitem
Source
1if (caller != this) 2 return E_PERM; 3endif 4item = args[1]; 5if (loc = item in this.trashobjects) 6 this.trashobjects = listdelete(this.trashobjects, loc); 7 this.trashtimes = listdelete(this.trashtimes, loc); 8endif
too_full
Referenced by
- #27777:check_if_too_full line 2:
this:too_full
Source
1max = this.maximum_players; 2cp = connected_players(); 3for x in (this.contents) 4 if (x in cp) 5 if ((max = max - 1) < 0) 6 return 1; 7 endif 8 endif 9endfor 10return 0;
most_idle_player
Referenced by
- #27777:check_if_too_full line 3:
this:most_idle_player
Source
1idler = #-1; 2time = 0; 3for x in (this.contents) 4 if (idle_seconds(x) > time) 5 time = idle_seconds(idler = x); 6 endif 7endfor 8return time && {idler, time};
shove_out
Referenced by
- #27777:check_if_too_full line 4:
this:shove_out - #27777:check_if_too_full line 7:
this:shove_out
Source
1"shove_out(who, ..disallowed destinations...)"; 2"since this can move people, requires permissions"; 3if ((caller != this) && (!caller_perms().wizard)) 4 return E_PERM; 5endif 6who = args[1]; 7msg = args[2]; 8poss_exits = this.exits; 9while (poss_exits) 10 exit = poss_exits[random(length(poss_exits))]; 11 poss_exits = setremove(poss_exits, exit); 12 if ((!(exit.dest in args)) && exit.dest:acceptable(who)) 13 break; 14 else 15 exit = 0; 16 endif 17endwhile 18if (typeof(exit) != OBJ) 19 return 0; 20endif 21player = who; 22this:shove_through_exit(exit, msg); 23return 1;
check_if_too_full
Referenced by
- #27777:enterfunc line 15:
this:check_if_too_full
Source
1item = args[1]; 2if (is_player(item) && this:too_full()) 3 if ((who = this:most_idle_player()) && (who[2] > this.idle_max)) 4 this:shove_out(who[1], {"", "It's awfully crowded in here to idle... you decide to go somewhere else less noisy.", ""}); 5 elseif (ents = $set_utils:intersection(this.entrances, $list_utils:slice(callers()))) 6 if (item.location == this) 7 this:shove_out(item, {"", "It's too crowded in here, and you decide to explore a little.", ""}, @$list_utils:map_property(ents, "source")); 8 endif 9 endif 10endif
shove_through_exit
Referenced by
- #27777:shove_out line 22:
this:shove_through_exit
Source
1if (caller != this) 2 return E_PERM; 3endif 4fork (0) 5 who = player; 6 if (who.location != this) 7 "don't do it, not here"; 8 return; 9 endif 10 exit = args[1]; 11 dest = exit.dest; 12 set_task_perms(player); 13 who:tell_lines(args[2]); 14 if (who.location == this) 15 exit:move(who); 16 endif 17 if (who.location == this) 18 "the 'eject' makes sure that they don't auto-return, and they also move"; 19 this:eject_basic(who); 20 endif 21endfork 22fork (1) 23 "REALLY get them out of here, dang it! In case they killed the above task"; 24 if (player.location == this) 25 this:eject_basic(player); 26 dobj = player; 27 this:announce_all_but({player}, this:oejection_msg()); 28 endif 29endfork
flush_item_now
Referenced by
- #27777:enterfunc line 25:
this:flush_item_now
Source
1"args[1] is an index into this.trashobjects"; 2"args[2] is now, so we don't have to recalculate it for every single item."; 3"Returns 1 if item should be flushed now, else 0."; 4index = args[1]; 5now = args[2]; 6return (now - this.trashtimes[index]) > this.delay;
forget_trash
Referenced by
- #27777:@self-clean line 8:
this:forget_trash
Source
1"This verb clears the record of litter in this room, and should be called after changing this.self_cleaning from 1 to 0."; 2if ((caller == this) || $perm_utils:controls(caller_perms(), this)) 3 this.trashtimes = {}; 4 this.trashobjects = {}; 5endif
@self-clean
Referenced by
none
Source
1"If no args, toggle state. Else turn self-cleaning on or off"; 2"+x so you can call it on generics to toggle."; 3if ($perm_utils:controls(valid(caller_perms()) ? caller_perms() | player, this)) 4 switch = argstr ? argstr | "toggle"; 5 if (this.self_cleaning) 6 if ((switch == "toggle") || (switch == "off")) 7 this:set_self_cleaning(0); 8 this:forget_trash(); 9 player:tell(this:title() + " is no longer self cleaning."); 10 elseif (switch == "on") 11 player:tell("Self-cleaning is already on."); 12 else 13 player:tell("Try this instead: @self-clean off"); 14 endif 15 else 16 if ((switch == "toggle") || (switch == "on")) 17 this:set_self_cleaning(1); 18 player:tell("Self-cleaning turned on."); 19 elseif (switch == "off") 20 player:tell("Self-cleaning is already on."); 21 else 22 player:tell("Try this instead: @self-clean on"); 23 endif 24 endif 25else 26 player:tell("Permission denied."); 27endif
set_self_cleaning
Referenced by
- #27777:@self-clean line 7:
this:set_self_cleaning - #27777:@self-clean line 17:
this:set_self_cleaning
Source
1if ((caller == this) || $perm_utils:controls(caller_perms(), this)) 2 return this.self_cleaning = args[1]; 3else 4 return E_PERM; 5endif