Porte Diaphragme avec autorisation PDF Imprimer Envoyer
Technique - Scripts
Écrit par ssm2017   
Jeudi, 15 Novembre 2007 02:00
Ce script permet de creer une porte s'ouvrant comme un diaphragme
 
//ssm2017_authdoor_diaph
// @copyright  Copyright (C) 2007 ssm2017 Binder (S.Massiaux). All rights reserved. 
// @license  GNU/GPL, http://www.gnu.org/licenses/gpl-2.0.html 
// ssm2017_authdoor_diaph is free software. This version may have been modified pursuant to the 
// GNU General Public License, and as distributed it includes or is derivative 
// of works licensed under the GNU General Public License or other free or open 
// source software licenses.  
//================ 
// messages 
//================ 
// non autorise 
string no_auth_msg1 = "Desole ";
string no_auth_msg2 = " mais vous n'etes pas autorise(e) a ouvrir cette porte."; 
// autorise
string auth_msg1 = "Bienvenue ";
string auth_msg2 = " dans notre palais.";
//=============== 
// door options 
//=============== 
vector closed;
//XYZ Coordinates of the closed door 
vector open;
//XYZ Coordinates of the opened door
float time = 10.0;
//time before the door close itself
float speed = 0.1;
//speed to open and close the door
//============
// sound uuid 
//============ 
key sound = "07cccfd5-62e5-fbf3-0e91-6944d952ef0f";
//===============
// notecard vars
//=============== 
integer iLine = 0;
key authNoteCard;
list auth; 
//=============
// door params
//=============
list params;
float size;
integer opened;
default
{
    state_entry()
    {
        closed = llGetPos();
        // reset auth list
        auth = [];
        // read the notecard
        authNoteCard = llGetNotecardLine("auth",iLine);
        // preload the sound
        llPreloadSound(sound);
        // get the door params
        params = llGetPrimitiveParams([PRIM_TYPE]);
        size = llList2Float(params,3);
    }
    touch_start(integer total_number)
    {
        // check if avatar that touched is in the list
        if ( ~llListFindList( auth, (list)(llDetectedName(0)) ))
        {
            llSay(0,auth_msg1+ llDetectedName(0) + auth_msg2);
            llPlaySound(sound,1);
            while ( size < 0.99 )
            {
                size = size + speed;
                params = llListReplaceList(params,[size],3,3);
                llSetPrimitiveParams([PRIM_TYPE] + params);
            }
            llSetTimerEvent(time);
        }
        else
        {
            llSay(0,no_auth_msg1+ llDetectedName(0) + no_auth_msg2);
        }
    }
    dataserver(key queryId, string data)
    {
        if(queryId == authNoteCard)
        {
            if(data != EOF)
            {
                auth += [data];
                authNoteCard = llGetNotecardLine("auth",++iLine);
            }
        }
    }
    timer()
    {
        llPlaySound(sound,1);
        while ( size > 0.0 )
        {
            size = size - speed;
            params = llListReplaceList(params,[size],3,3);
            llSetPrimitiveParams([PRIM_TYPE] + params);
        }
        llResetScript();
    }
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY) //note that it's & and not &&... it's bitwise!
        {
            llResetScript();
        }
    }
}