script porte avec badge d accès

Répondre
Partager Rechercher
bonjour
je cherche un script qui ouvre une porte uniquement que si l on porte un badge, donc 2 scripts 1 pour la porte et 1 pour le badge qui communique ensemble
merci pour votre aide
Citation :
Publié par stefsparta
bonjour
je cherche un script qui ouvre une porte uniquement que si l on porte un badge, donc 2 scripts 1 pour la porte et 1 pour le badge qui communique ensemble
merci pour votre aide
hellow.....pas forcement besoin de 2 scripts....il suffit de mettre quelque chose comme ça dans la porte....en supposant que le gars qui toque à la porte porte un badge dont le nom est "badge" par exemple....mais tu peux l' appeler "petit bout de plastique fabriqué par une equipe de petits chinois dans le garrage 1203 de la province de Yakaimiter"

/////////
key toqueur;

default
{
state_entry()
{
}

touch_end(integer total_number)
{
toqueur = llDetectedKey(0);
state verif;
}
}


state verif
{
state_entry()
{
llSensor("badge", NULL_KEY, PASSIVE, 5.0, PI);
}

sensor(integer num)
{
if(llDetectedOwner(0) == toqueur)
{
llSay(0,llKey2Name(toqueur) + " a le badge requis");

/////////////////////////////////
//OUVERTURE OU fERMETURE PORTE ICI ...ou envoit vers un autre state etc//
/////////////////////////////////

state default;
}
}

no_sensor()
{
llSay(0,"Désolé"+ " "+llKey2Name(toqueur)+ " vous ne portez pas le badge qui va bien");

state default;
}
}

Dernière modification par MenthalOH ; 28/10/2019 à 17h58.
script avec badge d accès
Citation :
Publié par stefsparta
bonjour
je cherche un script qui ouvre une porte uniquement que si l on porte un badge, donc 2 scripts 1 pour la porte et 1 pour le badge qui communique ensemble
merci pour votre aide
voici le script de porte

vector ROTATION = <0.0, 0.0, 80.0>;

/*
* Define the position of the virtual hinge; usually this is half the door
* prim's width and thickness
*/
vector HINGE_POSITION = <-0.75, 0.02, 0.0>;

/*
* Define how fast the door opens, in seconds
*/
float SECONDS_TO_ROTATE = 1.0;

/*
* Define after how much time the door should close automatically, in seconds;
* set to 0.0 to disable autolmatic closing
*/
float AUTO_CLOSE_TIME = 45.0;

/*
* Define a sound that plays when the door starts to open; set to NULL_KEY
* for no sound.
*/
key SOUND_ON_OPEN = "e5e01091-9c1f-4f8c-8486-46d560ff664f";

/*
* Define a sound that plays when the door has closed; set to NULL_KEY
* for no sound.
*/
key SOUND_ON_CLOSE = "88d13f1f-85a8-49da-99f7-6fa2781b2229";

/*
* Define the volume of the opening and closing sounds
*/
float SOUND_VOLUME = 1.0;

/*
* NORMALLY, THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT. IF YOU DO
* YOU RISK BREAKING IT.
*/

integer gClosed; // Door state: TRUE = closed, FALSE = opened
rotation gRotationClosed; // Initial rotation of the door (closed)
vector gPositionClosed; // Initial position of the door (closed)
vector gRotationPerSecond; // The amount to rotate each second

