Difference between revisions of "User:Daemonika Nightfire/Scripts/LinkNumber-List in llSetLinkPrimitiveParamsFast"
Kireji Haiku (talk | contribs) m (improved readability of first example script and changed linknumber list to contain integers instead of string ( lol ?!?! )) |
Kireji Haiku (talk | contribs) m (edited second example script to improve readability) |
||
Line 25: | Line 25: | ||
integer index = ~llGetListLength(listOfPrimsToChange); | integer index = ~llGetListLength(listOfPrimsToChange); | ||
// black and transparent | // black and transparent | ||
if(switch) | if(switch) | ||
while (++index) | while (++index) | ||
llSetLinkPrimitiveParamsFast(llList2Integer(listOfPrimsToChange, index), | llSetLinkPrimitiveParamsFast(llList2Integer(listOfPrimsToChange, index), | ||
[PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]); | [PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]); | ||
// white and opaque | // white and opaque | ||
else | else | ||
while (++index) | while (++index) | ||
Line 44: | Line 44: | ||
// LinkNumber-List in llSetLinkPrimitiveParamsFast | // LinkNumber-List in llSetLinkPrimitiveParamsFast | ||
// 11. Juli 2010 by Daemonika Nightfire | // 11. Juli 2010 by Daemonika Nightfire | ||
list firstListOfPrimsToChange = [1, 3]; | |||
list secondListOfPrimsToChange = [2, 4]; | |||
integer switch; | |||
default | default | ||
{ | { | ||
touch_start(integer total_number) | touch_start(integer total_number) | ||
{ | { | ||
integer | // toggle between TRUE (1) and FALSE (0) | ||
integer | switch = !switch; | ||
if( | |||
integer firstIndex = ~llGetListLength(firstListOfPrimsToChange); | |||
while (++ | integer secondIndex = ~llGetListLength(secondListOfPrimsToChange); | ||
llSetLinkPrimitiveParamsFast(llList2Integer( | if(switch) | ||
while (++firstIndex && ++secondIndex) | |||
llSetLinkPrimitiveParamsFast(llList2Integer(firstListOfPrimsToChange, firstIndex), | |||
// black and transparent | |||
[PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE, | |||
else | PRIM_LINK_TARGET, llList2Integer(secondListOfPrimsToChange, secondIndex), | ||
// white and opaque | |||
while (++ | PRIM_TEXT, "put some hovertext blabla here", <1.0, 1.0, 1.0>, (float)TRUE]); | ||
else | |||
llSetLinkPrimitiveParamsFast(llList2Integer( | while (++firstIndex && ++secondIndex) | ||
llSetLinkPrimitiveParamsFast(llList2Integer(firstListOfPrimsToChange, firstIndex), | |||
// white and opaque | |||
[PRIM_TEXT, "put some hovertext blabla here", <1.0, 1.0, 1.0>, (float)TRUE, | |||
PRIM_LINK_TARGET, llList2Integer(secondListOfPrimsToChange, secondIndex), | |||
// black and transparent | |||
PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]); | |||
} | } | ||
} | } |
Revision as of 10:09, 9 October 2012
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
LinkNumber-List in llSetLinkPrimitiveParamsFast
With this small script I want to prove that it is possible in llSetLinkPrimitiveParams the link points to put into a list.
It is especially interesting when multiple prims are a linksets changed. For example, it must not be written for each link number, a new complete llSetLinkPrimitiveParams. When would be a very large number of prims is too much work.
Example
For this example I have just only 4 prims linked together and only one script in the root of the linksets laid.
I opted for the touch to click the option to get to see what :)
Have fun with my snippet :) <lsl> // LinkNumber-List in llSetLinkPrimitiveParamsFast // 11. Juli 2010 by Daemonika Nightfire
list listOfPrimsToChange = [2, 4]; integer switch;
default {
touch_start(integer total_number) { // toggle between TRUE (1) and FALSE (0) switch = !switch;
integer index = ~llGetListLength(listOfPrimsToChange);
// black and transparent if(switch) while (++index) llSetLinkPrimitiveParamsFast(llList2Integer(listOfPrimsToChange, index), [PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]); // white and opaque else while (++index) llSetLinkPrimitiveParamsFast(llList2Integer(listOfPrimsToChange, index), [PRIM_TEXT, "put some hovertext blabla here", <1.0, 1.0, 1.0>, (float)TRUE]); }
} </lsl>
Advanced example with two lists in the change
Also with four prims. <LSL> // LinkNumber-List in llSetLinkPrimitiveParamsFast // 11. Juli 2010 by Daemonika Nightfire list firstListOfPrimsToChange = [1, 3]; list secondListOfPrimsToChange = [2, 4]; integer switch;
default {
touch_start(integer total_number) { // toggle between TRUE (1) and FALSE (0) switch = !switch;
integer firstIndex = ~llGetListLength(firstListOfPrimsToChange); integer secondIndex = ~llGetListLength(secondListOfPrimsToChange);
if(switch) while (++firstIndex && ++secondIndex) llSetLinkPrimitiveParamsFast(llList2Integer(firstListOfPrimsToChange, firstIndex), // black and transparent [PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE, PRIM_LINK_TARGET, llList2Integer(secondListOfPrimsToChange, secondIndex), // white and opaque PRIM_TEXT, "put some hovertext blabla here", <1.0, 1.0, 1.0>, (float)TRUE]); else while (++firstIndex && ++secondIndex) llSetLinkPrimitiveParamsFast(llList2Integer(firstListOfPrimsToChange, firstIndex), // white and opaque [PRIM_TEXT, "put some hovertext blabla here", <1.0, 1.0, 1.0>, (float)TRUE, PRIM_LINK_TARGET, llList2Integer(secondListOfPrimsToChange, secondIndex), // black and transparent PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]); }
} </LSL>
Optimized version with dynamic LinkList by LinkName
german description inside the Script for the moment
This Exsample change the Color oft all Prims from the List wich you rename with the same Name. <LSL> // ╔════════════════════════════════−−−−−−−−−→ // ║ *DS* GetLinkNumbers of LinkNames (linkset) © by Daemonika Nightfire (daemonika.nightfire) // ╚═══════════════════−−−−−−−−−→
integer schalter = FALSE; // status fuer den schalter im touch Event
string LinkName = "PRIM"; // festgelegter name fuer die gewuenschten Prims list LinkNumber = []; // leere Liste
GetNumber() // funktion aus mehreren Events abrufbar {
integer i; for(i = 0; i <= llGetNumberOfPrims(); i++) // zaehlt die Prims durch { if(llGetLinkName(i) == LinkName) // ueberprueft die Namen { LinkNumber += i; // fuegt die Linknummer des prims mit richtigen Namen der Liste hinzu } }
}
default {
state_entry() { GetNumber(); // ruft die Funktion auf } touch_start(integer total_number) { vector color; if(schalter == FALSE) { color = <0,1,0>; schalter = TRUE; } else if(schalter == TRUE) { color = <1,0,0>; schalter = FALSE; } integer i = ~llGetListLength(LinkNumber); // ruft die Liste mit den LinkNummern auf while(++i) // geht jede linknummer einzeln durch { llSetLinkPrimitiveParamsFast(llList2Integer(LinkNumber,i),[PRIM_COLOR,ALL_SIDES,color,1.0]); // setzt die gewuenschten Parameter } } changed(integer change) { if(change & CHANGED_LINK) // ueberprueft ob sich das linkset aendert und sich dadurch die Linknummern verschieben { LinkNumber = []; // loescht die liste, um mit einer leeren erneut zu beginnen GetNumber(); // ruft die Funktion auf } } on_rez(integer start) { llResetScript(); }
} </LSL>