Jump to content

primset - bulk prim property setter


Rufus Darkfold
 Share

You are about to reply to a thread that has been inactive for 4509 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

This is a bulk prim property setter.  It can set or query anything that can be set with llSet/GetLinkPrimitiveParams
for every prim in the link set, or any subset.   It responds to chat commands on channel 884 (change by editing the variable "channel").

Click on the object to select it, then it will start listening for chat commands.    The listen will time out after 5 minutes of inactivity.
Once the object has been selected,  individual prims within the linkset can be selected or de-selected by clicking them or by chat commands.

Chat commands are:
Optional prefix of  "/" followed by output chat channel number  (note that only case 2 below generates output)
Optional prefix enclosed in brackets "[ ]" with list of child id numbers or child object names to select.  "[*]" selects all prims individually,

No list uses existing selection list.
Followed by:
1. a list of parameters to pass to llSetLinkPrimitiveParamsFast
or
2. "?" followed by parameters to pass to llGetLinkPrimitiveParams

When the object is initially selected, the selection list (of prims within the object) is empty.
Prims may be selected by clicking on them or the whole selection list may be replaced with the "[ ]" chat syntax.
An empty selection list will default to LINK_SET for Set (case #1) and LINK_ROOT for Get (case #2).
If there are multiple prims selected (including "[*]") the Set or Get will be repeated for each one.

All lists entered above are separated by commas
.

Example commands:

25,-1,0.1               Set glow parameter for all sides of previously-selected prim(s) to 0.1
/886 [2,3,4] ?21        Get flexi parameters for child indices 2,3 & 4  whisper on 886
[*] ?7                  Get size of each prim in the link set, whisper on channel 0.
[foo] 27,bar            Rename all prims named "foo" to "bar".

 

I have a HUD to provide a GUI for setting the flexi and light-related parameters.

The list_cast function is in the script library archive.

 

//primset - v0.3 - bulk set prim properties by chat message
// need to include list_cast function from sl script library
integer channel = 884; //channel to listen on
float timeout = 300; // stop listening after 5 minutes of inactivity

debugout(string msg)
{
// llOwnerSay(msg);
}

integer outchan;
reply(string msg)
{
llWhisper(outchan, msg);
}


list subset;
integer hlis;

default
{
timer()
{
if (hlis){
llOwnerSay("Deslecting " + llGetObjectName());
llListenRemove(hlis);
hlis = 0;
}
}

touch_start(integer num)
{
llSetTimerEvent(300);
llResetTime();
if (!hlis) {
hlis = llListen(channel, "", "", "");
llOwnerSay(llGetObjectName() + " selected. Listening on channel " + (string)channel);
return;
}
while (num--) {
integer child=llDetectedLinkNumber(num);
integer j = llListFindList(subset,[child]);
if (~j) {
llOwnerSay("Deselecting #" + (string)child);
subset = llDeleteSubList(subset, j, j);
} else {
llOwnerSay("Selecting #" + (string)child);
subset += child;
}
}
}

listen(integer ch, string name, key id, string msg)
{
list sub;
list cmds;
integer i;

if (llGetOwner() != id) {
if (llList2Key(llGetObjectDetails(id, [OBJECT_OWNER]),0) != llGetOwner())
return;
}

outchan = 0;

if (msg == "") {
subset = [];
llSetTimerEvent(0.1); // empty message = disconnect right away;
return;
}
llSetTimerEvent(timeout);

if (llGetSubString(msg, 0, 0) == "/") { // specify response channel
integer endch = llSubStringIndex(msg, " ");
outchan = (integer)llGetSubString(msg, 1, endch);
msg = llGetSubString(msg, endch+1, -1);
}

if (llGetSubString(msg,0,0) == "[") {
integer e = llSubStringIndex(msg, "]");
if (e > 1)
subset = list_cast(llCSV2List(llGetSubString(msg, 1, e-1)));
else
subset = [];
msg = llStringTrim(llGetSubString(msg, e+1, -1), STRING_TRIM_HEAD);
if (llList2String(subset,0) == "*") {
subset = [];
for (i=1; i<=llGetNumberOfPrims(); i++) subset += i;
}
}
if (llGetSubString(msg,0,0) == "?") {
cmds = list_cast(llCSV2List(llGetSubString(msg, 1, -1)));
list curr;
sub = subset;
if (sub == []) // If not specified use root (or only) prim
sub = [ (llGetNumberOfPrims() > 1) ];
debugout(llList2CSV(cmds));
for (i = 0; i<llGetListLength(sub); i++) {
if (llGetListEntryType(sub,i) == TYPE_INTEGER){
integer j = llList2Integer(sub,i);
if (j == LINK_SET) j = LINK_ROOT;
curr = llGetLinkPrimitiveParams(j, cmds);
reply("[" + (string)j + "] " + llList2CSV(curr));
}
else //if (llGetListEntryType(subset,i) == TYPE_STRING)
{
integer k;
string x=llList2String(sub,i);
list exp;
for (k=1; k<=llGetNumberOfPrims(); k++) {
if (~llListFindList(llGetLinkPrimitiveParams(k,[PRIM_NAME,PRIM_DESC]),
[x]))
{
curr = llGetLinkPrimitiveParams(k, cmds);
exp += k;
reply("[" + (string)k + "] " + llList2CSV(curr));
}
}
debugout(x + " is " + llList2CSV(exp));
}

}
return;
}
cmds = list_cast(llCSV2List(msg));
if (subset == [])
sub = [LINK_SET];
else
sub = subset;

debugout("On " + llList2CSV(subset) +":");
debugout("Cmds: "+ llDumpList2String(cmds,"; "));
for (i = 0; i<llGetListLength(sub); i++) {
if (llGetListEntryType(sub,i) == TYPE_INTEGER)
llSetLinkPrimitiveParamsFast(llList2Integer(sub,i), cmds);
else //if (llGetListEntryType(subset,i) == TYPE_STRING)
{
integer k;
string x=llList2String(sub,i);
list exp;
for (k=1; k<=llGetNumberOfPrims(); k++) {
if (~llListFindList(llGetLinkPrimitiveParams(k,[PRIM_NAME,PRIM_DESC]),[x]))
{
llSetLinkPrimitiveParamsFast(k, cmds);
exp += k;
}
}
debugout(x + " is " + llList2CSV(exp));
}
}
}
}

 

 

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
// primset+ (includes resize and particles)// listens on 884 when touched (times out after 5 minutes idle)// prefix /nnn sets reply channel// prefix [m,n,o] selects child prims by id or name// ?<list of params>   get passed to llGetLinkPrimitiveParams// $<float>    resize entire linkset// $<vector>   non-proportional resize (see caveats below!)// %<list>     pass to llLinkParticleSystem// <list>      pass to llSetLinkPrimitiveParamsFast// needs the list_cast function from the wiki library// based on the basic resize script from the library.  Supports up to 64x64x64.// In most cases scal,x scal.y and scal.z should be equal.// Non-proportional re-size will work if all prims are oriented the same way,// or if it is the sort of object for which this does not matter. // use with caution and take a copy first.resize(vector scal){    integer primindx;    list primP;    vector s = llGetScale();    rotation saverot = llGetRot();    llSetRot(ZERO_ROTATION);    integer validDim = TRUE;    for ( primindx = 1; primindx <= llGetNumberOfPrims(); primindx++ )    {        primP = llGetLinkPrimitiveParams( primindx, [PRIM_SIZE]);        s = llList2Vector( primP, 0 );        vector vr = <scal.x*s.x,scal.y*s.y,scal.z*s.z>; debugout((string)vr);        validDim = validDim && vr.x>=0.01 && vr.y>=0.01 && vr.z>=0.01 && vr.x<=64.0 && vr.y<=64.0 && vr.z<=64.0;    }    if ( validDim )    {        s = llGetScale();        llSetScale( <scal.x*s.x,scal.y*s.y,scal.z*s.z> );         for ( primindx = 2; primindx <= llGetNumberOfPrims(); primindx++ )        {            primP = llGetLinkPrimitiveParams( primindx, [PRIM_SIZE, PRIM_POSITION]);            vector primScale = llList2Vector( primP, 0 );            primScale = <primScale.x*scal.x, primScale.y*scal.y, primScale.z*scal.z>;            vector primPos = llList2Vector( primP, 1 ) - llGetPos();            primPos = <primPos.x*scal.x, primPos.y*scal.y, primPos.z*scal.z>;            llSetLinkPrimitiveParamsFast( primindx, [PRIM_SIZE, primScale, PRIM_POSITION, primPos/llGetRootRotation()]);        }    }    else llOwnerSay("No resize! Out of limit sizes are not accepted");    llSetRot(saverot);}debugout(string msg){  llOwnerSay(msg);  // comment out if it's too chatty}integer outchan =0;reply(string msg){    llWhisper(outchan, msg);    if (outchan) {        debugout(msg);    }}integer channel = 884;list subset;integer hlis;float timeout = 300; // stop listening after 5 minutes of inactivitydefault{    timer()    {        if (hlis){            llOwnerSay("Deslecting " + llGetObjectName());            llListenRemove(hlis);            hlis = 0;        }    }        touch_start(integer num)    {        llSetTimerEvent(300);        llResetTime();        if (!hlis) {            hlis =  llListen(channel, "", "", "");            llOwnerSay(llGetObjectName() + " selected. Listening on channel " + (string)channel);            return;        }        while (num--) {            integer child=llDetectedLinkNumber(num);            integer j = llListFindList(subset,[child]);            if (~j) {                llOwnerSay("Deselecting #" + (string)child);                subset = llDeleteSubList(subset, j, j);            } else {                llOwnerSay("Selecting #" + (string)child);                subset += child;            }        }    }    listen(integer ch, string name, key id, string msg)    {        //llOwnerSay(msg + " from " + (string)id + " owned by " + (string)llGetObjectDetails(id, [OBJECT_OWNER]));        if (llGetOwner() != id) {            if (llList2Key(llGetObjectDetails(id, [OBJECT_OWNER]),0) != llGetOwner())                return;        }        outchan = 0;                if (msg == "") {            subset = [];            llSetTimerEvent(0.1);  // empty message = disconnect right away;            return;        }        llSetTimerEvent(timeout);                if (llGetSubString(msg, 0, 0) == "/") {  // specify response channel            integer endch = llSubStringIndex(msg, " ");            outchan = (integer)llGetSubString(msg, 1, endch);            msg = llGetSubString(msg, endch+1, -1);        }        if (llGetSubString(msg,0,0) == "[") {   // list of child prims to select by name or child id, or * for all            integer e = llSubStringIndex(msg, "]");            if (e > 1)                subset = list_cast(llCSV2List(llGetSubString(msg, 1, e-1)));            else                subset = [];            msg = llStringTrim(llGetSubString(msg, e+1, -1), STRING_TRIM_HEAD);            if (llList2String(subset,0) == "*") {                integer i;                subset = [];                for (i=1; i<=llGetNumberOfPrims(); i++) subset += i;            }        }        list sub;        list cmds;        if (llGetSubString(msg,0,0) == "?") {   // Get params from prims            cmds = list_cast(llCSV2List(llGetSubString(msg, 1, -1)));            integer i;            list curr;            if (subset == []) // If not specified use root (or only) prim                sub = [ (llGetNumberOfPrims() > 1) ];             else                sub = subset;            debugout(llList2CSV(cmds));            for (i = 0; i<llGetListLength(sub); i++) {                if (llGetListEntryType(sub,i) == TYPE_INTEGER){                    integer j = llList2Integer(sub,i);                    curr = llGetLinkPrimitiveParams(j, cmds);                    reply("[" + (string)j + "] " + llList2CSV(curr));                } else {                    integer k;                    string x=llList2String(sub,i);                    list exp;                    for (k=1; k<=llGetNumberOfPrims(); k++) {                        if (~llListFindList(llGetLinkPrimitiveParams(k,[PRIM_NAME,PRIM_DESC]),                                            [x]))                        {                            curr = llGetLinkPrimitiveParams(k, cmds);                            exp += k;                            reply("[" + (string)k + "] " + llList2CSV(curr));                       }                    }                    debugout(x + " is " + llList2CSV(exp));                }            }            return;        }        if (llGetSubString(msg,0,0) == "$") {  // resize entire linkset            msg = llDeleteSubString(msg,0,0);            vector v = (vector)msg;            if (v == ZERO_VECTOR) {                float scal=(float)msg;                v = <scal,scal,scal>;            }            resize(v);            return;        } else if (llGetSubString(msg,0,0) == "%") {  // particle system            msg = llDeleteSubString(msg,0,0);            cmds = list_cast(llCSV2List(msg));            if (subset == [])                sub = [LINK_SET];            else                sub  = subset;                            debugout("ParticleSystem On " + llList2CSV(subset) +":\nCmds: "+ llDumpList2String(cmds,"; "));            integer i;            for (i = 0; i<llGetListLength(sub); i++) {                if (llGetListEntryType(sub,i) == TYPE_INTEGER)                    llLinkParticleSystem(llList2Integer(sub,i), cmds);                else //if (llGetListEntryType(subset,i) == TYPE_STRING)                {                    integer k;                    string x=llList2String(sub,i);                    list exp;                    for (k=llGetNumberOfPrims(); k; k--) {                        if (~llListFindList(llGetLinkPrimitiveParams(k,[PRIM_NAME,PRIM_DESC]),[x]))                        {                            llLinkParticleSystem(k, cmds);                            exp += k;                        }                    }                    debugout(x + " is " + llList2CSV(exp));                }            }            return;        }                // set prim params        cmds = list_cast(llCSV2List(msg));        if (subset == [])            sub = [LINK_SET];        else            sub  = subset;                    debugout("On " + llList2CSV(subset) +":\nCmds: "+ llDumpList2String(cmds,"; "));        integer i;        for (i = 0; i<llGetListLength(sub); i++) {            if (llGetListEntryType(sub,i) == TYPE_INTEGER)                llSetLinkPrimitiveParamsFast(llList2Integer(sub,i), cmds);            else //if (llGetListEntryType(subset,i) == TYPE_STRING)            {                integer k;                string x=llList2String(sub,i);                list exp;                for (k=llGetNumberOfPrims(); k; k--) {                    if (~llListFindList(llGetLinkPrimitiveParams(k,[PRIM_NAME,PRIM_DESC]),[x]))                    {                        llSetLinkPrimitiveParamsFast(k, cmds);                        exp += k;                    }                }                debugout(x + " is " + llList2CSV(exp));            }        }    }}

 

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
You are about to reply to a thread that has been inactive for 4509 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...