Probleme de script

Répondre
Partager Rechercher
Bonjour a tous voila je suis nouveau dans le build et j'ai crée un halogène avec 2 script et les script ne marche pas quand je pose l'objet j'ai bien le tableau de commande mais pas la lumière mais quand j'édit l'objet il marche a merveille alors voila qui pourrais m'aider

premier script
Code:
 //prim colour

vector red = <0.86,0.0,0.14>; 
vector green  = <0,0.9,0>; 
vector white  = <1,1,1>;
vector black  = <0.12,0.1,0.12>;
vector steel  = <0.27,0.51,0.71>;
vector blue  = <0.1,0.31,0.98>;
vector orange  = <1,.6,0>;
vector yellow  = <1,1,0.1>;
vector brown  = <0.5,0.25,0>;
vector pink  = <0.85,0,0.75>;
vector purple  = <0.8,0.21,0.8>;
vector lime  = <0.18,0.75,0.34>;


float intensity;
float radius;
float falloff;
vector colour;
integer toggle;
vector pColour;
float alpha = 1.0;

integer channel;

default
{
    state_entry()
    {
        channel = llRound(llFrand(2000000.0)) + 1;
        llListen(channel, "", llGetOwner(), ""); 
        pColour = (vector) llList2String(llGetPrimitiveParams([PRIM_COLOR, 1]),0);
        alpha = llGetAlpha(ALL_SIDES);
        intensity = (float) llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),2);
        radius    = (float) llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),3);
        falloff   = (float)  llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),4);
        colour    = (vector) llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),1);
        toggle    = (integer)  llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),0);
    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
    
    touch_start(integer total_number)
    {
llDialog(llDetectedKey(0), "Light menu", ["radius", "falloff", "alpha", "prim colour", "light colour", "intensity", "full bright", "on/off", "store"], channel);   
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if (message == "store")
        {
            llResetScript();
        }
        
        if (message == "radius")
        {
            llDialog(id, "Radius menu", ["+", "++", "+++", "-", "--", "---"], channel);
        }
        
        if (message == "+")
        {
            radius += 0.5;
            if (radius > 20) {radius = 20;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "++")
        {
            radius += 1;
            if (radius > 20) {radius = 20;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "+++")
        {
            radius += 5;
            if (radius > 20) {radius = 20;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }    
        if (message == "-")
        {
            radius -= 0.5;
            if (radius < 1) {radius = 1;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "--")
        {
            radius -= 1;
            if (radius < 1) {radius = 1;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "---")
        {
            radius -= 5;
            if (radius < 1) {radius = 1;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        if (message == "prim colour")
        {
            llDialog(id, "Prim colour menu", ["p.red","p.green","p.white","p.black","p.steel","p.blue","p.orange","p.yellow","p.brown","p.pink","p.purple","p.lime"], channel);
        }   
        
        if (llGetSubString(message,0,1) == "p.")
        {
            string c = llGetSubString(message,2,-1);
            
            if (c == "brown")
            {
                pColour = brown;
            }
            if (c == "pink")
            {
                pColour = pink;
            }

            if (c == "purple")
            {
                pColour = purple;
            }
            if (c == "lime")
            {
                pColour = lime;
            }
            
            if (c == "yellow")
            {
                pColour = yellow;
            }
            if (c == "orange")
            {
                pColour = orange;
            }    
            if (c == "blue")
            {
                pColour = blue;
            }
            if (c == "steel")
            {
                pColour = steel;
            }
            if (c == "black")
            {
                pColour = black;
            }
            if (c == "white")
            {
                pColour = white;
            }
            if (c == "red")
            {
                pColour = red;
            }
            if (c == "green")
            {
                pColour = green;
            }
            llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, pColour, alpha]);
        }
        
        
        if (message == "light colour")
        {
            llDialog(id, "Light colour menu", ["l.red","l.green","l.white","l.black","l.steel","l.blue","l.orange","l.yellow","l.brown","l.pink","l.purple","l.lime"]   , channel);   
        }
        
        if (llGetSubString(message,0,1) == "l.")
        {
            string c = llGetSubString(message,2,-1);
            
            if (c == "brown")
            {
                colour = brown;
            }
            if (c == "pink")
            {
                colour = pink;
            }

            if (c == "purple")
            {
                colour = purple;
            }
            if (c == "lime")
            {
                colour = lime;
            }
            
            if (c == "yellow")
            {
                colour = yellow;
            }
            if (c == "orange")
            {
                colour = orange;
            }    
            if (c == "blue")
            {
                colour = blue;
            }
            if (c == "steel")
            {
                colour = steel;
            }
            if (c == "black")
            {
                colour = black;
            }
            if (c == "white")
            {
                colour = white;
            }
            if (c == "red")
            {
                colour = red;
            }
            if (c == "green")
            {
                colour = green;
            }
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        // Intensity toggle
        if (message == "intensity")
        {
            llDialog(id, "Intensity menu", ["i.0 %","i.10 %","i.20 %","i.30 %","i.40 %","i.50 %","i.60 %","i.70 %","i.80 %","i.90 %","i.100 %"], channel);   
        }
        
        if (message == "falloff")
        {
            llDialog(id, "fall off menu", ["f.0 %","f.20 %","f.40 %","f.60 %","f.80 %","f.100 %","f.120 %","f.140 %","f.160 %","f.180 %","f.200 %"], channel);   
        }

        if (message == "alpha")
        {
            llDialog(id, "Intensity menu", ["a.5 %","a.10 %","a.20 %","a.30 %","a.40 %","a.50 %","a.60 %","a.70 %","a.80 %","a.90 %","a.100 %"], channel);   
        }


        
        if (llGetSubString(message,0,1) == "i.")
        {
            list templist = llParseString2List(message,[" "], []);
            intensity = (float) llGetSubString(llList2String(templist,0),2,-1);
            intensity = intensity * 0.01;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        if (llGetSubString(message,0,1) == "a.")
        {
            list templist = llParseString2List(message,[" "], []);
            alpha = (float) llGetSubString(llList2String(templist,0),2,-1);
            alpha = alpha * 0.01;
            llSetAlpha(alpha, ALL_SIDES);
        }

        
        if (llGetSubString(message,0,1) == "f.")
        {
            list templist = llParseString2List(message,[" "], []);
            falloff = (float) llGetSubString(llList2String(templist,0),2,-1);
            falloff = falloff * 0.01;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        // full brigth toggle
        if (message == "full bright")
        {
            llDialog(id, "Full bright menu", ["fb.on", "fb.off"], channel);   
        }
        if (message == "fb.on")
        {
            llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
        }
        if (message == "fb.off")
        {
            llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
        }
        
        // on off menu
        if (message == "on/off")
        {
            llDialog(id, "On off switch menu", ["t.on", "t.off"], channel);
        }
        if (message == "t.on")
        {
            toggle = TRUE;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "t.off")
        {
            toggle = FALSE;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
    }
}
et le deuxième

Code:
 // Lampe - Auteur: http://lslblog.free.fr

// Canal de communication entre l'interrupteur et la lampe
integer gCanal = -1500;

// Adresse d'écoute de l'interrupteur
integer gListener;

// Donne à la lampe l'intensité lumineuse passée en paramètre
AllumeLampe(float intensite)
{
    llSetPrimitiveParams([PRIM_POINT_LIGHT] + llListReplaceList(llGetPrimitiveParams([PRIM_POINT_LIGHT]), [intensite], 2, 2));
}

default
{
    state_entry()
    {
        llListen(llRound(llFrand(2000000.0)) + 1, "", NULL_KEY, "");
    }  
   
    // Ecoute et analyse les messages reçus
    listen(integer channel, string name, key id, string message)
    {
        AllumeLampe((float) message / 100.);
    }
}
Voila ce son des script que j'ai trouver sur ce site et dont j'ai mis un très légère touche personnel pour ma convenance mais bon je ne suis que un noob niveau script j'en comprend que une partie infime
Bonjour

je ne suis peut etre pas encore reveiller, mais ya une chose qui me surprend,
le canal de discution est aleatoire , comment fait donc la lampe pour recevoir le bon canal ?

si je dis au conn.. c'est p'tres que je suis en train de boire mon Café
__________________
Paris 1900
http://www.paris1900.net
...
j'ai bien compris que mes script ne pouvais pas communiquer ensemble vue que il ne son pas relier par un canal et que il fonctionne que quand j'édit il doivent pouvoir communique par le fait que je les édit donc que j'interagis sur les 2 script donc ça fonctionne et il communique par l'outil d'édition

alors qui pourrais me donner la marche a suivre pour régler mon problème je suis aussi joignable IG sous le même pseudo en tous cas merci pour votre éclaircissage qui m'aide déjà beaucoup a comprendre le problème

en attendant je vais chercher sur le net des ligne de commande pour la communication des 2 script
Au fond, Acham, tu cherches une paire de scripts pour qu'un clic sur une prim A (interrupteur) allume une prim B (lampe ou ampoule).

Si c'est ça, j'ai ce que tu cherches, et tu peux me contacter IG
Je reviens sur ce post car lisant les scripts de Acham qui doivent fonctionner à merveille...mais me chagrine un peu quand au code

si je reprends une partie de son script


Code PHP:

        if (llGetSubString(message,0,1) == "p.")
        {
            
string c llGetSubString(message,2,-1);
            
            if (
== "brown")
            {
                
pColour brown;
            }
            if (
== "pink")
            {
                
pColour pink;
            }

            if (
== "purple")
            {
                
pColour purple;
            }
            if (
== "lime")
            {
                
pColour lime;
            }
            
            if (
== "yellow")
            {
                
pColour yellow;
            }
            if (
== "orange")
            {
                
pColour orange;
            }    
            if (
== "blue")
            {
                
pColour blue;
            }
            if (
== "steel")
            {
                
pColour steel;
            }
            if (
== "black")
            {
                
pColour black;
            }
            if (
== "white")
            {
                
pColour white;
            }
            if (
== "red")
            {
                
pColour red;
            }
            if (
== "green")
            {
                
pColour green;
            }
            
llSetPrimitiveParams([PRIM_COLORALL_SIDESpColouralpha]);
        } 
1. Penser au else if...
2. quand on a une succession interminable de if ... se dire qu'il doit y avoir une autre solution...

La solution aurait pu être par exemple une liste comprenant une succession de paires
Code PHP:

list colors =[  "red" ,   <0.86,0.0,0.14>,
                      
"green" , <0,0.9,0etc... 
ce qui donnerait:

Code PHP:

         if (llGetSubString(message,0,1) == "p.")
     {
        
string c llGetSubString(message,2,-1);

        
integer index llListFindList(colors, [c]);
        if (
index != -1)
            
pColour llList2Vector(colors,index+1);

         
llSetPrimitiveParams([PRIM_COLORALL_SIDESpColouralpha]);
    } 
That is all...

Amicalement,
Répondre

Connectés sur ce fil

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