Generic Room with Seats (#955)

(an instance of Generic Secured Post-Apocalypse Room made by Dred)

     This child of the PARC allows you to make custom seats of any amount, holding a custom amount of people each. The owner can create seats fitting for their room environment and theme. See `help #955'.

Go to location of this object, wooden box.


HELP MANUAL:
     This child of the PARC allows you to define virtual seats in your room of any size. 

     
     Owner only verbs:
     
     @seats
     
     Tells you what seats are available, by what names. How many they can hold, and what 
messages are set that aren't the default.
     
     @add-seat  for 
     
     Adds the named seat, with aliases specified to the room that can hold up to the  
specified. Amount must be greater than 0. Aliases are optional.
     
     @rm-seat 
     
     Completely removes the specified seat, if it exists, from the room.
     
     @sit/@osit/@stand/@ostand/@ositting  is [message|default]
     
     Use this command to see and set the messages for your seats. With no indirect
     object string (i.e. `@sit  is'), you will be told the current message. If
     you use the word `default' as the message, the message will be cleared back to
     default values. Otherwise, the new [message] is set for that seat. Note that in
     addition to standard pronoun substitutions, the word chaise longue will be replaced
     with the name of the seat in your message.
     
     ----
     The last command manipulates the messages associated with each seat you create:
     
       sit     - the player sees this when he sits down on the seat.
       osit    - the room sees this when the player sits on the seat.
       stand   - the player sees this when he stands up from the seat.
       ostand  - the room sees this when the player stands up from the seat.
       sitting - when someone looks, this message is displayed about those sitting.
     
     In these messages, normal pronoun substitutions are used in addition to these:
       chaise longue - the name of the seat
     
     For @sitting ONLY:
       sheitter - the name of the person, or people if more than one, in the seat.
        - conjugated for sheitter. (i.e. sheitter , sheitter , 
                 sheitter , etc.) Start out with singular in your message. 
     
     These are the defaults for these messages:
     
       sit     - You sit on the chaise longue.
       osit    - Visitor sits on the chaise longue.
       stand   - You get up from the chaise longue.
       ostand  - Visitor gets up from the chaise longue.
       sitting - sheitter  sitting on the chaise longue.
     ----



VERB SOURCE CODE:

@seats:
"Usage: @seats";
"";
"Tells you what seats are available, by what names. How many they can hold, and what 
messages are set that aren't the default.";
if (!$perm_utils:controls(player, this))
    player:tell(E_PERM);
    return;
endif
if (this.seats)
    player:tell("----------");
    for seat in [1..length(this.seats)]
        set = this.seats[seat];
        player:tell("\"", set[1][1], "\"", (length(set[1]) > 1) ? tostr(" ", $string_utils:print(set[1][2..length(set[1])])) 
| "", " holding up to ", set[2], (set[2] == 1) ? " person." | " people.");
        found = 1;
        for msg in ({"sit_msg", "osit_msg", "stand_msg", "ostand_msg", "sitting_msg"})
            if (this.(msg)[seat])
                player:tell("  ", this:(msg)(seat, {player}));
                found = 0;
            endif
        endfor
        if (found)
            player:tell("  Using all default messages.");
        endif
    endfor
    player:tell("----------");
else
    player:tell("No seats defined.");
endif
.


@add-seat:
"Usage: @add-seat  for ";
"";
"Adds the named seat, with aliases specified to the room that can hold up to the 
 specified. Amount must be greater than 0. Aliases are optional.";
if ((!$perm_utils:controls(valid(cp = caller_perms()) ? cp | player, this)) && (caller 
!= this))
    player:tell(E_PERM);
    return;
endif
if (names = $building_utils:parse_names(dobjstr))
    if (amt = tonum(iobjstr))
        player:tell("Adding seat named \"", names[1], "\" and alias", (length(names[2]) 
> 1) ? "es " | " ", $string_utils:print(names[2]), " to hold up to ", amt, " people.");
        this.seats = {@this.seats, {{names[1], @setremove(names[2], names[1])}, amt}};
        this:load_new();
    else
        player:tell("You need to specify some number greater than 0.");
    endif
else
    player:tell("Could not figure out the name: ", dobjstr, ".");
endif
.


@rm-seat:
"Usage: @rm-seat ";
"";
"Completely removes the specified seat, if it exists, from the room. Naturally, only 
the owner can use this.";
if ((!$perm_utils:controls(valid(cp = caller_perms()) ? cp | player, this)) && (caller 
!= this))
    player:tell(E_PERM);
    return;
endif
if (seat = this:match_seat(dobjstr))
    oldinfo = this.seats[seat][1];
    player:tell("Removing seat named \"", oldinfo[1], "\" and alias", (length(oldinfo) 
> 2) ? "es " | " ", $string_utils:print(oldinfo), ".");
    this.seats = listdelete(this.seats, seat);
    this.sitting = listdelete(this.sitting, seat);
    this.sit_msg = listdelete(this.sit_msg, seat);
    this.osit_msg = listdelete(this.osit_msg, seat);
    this.stand_msg = listdelete(this.stand_msg, seat);
    this.ostand_msg = listdelete(this.ostand_msg, seat);
    this.sitting_msg = listdelete(this.sitting_msg, seat);
else
    player:tell("Could not find seat named \"", dobjstr, "\".");
endif
.


sit:
"Usage: sit on ";
"";
"If the seat is defined on the room, you naturally will sit in it if there is room.";
if (seat = this:match_seat(iobjstr))
    if (player in this.sitting[seat])
        player:tell("You are already sitting there!");
        return;
    endif
    if (length(this.sitting[seat]) < this.seats[seat][2])
        if (oldseat = this:find_sitter(player))
            this:do_stand(oldseat);
        endif
        this:do_sit(seat);
    else
        player:tell("There isn't enough room in that seat.");
    endif
else
    player:tell("You find no such place to sit on.");
endif
.


stand:
"Usage: stand";
"";
"If you are sitting in a seat defined in the room, well, you stand up. Duh";
if (oldseat = this:find_sitter(player))
    this:do_stand(oldseat);
else
    player:tell("You aren't sitting!");
endif
.


match_seat:
if (caller != this)
    return E_PERM;
endif
seatname = args[1];
for seat in [1..length(this.seats)]
    try_ = $string_utils:from_list(this.seats[seat][1], "%|");
    if (match(seatname, try_))
        return seat;
    endif
endfor
return 0;
.


load_new:
if (caller != this)
    return E_PERM;
endif
this.sit_msg = {@this.sit_msg, ""};
this.osit_msg = {@this.osit_msg, ""};
this.stand_msg = {@this.stand_msg, ""};
this.ostand_msg = {@this.ostand_msg, ""};
this.sitting_msg = {@this.sitting_msg, ""};
this.sitting = {@this.sitting, {}};
.


sit_msg osit_msg stand_msg ostand_msg sitting_msg:
ind = args[1];
if (!(msg = this.(verb)[ind]))
    vlist = $string_utils:words(verb_info(#955, verb)[3]);
    vind = verb in vlist;
    msg = this.defaults[vind];
endif
if (verb == "sitting_msg")
    wholist = args[2];
    fverb = "";
    for word in ($string_utils:words(msg))
        if ((length(word) > 1) && (word[1..2] == "%<"))
            fverb = word[3..length(word) - 1];
        endif
    endfor
    if (fverb)
        wverb = $gender_utils:get_conj(fverb, @(length(wholist) > 1) ? {this} | wholist);
        msg = strsub(msg, tostr("%<", fverb, ">"), wverb);
    endif
    msg = strsub(msg, "%sitter", $string_utils:title_list(wholist));
endif
return $string_utils:pronoun_sub(strsub(msg, "%seat", this.seats[ind][1][1]));
.


find_sitter:
":find_sitter(OBJ player) - if player is sitting down in a seat, returns the index 
of the seat in .seats. Returns 0 if not sitting.";
who = args[1];
for d in [1..length(this.sitting)]
    if (who in this.sitting[d])
        return d;
    endif
endfor
return 0;
.


@sit @osit @stand @ostand @sitting:
"Usage: @sit/@osit/@stand/@ostand/@ositting  is [message|default]";
"";
"Use this command to see and set the messages for your seats. With no indirect object 
string (i.e. `@sit  is'), you will be told the current message. If you use 
the word `default' as the message, the message will be cleared back to default values. 
Otherwise, the new [message] is set for that seat. Note that in addition to standard 
pronoun substitutions, the word %seat will be replaced with the name of the seat 
in your message.";
if ((!$perm_utils:controls(valid(cp = caller_perms()) ? cp | player, this)) && (caller 
!= this))
    return E_PERM;
endif
if (seat = this:match_seat(dobjstr))
    mesnam = tostr(verb[2..length(verb)], "_msg");
    if (iobjstr)
        if (iobjstr == "default")
            player:tell("You clear the \"", mesnam[1..length(mesnam) - 4], "\" message 
of seat \"", this.seats[seat][1][1], "\" back to default values.");
            this.(mesnam)[seat] = "";
        else
            player:tell("You set the \"", mesnam[1..length(mesnam) - 4], "\" message 
of seat \"", this.seats[seat][1][1], "\".");
            this.(mesnam)[seat] = iobjstr;
        endif
    else
        player:tell("The \"", mesnam[1..length(mesnam) - 4], "\" message of seat 
\"", this.seats[seat][1][1], "\":");
        if (!(msg = this.(mesnam)[seat]))
            vlist = $string_utils:words(verb_info(#955, mesnam)[3]);
            vind = mesnam in vlist;
            msg = this.defaults[vind];
        endif
        player:tell(msg);
    endif
else
    player:tell("Seat \"", dobjstr, "\" not found.");
endif
.


exitfunc:
pass(@args);
who = args[1];
if (seat = this:find_sitter(who))
    this.sitting[seat] = setremove(this.sitting[seat], who);
endif
.


tell_contents:
contents = args[1];
ctype = args[2];
if (this.seats)
    for thing in (contents)
        if (ind = this:find_sitter(thing))
            contents = setremove(contents, thing);
        endif
    endfor
    newmsg = "";
    for seat in [1..length(this.sitting)]
        if (wholist = this.sitting[seat])
            newmsg = (newmsg + this:sitting_msg(seat, wholist)) + this.look_sep_msg;
        endif
    endfor
    if (newmsg)
        player:tell(newmsg);
    endif
    pass(contents, ctype);
else
    pass(@args);
endif
.


do_sit do_stand:
"removes or adds player to the correct seat. Allows children to hack into the sitting 
and standing process. Must be called by this, and expects seat index as args.";
if (caller != this)
    return E_PERM;
endif
seat = args[1];
verb = verb[4..length(verb)];
player:tell(this:(tostr(verb, "_msg"))(seat));
this:announce(this:(tostr("o", verb, "_msg"))(seat));
this.sitting[seat] = (verb == "sit") ? setadd(this.sitting[seat], player) | setremove(this.sitting[seat], 
player);
.


set_sitting:
"Allows children, or any verb owned by the owner of the child room, to set the .sitting 
property directly so they can do fun things.";
"This verb does NOT check to make sure that you are giving the data in the right 
format.";
"The proper format is: {{object1 in seat1, object2 in seat1, ...}, {object1 in seat2, 
object2 in seat2, ...}, ...}";
if ((caller == this) || $perm_utils:controls(caller_perms(), this))
    if (args)
        return this.(verb[5..length(verb)]) = args[1];
    else
        return E_INVARG;
    endif
else
    return E_PERM;
endif
.



PROPERTY DATA:
      seats
      sitting
      sit_msg
      osit_msg
      stand_msg
      ostand_msg
      sitting_msg
      defaults
      gender

CHILDREN:
D.E.W. a room Dr Benway's Clinic Little Park Hiding Place The Whirligig Mossy rocks Anril's Abode Generic Container Room Under a Tree Stage Manager's Office Club Can't Tell Mael's Office Meet Cafe O.o.f. Theater The Manticore Randomhaus Floating Music Widor's Le Cafe' Fetish The Pit Dockside The Hermaphrodite Generic Room with Surfaces Cave #17 Ben's Place Removal Chamber Tattoo Den (waiting room) Tattoo Chamber Tower Chamber (window ledge) Tower Chamber Grrl Island Confession Booth Scabby Little Room Boiler Room 307 Red metal poison The Ajax Inside the Pothole Morte Delizioso Bianco Proto-Generic Aspect Seated Secured Post-Apocalypse Room Burrow a compost heap 3-J Back Lot cardboard box High Cliff Old Church Lobby of Labry Apartments A small Crypt