Wednesday, November 26, 2008

Region wide door w/ Master Controller

Ok, Zanthar on OS Scripters asked about a region wide door... figured I'd code in a blog post for a minute...

Concept - Master Controller that you would list all the names in, slave door script that would talk to the master controller.

**** Note. I never tried to compile this ******

Master Controller
--


default
{
list validusers = ["Redbeard McCellan"];

state_entry()
{
llSetName("DOORCONTROLLER");
llListen(-8988,"", NULL_KEY, "");
//Randomly picked a channel, but it needs to be static.
}

listen( integer channel, string name, key id, string message )
{
if(llListFindList(validusers,(list)message) != -1)
{
llRegionSay(-8989,(string)id);
}
}

}




Door Script
--
default
{
state_entry()
{
llListen(-8989, "DOORCONTROLLER", NULL_KEY, (string)llGetKey());
//Randomly picked a channel, but it needs to be static.
}

touch_start(integer total_number)
{
llRegionSay(-8988, (string)llDetectedName(0));
}


listen( integer channel, string name, key id, string message )
{
if(message == (string)llGetKey()) //expects back the it's own key if it is supposed to open
{
llSetTimerEvent(15);
llSetAlpha(0,ALL_SIDES);
llSetStatus(STATUS_PHANTOM,TRUE);
}
}

timer()
{
llSetTimerEvent(0);
llSetAlpha(1,ALL_SIDES);
llSetStatus(STATUS_PHANTOM,FALSE);
}
}

Lazy

I suppose I should get back into posting here.....

Official Second Life Blog