doOpenOrClose() {
/*
* Only perform the rotation if the door isn't root or unlinked
*/
integer linkNumber = llGetLinkNumber();
if (linkNumber < 2)
return;

if (gClosed) {
/*
* Store the initial rotation and position so we can return to it.
*
* Rotating back purely by calculations can in the longer term cause the door
* to be positioned incorrectly because of precision errors
*
* We determine this everytime before the door is being opened in case it was
* moved, assuming the door was closed whilst being manipulated.
*/
gPositionClosed = llGetLocalPos();
gRotationClosed = llGetLocalRot();

/*
* Play the opening sound and preload the closing sound
*/
if (SOUND_ON_OPEN)
llPlaySound(SOUND_ON_OPEN, SOUND_VOLUME);
}

vector hingePosition = gPositionClosed + HINGE_POSITION * gRotationClosed;

/*
* Reset the timer and start moving
*/
llResetTime();
while (llGetTime() < SECONDS_TO_ROTATE) {
float time = llGetTime();
if (! gClosed)
/*
* Invert the timer for closing direction
*/
time = SECONDS_TO_ROTATE - time;

rotation rotationThisStep = llEuler2Rot(gRotationPerSecond * time) * gRotationClosed;
vector positionThisStep = hingePosition - HINGE_POSITION * rotationThisStep;
llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, rotationThisStep, PRIM_POS_LOCAL, positionThisStep]);
}

/*
* Set the new state
*/
gClosed = !gClosed;

if (gClosed) {
/*
* Finalize the closing movement
*/
llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, gRotationClosed, PRIM_POS_LOCAL, gPositionClosed]);

/*
* Play the closing sound and preload the opening sound
*/
if (SOUND_ON_CLOSE)
llPlaySound(SOUND_ON_CLOSE, SOUND_VOLUME);
if (SOUND_ON_OPEN)
llPreloadSound(SOUND_ON_OPEN);
} else {
/*
* Finalize the opening movement
*/
rotation rotationOpened = llEuler2Rot(ROTATION * DEG_TO_RAD) * gRotationClosed;
vector positionOpened = hingePosition - HINGE_POSITION * rotationOpened;
llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, rotationOpened, PRIM_POS_LOCAL, positionOpened]);

/*
* Preload the closing sound
*/
if (SOUND_ON_CLOSE)
llPreloadSound(SOUND_ON_CLOSE);

/*
* Set a timer to automatically close
*/
llSetTimerEvent(AUTO_CLOSE_TIME);
}
}

default {
state_entry() {
/*
* Assume the door is closed when the script is reset
*/
gClosed = TRUE;

/*
* These doesn't change unless the script is changed, calculate them once
*/
gRotationPerSecond = (ROTATION * DEG_TO_RAD / SECONDS_TO_ROTATE);

/*
* Preload the opening sound
*/
if (SOUND_ON_OPEN)
llPreloadSound(SOUND_ON_OPEN);
}
touch_start(integer agentCount) {
doOpenOrClose();
}
timer() {
llSetTimerEvent(0.0);

/*
* Close the door if it isn't already closed
*/
if (! gClosed)
doOpenOrClose();
}
}
bon, j' ai finalement refait un peu le truc...à mettre dans la porte, la largeur de la porte devant être en x en local...


///NE PAS LIER EN ROOT/////TOUJOURS MODIFIER EN POSITION FERMEE////

vector largeurPorte;

integer ouverture = 80;
integer gClosed;

key toqueur;

//////////////////

animation(float angle)
{
integer i;
do
{
vector posPorte = llGetLocalPos();
rotation rot = llAxisAngle2Rot(llRot2Up(llGetLocalRot()), DEG_TO_RAD * angle);
vector vecteur = -(largeurPorte / 2.0) * llGetLocalRot();//modif coté d' ouverture ajoutez ou enlevez "-"
vector posAxe = posPorte - vecteur;
vector rotVecteur = vecteur * rot;
vector nouvellePosition = posAxe + rotVecteur;

if(llGetLinkNumber()>0)
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, llGetLocalRot() * rot/ llGetRootRotation(),
PRIM_POSITION, nouvellePosition]);

}
else
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, llGetRot() * rot,
PRIM_POSITION, nouvellePosition]);
}
}

while(++i<= ouverture);
}
////////////////////

default
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
}

touch_end(integer total_number)
{
toqueur = llDetectedKey(0);
state verif;
}
}


