For some strange reason, line 10 is coming up with a parse error. What I'm trying to do is make it so a set of rooms can inherit this one and have the privacy field code. Here's the file:
#define PRIV_FILE __DIR__"allow.list"
#include <rooms.h>
inherit LIB_ROOM;
int privacy = 0;
string *trust = explode(read_file(PRIV_FILE), "\n");
for( int i = 0; i < sizeof(trust); i++ )
trust[i] = lower_case(trust[i]);
string owner = trust[0];
void create_workroom() { }
void init_workroom() { }
string SetPrivacy(int i);
string SetDesc(string str);
string GetDesc();
string DescPrivacy()
{
if( privacy )
return desc + "\n\
%^YELLOW%^The walls seem to be encased in a yellowish shield.%^RESET%^";
return desc;
}
string SetDesc( string str )
{
return desc = str;
}
string GetDesc()
{
return desc;
}
static void create()
{
room::create();
create_workroom();
SetDesc(this_object()->GetDesc())
SetLong((: DescPrivacy :));
}
void init()
{
::init();
init_workroom();
add_action("mod_privacy", ({ "privacy", "priv" }));
add_action("eventAllow", "allow");
add_action("eventReject", "reject");
}
int CanReceive( object sneak )
{
int ret;
object *living_stack;
if( !privacy )
return ::CanReceive(sneak);
living_stack = get_livings(sneak);
if( !living_stack || !arrayp(living_stack) )
living_stack = ({ sneak });
foreach( object ob in living_stack )
{
if( !archp(ob) && member_array(ob->GetKeyName(), trust) == -1 )
{
message("info", "You bounce off the privacy field.", ob);
message("info", ob->GetName()+" bounced off the privacy field.",
this_object());
if( !environment(ob) )
ob->eventMoveLiving(ROOM_START);
return 0;
}
}
ret = ::CanReceive(sneak);
if( ret )
tell_room(this_object(), "\n\nPRIVACY WARNING: "+identify(sneak)+
" has entered the room.\n\n", sneak);
return ret;
}
int set_privacy( int i )
{
object *npcs = filter(deep_inventory(this_object()),
(: living($1) && !interactive($1) :));
privacy = i;
SetProperty("no peer", i);
if( sizeof(npcs) )
{
foreach( object npc in npcs )
{
tell_room(this_object(), "Ejecting "+identify(npc), npc);
npc->eventMove(ROOM_FURNACE);
}
}
SetLong((: DescPrivacy :));
return privacy;
}
int mod_privacy( string str )
{
if( !archp(this_player()) &&
this_player()->GetKeyName() != lower_case(owner) )
{
write("You close your eyes, but nothing changes.");
say(this_player()->GetName()+" is trying to muck around with the privacy field system.");
return 1;
}
if( !str || (str != "off" && str != "on") )
{
if( privacy )
str = "off";
else
str = "on";
}
if( str == "on" )
{
set_privacy(1);
write("You close your eyes, and the walls shimmer briefly.");
say(this_player()->GetName()+" closes "+possessive(this_player())+
" eyes, and the walls shimmer briefly.");
return 1;
}
if( str == "off" )
{
set_privacy(0);
write("You close your eyes, and a gentle draft passes through the room.");
say(this_player()->GetName()+" closes "+possessive(this_player())+
" eyes, and a gentle draft passes through the room.");
return 1;
}
}