Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Cobining of 2 door scripts

Markie Reifsnider
Registered User
Join date: 22 Apr 2007
Posts: 5
12-30-2007 01:14
Hello everybody :-)

I have a "little" problem...
i have bought a house with an amazing door script. But the problem is ...only i can open the doors :-( and i wish that my SL family can open the doors to. Now i have also a door script that works with a notecard.

Now i have tried to combine the 2 scripts meself for the last 2 weeks but to no avail :-(

I really hope that someone can help me....PLZ...

the first one is the one that came with the house and the second one that with the notecard
For all those who are going to fiddle/help me with it...THX in advance!!!

this are the 2 scripts:

default
{
state_entry()
{
llListen(0, "", llGetOwner(), "";);
}

listen(integer channel, string name, key id, string message)
{
if (message == "lock";) {
llSay(0, "locked";);
state locked;
}
}
touch_start(integer total_num)
{
llTriggerSound("Door open", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state open;
}
}

state open
{
state_entry()
{
llSetTimerEvent(5);
llListen(0, "", llGetOwner(), "";);
}

listen(integer channel, string name, key id, string message)
{
if (message == "lock";){
llSay(0, "locked";);
state lockopen;
}
}
touch_start(integer total_num)
{
llTriggerSound("Door close", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state default;
}
timer()
{
llTriggerSound("Door close", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state default;
}
}

state locked
{
state_entry()
{
llListen(0, "", llGetOwner(), "";);
}

listen(integer channel, string name, key id, string message)
{
if (message == "unlock";) {
llSay(0, "unlocked";);
state default;
}
}
touch_start(integer total_num)
{
if (llDetectedKey(0) == llGetOwner()) {
llTriggerSound("Door open", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state lockopen;
} else {
llTriggerSound("Door knock", 0.5);
}
}
}

state lockopen
{
state_entry()
{
llListen(0, "", llGetOwner(), "";);
llSetTimerEvent(5);
}

listen(integer channel, string name, key id, string message)
{
if (message == "unlock";) {
llSay(0, "unlocked";);
state open;
}
}
touch_start(integer total_num)
{
if (llDetectedKey(0) == llGetOwner()) {
llTriggerSound("Door close", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state locked;
}
}
timer()
{
llTriggerSound("Door open", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state locked;
}
}
-------------------------------------------------------------------------------------------
script with notecard

key nrofnamesoncard;
integer nrofnames;
list names;
list keynameoncard;
string nameoncard;
string storedname;

default
{
state_entry()
{
llOwnerSay("Startup state reading whitelist notecard";);
nrofnamesoncard = llGetNumberOfNotecardLines("whitelist";);
}

dataserver (key queryid, string data){

if (queryid == nrofnamesoncard)
{

nrofnames = (integer) data;
llOwnerSay("Found "+(string)nrofnames+ " names in whitelist.";);

integer i;
for (i=0;i < nrofnames;i++){
keynameoncard += llGetNotecardLine("whitelist", i);
}
} else
{
integer listlength;
listlength = llGetListLength(keynameoncard);
integer j;
for(j=0;j<listlength;j++) {
if (queryid == (key) llList2String(keynameoncard,j))
{
llOwnerSay("Name added to whitelist: "+data);
names += data;
}
}
}

if (llGetListLength(names) == nrofnames)
{
llOwnerSay ("Read the complete notecard going to state closed now. Finished configuration";);
state closed;
}



}


}

state closed
{
state_entry()
{
llListen(2,"",llGetOwner(),"";);
}

touch_start(integer total_number)
{
integer j;
for (j=0;j<llGetListLength(names);j++)
{
if (llList2String(names, j) == llDetectedName(0)){
vector test;
rotation rot;
test.x = 0;
test.y = 0;
test.z = 0.5 * PI;

rot = llEuler2Rot(test);
llSetRot(rot);
state open;
}
}
}

}

state open
{
state_exit()
{
integer j;
for (j=0;j<llGetListLength(names);j++)
{
if (llList2String(names, j) == storedname){
vector test;
rotation rot;
test.x = 0;
test.y = 0;
test.z = 0 * PI;

rot = llEuler2Rot(test);
llSetRot(rot);

}
}
}

touch_start(integer total_number)
{
storedname = llDetectedName(0);
state closed;
}
}


----------------------------------------------------------------------------
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-30-2007 03:09
something a little simpler, but it shows you how to modify the script you want

this is the original
CODE

//--// v7-D Feebie Type 1 Door Script //--//
//--// Works At ANY Angle //--//

//-- works in ANY single prim door, linked or un-linked
//-- works in muti prim doors NOT linked to a larger structure
//-- REQUIREMENTS: a cut root prim, suggest cube, pathcut start=.125, end=.625
//-- CAVEAT: single prim doors are limited to 5m width

//--// USERS MODIFY HERE v
integer vgIntDoorSwing = 90;
//-- use -# to reverse the direction of swing, eg. -90;

rotation vgRotDoorSwing;


default{
state_entry(){
vgRotDoorSwing = llEuler2Rot( <.0, .0, (float)vgIntDoorSwing * DEG_TO_RAD> );
llGetNotecardLine( llGetScriptName() + " - allow", gIntNotecardLine );
}

touch_start( integer vIntTouches ){
//- small hack to reverse direction of swing on each
//- touch & avoid lsl funkiness regarding rotation division
vgRotDoorSwing.s *= -1;

//-- like sounds? add one here!
llSetLocalRot( vgRotDoorSwing * llGetLocalRot() );
}
}

//-- IF Redistributing as-is:
//-- Please leave script full permissions & include all comments


this is the update with notecard access
CODE

//--// v7-D Feebie Type 1 Door Script //--//
//--// Works At ANY Angle //--//

//-- works in ANY single prim door, linked or un-linked
//-- works in muti prim doors NOT linked to a larger structure
//-- REQUIREMENTS: a cut root prim, suggest cube, pathcut start=.125, end=.625
//-- CAVEAT: single prim doors are limited to 5m width

//--// USERS MODIFY HERE v
integer vgIntDoorSwing = 90;
//-- use -# to reverse the direction of swing, eg. -90;

list gLstAllowedNames; //-- new
integer gIntNotecardLine; //-- new
rotation vgRotDoorSwing;


default{
state_entry(){
vgRotDoorSwing = llEuler2Rot( <.0, .0, (float)vgIntDoorSwing * DEG_TO_RAD> );
llGetNotecardLine( llGetScriptName() + " - allow", gIntNotecardLine ); //-- new
}

//-- new section
dataserver( key vKeyNull, string vStrData ){
if (EOF != vStrData){
gLstAllowedNames += llToLower( llStringTrim( vStrData, STRING_TRIM ) );
llGetNotecardLine( llGetScriptName() + " - allow", ++gIntNotecardLine );
}
}

touch_start( integer vIntTouches ){
if (~llListFindList( gLstAllowedNames, (list)llToLower( llDetectedName( 0 ) ) )){ //-- new
//- small hack to reverse direction of swing on each
//- touch & avoid lsl funkiness regarding rotation division
vgRotDoorSwing.s *= -1;

//-- like sounds? add one here!
llSetLocalRot( vgRotDoorSwing * llGetLocalRot() );
} //-- new
}

//-- new section
changed( integer vIntChanged ){
if (CHANGED_INVENTORY & vIntChanged){
llResetScript();
}
}
}

//-- IF Redistributing as-is:
//-- Please leave script full permissions & include all comments


in this example the note card should have the same names as the script + ' - allow'
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Markie Reifsnider
Registered User
Join date: 22 Apr 2007
Posts: 5
12-30-2007 04:24
THX...i going to fiddle with it...hahaha

and this way i learn more and more about scripting :-)