state verif
{
state_entry()
{
llSensor("badge", NULL_KEY, PASSIVE, 5.0, PI);
vector dimensions = llGetScale();
largeurPorte = <dimensions.x, .0, .0>;
}

sensor(integer num)
{
if(llDetectedOwner(0) == toqueur)
{
llSay(0,llKey2Name(toqueur) + " a le badge requis");

/////////////////////////////////
//OUVERTURE OU fERMETURE PORTE ICI ...ou envoit vers un autre state etc//
/////////////////////////////////

if(gClosed)
{
llPlaySound("cb340647-9680-dd5e-49c0-86edfa01b3ac", 1.0);
animation(1.0);
gClosed = !gClosed;
state default;
}

else
{
llPlaySound("e7ff1054-003d-d134-66be-207573f2b535", 1.0);
animation(-1.0);
gClosed = !gClosed;
state default;
}
}
}

no_sensor()
{
llSay(0,"Désolé"+ " "+llKey2Name(toqueur)+ " vous ne portez pas le badge qui va bien");

state default;
}

}
script avec badge d accès
merci beaucoup quand je met le script dans la porte et le script dans un badge que je porte
voici ce que j ai Désolé vous ne portez pas le badge qui va bien
et bien sur la porte ne s ouvre pas
j ai du rater une étape non?
pourquoi tu veux mettre un script dans le badge ?....le script dans la porte cherche juste un objet nommé "badge"....quoique, j' avais testé avec un badge posé....pas porté....attends.....ok, vu, il faut se servir d'une autre fonction pour verif le port du badge....ça vient....là, ça devrait le faire...




///NE PAS LIER EN ROOT/////TOUJOURS MODIFIER EN POSITION FERMEE////

vector largeurPorte;

integer ouverture = 80;
integer gClosed;

key toqueur;

list objets ;
list cleobjets ;
list objetcherche ;

//////////////////

animation(float angle)
{
integer i;
do
{
vector posPorte = llGetLocalPos();
rotation rot = llAxisAngle2Rot(llRot2Up(llGetLocalRot()), DEG_TO_RAD * angle);
vector vecteur = -(largeurPorte / 2.0) * llGetLocalRot();//modif coté d' ouverture ajoutez ou enlevez "-"
vector posAxe = posPorte - vecteur;
vector rotVecteur = vecteur * rot;
vector nouvellePosition = posAxe + rotVecteur;

if(llGetLinkNumber()>0)
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, llGetLocalRot() * rot/ llGetRootRotation(),
PRIM_POSITION, nouvellePosition]);

}
else
{
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, llGetRot() * rot,
PRIM_POSITION, nouvellePosition]);
}
}

while(++i<= ouverture);
}
////////////////////

default
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
}

touch_end(integer total_number)
{
toqueur = llDetectedKey(0);
state verif;
}
}


state verif
{
state_entry()
{
vector dimensions = llGetScale();
largeurPorte = <dimensions.x, .0, .0>;

cleobjets = llGetAttachedList(toqueur);
objets = [];

objetcherche =["badge"];

integer i;
while (i < llGetListLength(cleobjets) )
{
list temp = llGetObjectDetails(llList2Key(cleobjets,i),[OBJECT_NAME]);

objets += [llList2String(temp,0)];
++i;
}

integer index = llListFindList(objets, objetcherche);

if(index == -1)
{
llSay(0,"Désolé"+ " "+llKey2Name(toqueur)+ " vous ne portez pas le badge qui va bien");

state default;
}

else
{
llSay(0,llKey2Name(toqueur) + " a le badge requis");

if(gClosed)
{
llPlaySound("cb340647-9680-dd5e-49c0-86edfa01b3ac", 1.0);
animation(1.0);
gClosed = !gClosed;

state default;
}

else if(!gClosed)
{
llPlaySound("e7ff1054-003d-d134-66be-207573f2b535", 1.0);
animation(-1.0);
gClosed = !gClosed;
state default;
}
}
}
}

Dernière modification par MenthalOH ; 29/10/2019 à 21h45.
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés