User:Daemonika Nightfire/Scripts/LinkNumber-List in llSetLinkPrimitiveParamsFast
< User:Daemonika Nightfire
Jump to navigation
Jump to search
Revision as of 22:24, 24 January 2015 by ObviousAltIsObvious Resident (talk | contribs) (<lsl> tag to <source>)
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 :)
// LinkNumber-List in llSetLinkPrimitiveParamsFast
// 11. Juli 2010 by Daemonika Nightfire
integer s;
list prims = [2,4];
default
{
touch_start(integer total_number)
{
integer i = ~llGetListLength(prims);
if(s == FALSE)
{
while (++i)
{
llSetLinkPrimitiveParamsFast(llList2Integer(prims,i),[PRIM_TEXT,"Hovertext",<1,1,1>,1]);
}
s = TRUE;
}
else if(s == TRUE)
{
while (++i)
{
llSetLinkPrimitiveParamsFast(llList2Integer(prims,i),[PRIM_TEXT,"",ZERO_VECTOR,0]);
}
s = FALSE;
}
}
}
Advanced example with two lists in the change
Also with four prims.
// LinkNumber-List in llSetLinkPrimitiveParamsFast
// 11. Juli 2010 by Daemonika Nightfire
integer s;
list prims = [1,3];
list prims2 = [2,4];
default
{
touch_start(integer total_number)
{
integer i = ~llGetListLength(prims);
integer i2 = ~llGetListLength(prims2);
if(s == FALSE)
{
while (++i && ++i2)
{
llSetLinkPrimitiveParamsFast(llList2Integer(prims,i),[PRIM_TEXT,"test",<1,1,1>,1]);
llSetLinkPrimitiveParamsFast(llList2Integer(prims2,i2),[PRIM_TEXT,"",ZERO_VECTOR,0]);
}
s = TRUE;
}
else if(s == TRUE)
{
while (++i && ++i2)
{
llSetLinkPrimitiveParamsFast(llList2Integer(prims,i),[PRIM_TEXT,"",ZERO_VECTOR,0]);
llSetLinkPrimitiveParamsFast(llList2Integer(prims2,i2),[PRIM_TEXT,"test",<1,1,1>,1]);
}
s = FALSE;
}
}
}
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.
// ╔════════════════════════════════−−−−−−−−−→
// ║ *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 Dae)
{
llResetScript();
}
}