@create $room named Self-Cleaning Room @prop "Self-Cleaning Room"."delay" 3600 rc @prop "Self-Cleaning Room"."remove_object_msg" "The housekeeper arrives to remove %n from %t." rc @prop "Self-Cleaning Room"."trashtimes" {} r @prop "Self-Cleaning Room"."trashobjects" {} r ;"Self-Cleaning Room".("entrances") = {} ;"Self-Cleaning Room".("exits") = {} ;"Self-Cleaning Room".("key") = 0 ;"Self-Cleaning Room".("aliases") = {"Self-Cleaning Room"} ;"Self-Cleaning Room".("description") = "This room keeps itself relatively free of garbage. 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." @verb "Self-Cleaning Room":"enterfunc" this none this @program "Self-Cleaning Room":enterfunc pass(@args); item = args[1]; if (this:litterp(item)) if (loc = (item in this.trashobjects)) this.trashtimes[item in this.trashobjects] = time(); else this.trashobjects = {@this.trashobjects, item}; this.trashtimes = {@this.trashtimes, time()}; endif endif now = time(); stuff = {}; for i in [1..length(this.trashobjects)] if ((now - this.trashtimes[i]) > this.delay) stuff = {@stuff, this.trashobjects[i]}; endif endfor if (stuff) fork (20) for x in (stuff) if (x.location == this) this:announce_all($string_utils:pronoun_sub(this.remove_object_msg, x)); this:eject(x); endif endfor endfork endif . @verb "Self-Cleaning Room":"exitfunc" this none this @program "Self-Cleaning Room":exitfunc pass(@args); item = args[1]; if (loc = (item in this.trashobjects)) this.trashobjects = listdelete(this.trashobjects, loc); this.trashtimes = listdelete(this.trashtimes, loc); endif . "Oops! Forgot this needed wizperms. Sorry 'bout that. @verb "Self-Cleaning Room":"eject" this none this rxd #2 @program "Self-Cleaning Room":eject if (caller in {this, this.owner}) return pass(@args); else return E_PERM; endif . @verb "Self-Cleaning Room":"remove_object_msg" this none this @program "Self-Cleaning Room":remove_object_msg return this.(verb); . @verb "Self-Cleaning Room":"litterp" this none this @program "Self-Cleaning Room":litterp item = args[1]; return (!is_player(item)) && (!(item in this.residents)); .