Generic Litter (#834)

(an instance of generic note made by Marcus)

     A fairly non-descript piece of litter. It has print on it.

Go to location of this object, wooden box.
                      KEEP OUR CITY CLEAN!



HELP MANUAL:
                         GENERIC LITTER
       Generic Litter is very simple:  it's a note, which blows
       from place to place.
     
       Make your own by typing @create #834 named .
       Use @notedit for an easy way to write on your litter.
       Use @setinterval to set the time litter will take to blow
       from one place to the next (in seconds). The minimum
       interval allowed is 180 seconds.
     
       The only other thing you need to know is how to ban the
       litter from a certain place. (The wind blows oddly in
       Bellona.)  Type ban  from  to do it. Use the
       object number of the place.  @rmban  from  will
       allow the litter back in.  (You can also ban other people's 
       litter from your own spaces.)  This function may also be 
       used to delimit a territory within which the litter may 
       blow, if you like.
     
       @messages to set on Generic Litter are @blow_in and @blow_out.
     



VERB SOURCE CODE:

d*rop th*row:
pass(@args);
if (!$code_utils:task_valid(this.blow_task))
    this.blowing = 1;
    this:blow_around();
endif
.


@setinterval:
if (player != this.owner)
    player:tell("You can't do that, it's not yours.");
else
    interval = tonum(iobjstr);
    if (interval < 180)
        player:tell("Sorry--the interval has to be at least 180. (It's not THAT windy!)");
    else
        this.interval = interval;
        player:tell("You set the delay on ", this.name, " to ", interval, " seconds.");
    endif
endif
.


blow_around:
"blow_around: a loop to blow the litter.  First invoked by :drop";
if (this.blowing)
    fork blowtask (this.interval)
        this:blow();
        this:blow_around();
    endfork
    this.blow_task = blowtask;
endif
.


blow:
"blow(): the basic verb to make the litter blow from one place to the next.  Invoked 
by :blow_around.";
if ($object_utils:has_property(this.location, "exits"))
    exits = this:find_exits();
    if (length(exits))
        destination = exits[random(length(exits))];
        this.location:announce_all($string_utils:pronoun_sub(this.blow_out_msg));
        this:moveto(destination);
        this.location:announce_all($string_utils:pronoun_sub(this.blow_in_msg));
    else
        this.blowing = 0;
    endif
else
    this.blowing = 0;
endif
.


find_exits:
exits = {};
obvious_exits = this.location:obvious_exits();
for exit in (obvious_exits)
    if (valid(exit) && (!(exit.dest in this.banned_rooms)))
        exits = listappend(exits, exit.dest);
    endif
endfor
return exits;
.


ban:
if ($object_utils:isa(place = player:my_match_object(iobjstr), $room))
    if ((player == place.owner) || (player == this.owner))
        this.banned_rooms = setadd(this.banned_rooms, place);
        player:tell("Okay, you have banned ", this.name, " from ", place.name, ". 
Once it's gone it won't come back.");
    else
        player:tell("You have to be the owner of ", this.name, "or of the room to 
ban it from places.");
    endif
else
    player:tell("Sorry, ", this.name, " can only be banned from a room...");
endif
.


@rmban:
if ($object_utils:isa(place = player:my_match_object(dobjstr), $room))
    if (!(place in this.banned_rooms))
        player:tell(this.name, " is not presently banned from ", place.name, ".");
    elseif ((player == place.owner) || (player == this.owner))
        this.banned_rooms = setremove(this.banned_rooms, place);
        player:tell("You have taken ", this.name, " off the banned list for ", place.name, 
".");
    else
        player:tell("You have to be the owner of ", this.name, "or of the room to 
control its access.");
    endif
else
    player:tell("Sorry, how could ", this.name, " be banned from ", place.name, "?");
endif
.


take:
pass(@args);
this.when_taken = ctime(time());
.



PROPERTY DATA:
      blowing
      interval
      banned_rooms
      blow_out_msg
      blow_in_msg
      blow_task
      help_msg
      when_taken
      look_msg

CHILDREN:
a piece of litter a scrap of scripture a scrap of poetry a printed page a small notebook a vanilla page a crumpled page a yellow frisbee a paper plate Fantasy some computer paper half-page half-page half-page torn page a torn leaf Rebel Rebel a little page crumpled page