Jump to content

Start & Stop Script From Menu


joeyblueyes
 Share

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

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

Recommended Posts

Hi All,

 

I'm real new to LSL scripting, but trying to play with some existing scripts to learn!

Here is what I'm trying to do....

I built a hot tub and added a menu.  In that menu I have a button called "Steam" .  I added a steam particle script that works well with steam coming off the tub water, but I would like to be able to turn the steam on and off!

 

Using llGetScriptState to check the running state of the script and llSetScriptState to toggle from running to not running, this works fine, "except" of course it does not turn off the steam effect!

 

Question #1 - Is there another way to completely stop the script from running, since toggling the running status does not do it?

 

In the steam script, I found that I can set "float startAlpha = 0.2" to  "float startAlpha = 0.0" to make the steam invisible and it appears to be off, but I'm not sure how to set this value remotely from the menu!

 

Question #2 - Is there a way to use the status of the steam script (running or not), and use a conditional "if" to set the startAlpha value?

 

Thanks in advance...  :-)

 

Link to comment
Share on other sites

You're doing it a really hard way.  The easiest way to toggle anything on or off, whether it's a light bulb or a steam bath, is to just switch a Boolean variable from TRUE to FALSE or vice versa, like this ...

integer gON;  // Here's your Boolean variabledefault{    touch_start(integer num)    {        gON = !gON;  // This toggles the variable from TRUE to FALSE or the reverse        if (gON)        {            // Switched on stuff        }        else        {            // Switched off stuff        }    }}

 If the "stuff" you want to switch on is a particle display, then the llParticleSystem statement with all of your parameters will go in the "switched on" area.  If you want to switch a particle display off, write llParticleSystem([]);  Particles are a prim property.  Once they are enabled, you don't even need the script in the prim any more.  That's why turning your script to "not running" has no effect.  To turn particles off you have to do it with a script, feeding the prim a llParticleSystem statement with no parameters.

You don't want to mess with the alpha of the partcles themselves as a switch.  That will just make them transparent, not turn them off.

 

Link to comment
Share on other sites

To make it short:

A particle script sets a property of a prim using the llParticleSystem command. To stop a continously running particle system, you just re-set the parameters to "nothing"

llParticleSystem([]);

 So the easiest way to toggle the particles is to pack the partice paraeters into your dialog script anf toggle between the parameters you are using and the empty parameter list

Link to comment
Share on other sites

Hi setting the running state of the script wont work as the particles are the property of the prim so would continue to emit.  Have your particle system in the same script as the menu then in you listen event have something like this,

if (msg == "steam on")

{

llParticleSystem( your particles);

}

else if (msg == "steam off")

{

llParticleSystem([])     this will stop particles as it is an empty system :)

}   

Link to comment
Share on other sites

The original questions have answers, I think, but if there's still confusion about those, maybe a look at your script will make it simpler to explain what to change.

In case it's of interest: because it's a hot tub, I was reminded of some legacy freebie hot tubs, and how many unnecessary scripts they contain. One LSL function that was introduced long after those were scripted is llLinkParticleSystem(), which makes it possible for the script controlling the steam to be in a different prim from the one that emits the steam particles.

Link to comment
Share on other sites

Thanks everyone for your fast replies, and help, and sorry for my delay in replying!

 

I did combine my partical steam script with the menu script, and using the conditionals on menu button presses, the steam turns on and off nicely with llParticleSystem(sys) & llParticleSystem([]).  So thanks for that help and understanding!

 

Of course this works easily because it is all contained within the same script, but just wondering how I would have done this if I had left the code as 2 separate scripts (menu & steam)?  Would I have used llLinkParticleSystem( integer link, list rules ) from the menu script? And if so, can someone please give me an idea of how I would have formatted it?

 

Now, I would like to also take this one step further too....  I would like to have a LOW, MED & HI steam particle setting, and of course I can achieve this with changing the float startAlpha value, but I can't seem to do this.....

 

If I try to use conditionals in the "scope" where the startAlpha is currently defined, I get a syntax error, and if I try to specisfy the conditionals anywhere else, then I get the error that startAlpha is not defined in the scope!  I tried setting the default value in the scope, and using button press conditionals later in the code, but it seems that the value does not change :-(

 

Thinking this is probably something real simple that I'm missing, and any help is appreciated!

 

Thanks again for all of your replies....  :matte-motes-sunglasses-3:

Link to comment
Share on other sites

There's little point in dividing the job into two scripts if it works just as well (or better) with one script.  That just increases the overhead on the sim's servers and doubles the number of scripts in your own work  for no good reason.  Of course you can do it, either by using llMessageLinked to communicate between scripts in a linked object or by using various communication options like llRegionSayTo if the objects are not linked.  

If you want to vary the volume of steam in your hot tub/sauna, you might change the size of the particles, or you might change their lifetime, among other options.  You'd have to experiment to see what looks best to you.  I suggest spending some time playing with tutorials at the Particle Laboratory in world until you get a feel for what the parameters all do.  You can change particle parameters on the fly easily enough, BTW.  You just can't do it in the block of global variable definitions at the top of your script.  Instead, do something like this

list particle_params = [ list almost all of your parameters here ];default{    [ ... ] // several events and other stuff go here, including your llDialog statement    listen (integer channel, string name, key id, string msg)    {        if (msg == "HIGH")        {            llParticleSystem( particle_params + [PSYS_PART_END_SCALE, <1.0,1.0,1.0>]);        }        else if (msg == "MED")        {            llParticleSystem( particle_params + [PSYS_PART_END_SCALE, <0.7,0.7,0.7>]);        }        else if (msg == "LOW")        {            llParticleSystem( particle_params + [PSYS_PART_END_SCALE, <0.4,0.4,0.4>]);        }    }}

 

 

 

  • Like 1
Link to comment
Share on other sites

Thank you so much again, Rolig!  I guess it really does make sense to combine the scripts, and sure I'll see that much clearer when fully writing my own!

 

Seems I was kind of close already to your example, so just needed to add:

 

        if (cmd == "Steam-HI") {                llParticleSystem(sys + [PSYS_PART_START_ALPHA, 0.5]);            llSay(0,"Steam ON HI");                } else if (cmd == "Steam-MED") {                        llParticleSystem(sys + [PSYS_PART_START_ALPHA, 0.3]);            llSay(0,"Steam ON MED");                 } else if (cmd == "Steam-LOW") {                        llParticleSystem(sys + [PSYS_PART_START_ALPHA, 0.1]);            llSay(0,"Steam ON LOW");           }

 Then just comment our the hard coded Alpha setting in the particle params, and it is working like a charm!  :-)

 

Think I will also take your advice and visit the Particle labs, as it prob would be helpful to know more about it!

 

Thanks once again, everyone.....  But I;m sure I'll be back...  LOL ;-)

Link to comment
Share on other sites

Ok, back with one more question....

 

I'm now pushing it, and trying to combine a lighting control script within the menu script!

 

I'm getting the following error:

 

Tub [script:~menu] Script run-time error
Stack-Heap Collision

 

Is there something simple that is causing this?  Wont compile, nor work as long as this error exists....

 

Thanks again.....

Link to comment
Share on other sites

It means that you are running out of run-time memory.  In a simple script lik this, the probable answer is that you have some loop running that the script can't get out of.  Try putting a diagnostic llOwnerSay statement inside any loop you may have, and see what's happening.

Link to comment
Share on other sites


Rolig Loon wrote:

It means that you are running out of run-time memory.  In a simple script lik this, the probable answer is that you have some loop running that the script can't get out of.  Try putting a diagnostic
llOwnerSay
statement inside any loop you may have, and see what's happening.

 

 

 

Thank you again, Rolig!

I did some process of elimination, and narrowed to down to a function in the lighting script that I'm trying to combine in the menu script!  The lighting script controls 4 lights that are linked and all have the name "bulb".  When it's used and not combined with the menu script, it works fine, so something is clashing, but I'm at a loss to what it is!

Below is the function that clashes....

doLight(){    integer i = llGetNumberOfPrims();    for (; i >= 0; --i)    {        if (llGetLinkName(i) == "bulb")        {                        if (lState == 1 || (lState == 2 && sunDir.z <  0)) {             llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);            }        }    }}

 

I've narrowed it down further....  The conditional "if" is what is causing the error!  I used llSetLinkPrimitiveParams by itself, and it compiles just fine.  I even substituted a totally unrelated "if" statement there and the error returns, so....  just by having this conditional, I get the error!

 

Any ideas?  

 

Thanks again....

Link to comment
Share on other sites

Well, the most obvious problem is that you are running your for loop down to zero, but there's no link #0 in the linkset. The root is #1 and the numbers go up from there. I don't see any reason why that should give you a stack/heap error, though.  I assume that your variables lState and sunDir are both global, BTW.

Incidentally, not that it makes any difference in a slow-changing script like this, but llSetLinkPrimitiveParams has a 0.2 second delay every time it is executed.  In general, I avoid it and use SLPPF, which has no delay, instead.

Link to comment
Share on other sites


Rolig Loon wrote:

Well, the most obvious problem is that you are running your
for
loop down to zero, but there's no link #0 in the linkset. The root is #1 and the numbers go up from there. I don't see any reason why that should give you a stack/heap error, though.  I assume that your variables
lState
and
sunDir
are both global, BTW.

Incidentally, not that it makes any difference in a slow-changing script like this, but llSetLinkPrimitiveParams has a 0.2 second delay every time it is executed.  In general, I avoid it and use SLPPF, which has no delay, instead.

Ok, thanks!  I will try changing the for-loop from 0, and also give the SLPPF a try as well....  Just strange that the "if" part of the whole thing is what is causing the error!  I can say if(jellybeans), and still get the same....  LOL

 

I'm currently using a button on the outside of the tub that controls the lights, and this works fine, but I just would like to have it in the menu with everything else if possible!  I'll give the above a try and hope for the best!

 

Thanks for your continued help, Rolig!  :-)

 

Link to comment
Share on other sites

My guess is that the error is not where you think it is.  It's more likely to be in whatever section of the code is calling this function -- probably calling i over and over and over again.  That's why it's usully a smart idea to pepper your script with llOwnerSay statements to see what the values of key variables are at strategic points.  You'll find that something you thought was going to terminate is actually continuing to loop indefinitely.

Link to comment
Share on other sites

LOL...  If you made "i" a global variable for some reason, then yes, it's being reset God Only Knows Where else in your script. 

A variable is defined within a specific scope.  The scope can be as small as the region between {brackets}, or within a single event.  Outside of that scope, the variable has no meaning.  Any value assigned to it within its scope is lost once the focus of the script moves to another area.  If you want a variable to have meaning beyond its local scope and to retain whatever value you have assigned there, you have to make it global.  Conversely, if you don't want the value assigned to a variable in one place to be retained elsewhere, either be sure to reset it, or be sure that it's not global.

You should avoid reusing the same variable name in several places, to keep from getting confused about exactly which instance you are using, but here's a quick example....

integer gNUM;    // This is a global variabledefault{    state_entry()    {        integer num = 4;    //This variable only has meaning in state_entry        gNUM = 12;        llSay(0,(string) gNUM + "  " + (string)num); // This will say 12  4    }    touch_start (integer number_detected)    {        integer Num = 37;  //This is a different "Num"        if (gNUM == 12)    //This will be TRUE because gNUM is global and was made == 12 in state_entry        {            integer numb = 81;  // This is again a different "numb"             llSay(0,(string) gNUM + "  " + (string)Num + "  " + (string) numb); // This will say 12  37  81            // If you wrote llSay(0,(string)num) , you'd get a compile error. "num" is not defined here        }            // If you wrote llSay(0,(string)numb)  , you'd get a compile error. "numb" is not defined here        state Next;    }}state Next{    state_entry()    {        llSay(0,(string) gNUM ); // This will say 12        // Neither "num" nor "Num" is defined here.    }}

 To avoid misusing a global variable, I have adopted Void Singer's convention of always starting the names of global variables with a lower case "g".

 

 

Link to comment
Share on other sites

Well, I am completely at a loss!  I've tried all we've discussed, and used a variable that I'm sure was not otherwise used, but still I get the same error when the conditional "if" is used....  :-(

 

Is there possibly some easy way to call the DoLight() function from a menu button without adding the scripts together?  They work fine when separate, so this worul of course solve my conflict issue....

 

Thanks for your patience and help!

Link to comment
Share on other sites

Ok, well it is messy from so much trial & error, but the only Lighting code added so far is at the top of the script, and with what is commented out now, it is compiling fine without errors!

 

I hope there is a simple solution, as I've spent so much time on this...  :-(

 

integer PINK1 = 1;  //0001 binaryinteger BLUE1 = 2;  //0010 binaryinteger PINK2 = 4;  //0100 binaryinteger BLUE2 = 8;  //1000 binaryinteger a;integer alive;integer b;integer b0;integer ballusers;integer c;integer ch;integer chat = 1;integer group;integer hear;integer i;integer line;integer menu;integer menuusers;integer redo = 1;integer rez;integer swap;integer visible;float alpha;string cmd;string pose;string pose0;key owner;key user;key user0;list buttons;list buttonindex;list commands;list menus;list balls;list users;// Lighting Control ******** START ********vector  sunDir;         // Vector as we use a function//integer cmdChannel  = -900101; // Dialog channel we recieve commands oninteger lState  = 2;    // 0 = off, 1 = on, 2 = sun controlledinteger dState  = 0;    // 0 = main, 1 = intensity, 2 = falloff, 3 = radius, 4 = glowkey     User;integer listner;vector  lColorOff   = <222, 187, 153>; // Color of the prim when the light is off (255 = white)vector  lColorOn    = <190, 0, 0>; // These are the RGB values as you see in the color pickerinteger lLinkBulbs  = TRUE;     // Set all linked "bulb" prims to emit light  TRUE = yes, FALSE = fullbrightfloat   lIntensity  = 0.6;      // Light intesity (doh)float   lFalloff    = 0.5;      // Light falloff (double doh)float   lRadius     = 6.0;      // Light radius (oh c`mon, like you didn`t guess that one coming...)float   lGlow       = 0.45;     // Glow amount, steps of 0.05float   lGlowDefault = 0.05;    // Amount of glow when the light is off/*// As complicated as this looks, bad joke, we can`t be arsed to copy the dialog text 10 times list dM     = ["Glow", "Show Settings", "Exit", "Intensity", "Falloff", "Radius", "Light On", "Light Off", "Light Sun"];list dPM    = ["--", "++", "Back"];*/// No, it`s not the God function, christ...doLight(){    integer l = llGetNumberOfPrims();    for (; l >= 1; --l)    {        if (llGetLinkName(l) == "bulb")        {                        // We love burning electricity, ON!//            if (lState == 1 || (lState == 2 && sunDir.z <  0)) { //            llSetLinkPrimitiveParamsFast( l, [PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);//            }//            if (!lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0))) { //            llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff]); //            }//            if (lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0)))  { //            llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff, PRIM_GLOW, ALL_SIDES, lGlow, PRIM_COLOR, ALL_SIDES, (lColorOn/255), 1]); //            }/*                    // Ok, we`re kindof green...off              if (lState == 0 || (lState == 2 && sunDir.z > 0)) {             llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);            }            if (!lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z >  0))) {             llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,FALSE, (lColorOn/255), lIntensity, lRadius, lFalloff]);             }            if (lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z > 0)))  {             llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT, FALSE, <0.0,1.0,0.0>,1.0, 10.0, 0.5, PRIM_GLOW, ALL_SIDES, lGlowDefault, PRIM_COLOR, ALL_SIDES, (lColorOff/255), 1]);             }*/                    }     }}// Lighting Control ******** END ********// Particle Script 0.5 ******** START ********integer keystate = 0 ;// Mask Flags - set to TRUE to enableinteger glow = FALSE;            // Make the particles glowinteger bounce = FALSE;          // Make particles bounce on Z plane of objectinteger interpColor = TRUE;     // Go from start to end colorinteger interpSize = TRUE;      // Go from start to end sizeinteger wind = TRUE;           // Particles effected by windinteger followSource = FALSE;    // Particles follow the sourceinteger followVel = FALSE;       // Particles turn to velocity direction// Choose a pattern from the following:// PSYS_SRC_PATTERN_EXPLODE// PSYS_SRC_PATTERN_DROP// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY// PSYS_SRC_PATTERN_ANGLE_CONE// PSYS_SRC_PATTERN_ANGLEinteger pattern = PSYS_SRC_PATTERN_EXPLODE;// Select a target for particles to go towards// "" for no target, "owner" will follow object owner //    and "self" will target this object//    or put the key of an object for particles to go tokey target = "";// Particle paramatersfloat age = 1.0;                  // Life of each particlefloat maxSpeed = 0.2;            // Max speed each particle is spit out atfloat minSpeed = 0.5;            // Min speed each particle is spit out atstring texture = "4f714019-c1cf-6b16-994f-44b217022f1a";                 // Texture used for particles, default used if blank//float startAlpha = 0.1;       // Start alpha (transparency) valuefloat endAlpha = 0.0;           // End alpha (transparency) valuevector startColor = <9.9,9.9,9.9>;    // Start color of particles <R,G,B>vector endColor = <9,9,9>;      // End color of particles <R,G,B> (if interpColor == TRUE)vector startSize = <1.30,1.30,0.0>;     // Start size of particles vector endSize = <1.5,1.5,0.0>;       // End size of particles (if interpSize == TRUE)vector push = <.2,0,3>;          // Force pushed on particles// System paramatersfloat rate = 0.0;            // How fast (rate) to emit particlesfloat radius = 1.0;          // Radius to emit particles for BURST patterninteger count = 59;        // How many particles to emit per BURST float outerAngle = 0;    // Outer angle for all ANGLE patternsfloat innerAngle = 0.1;    // Inner angle for all ANGLE patternsvector omega = <0,0,0>;    // Rotation of ANGLE patterns around the sourcefloat life = 0;             // Life in seconds for the system to make particlesinteger flags;list sys;integer type;vector tempVector;rotation tempRot;string tempString;//integer i;updateParticles(){    flags = 0;    if (target == "owner") target = llGetOwner();    if (target == "self") target = llGetKey();    if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;    if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;    if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;    if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;    if (wind) flags = flags | PSYS_PART_WIND_MASK;    if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;    if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;    if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;    sys = [  PSYS_PART_MAX_AGE,age,                        PSYS_PART_FLAGS,flags,                        PSYS_PART_START_COLOR, startColor,                        PSYS_PART_END_COLOR, endColor,                        PSYS_PART_START_SCALE,startSize,                        PSYS_PART_END_SCALE,endSize,                         PSYS_SRC_PATTERN, pattern,                        PSYS_SRC_BURST_RATE,rate,                        PSYS_SRC_ACCEL, push,                        PSYS_SRC_BURST_PART_COUNT,count,                        PSYS_SRC_BURST_RADIUS,radius,                        PSYS_SRC_BURST_SPEED_MIN,minSpeed,                        PSYS_SRC_BURST_SPEED_MAX,maxSpeed,                        PSYS_SRC_TARGET_KEY,target,                        PSYS_SRC_INNERANGLE,innerAngle,                         PSYS_SRC_OUTERANGLE,outerAngle,                        PSYS_SRC_OMEGA, omega,                        PSYS_SRC_MAX_AGE, life,                        PSYS_SRC_TEXTURE, texture,//                        PSYS_PART_START_ALPHA, startAlpha,                        PSYS_PART_END_ALPHA, endAlpha                            ];                            //    llParticleSystem(sys);}// Particle Script 0.5 ******** END ********//menu partly based on Menu Engine by Zonax Delorean (BSD License)//llDialog(user, menuname, buttons(from index to nextindex-1), channel)  doMenu() {    b0 = llList2Integer(buttonindex, menu);         //position of first button for this (sub)menu    b = llList2Integer(buttonindex, menu+1);        //position of first button for next (sub)menu    llDialog(user, llList2String(menus,menu), llList2List(buttons, b0, b - 1), ch - 1);    c = llList2Integer(balls,menu);         //ballcolors    if © {                                //if submenu includes ballcolor(s):        if (!rez) rezBalls();               //if no balls present: create balls        llSay(ch,(string)(c & 3));          //ball1color: mask with 3 = 0011 binary        llSay(ch+1,(string)(c >> 2));       //ball2color: shift 2 bits to the right        if (ballusers) setBalls("GROUP");   //if group access only    }    llResetTime();    //if (user != llGetOwner()) llOwnerSay("("+llKey2Name(user)+" selects "+llList2String(menus,menu)+")");     //owner will receive info}say(string str) {    if (menuusers) llWhisper(0,str);    else llOwnerSay(str);}setBalls(string cmd) {    llSay(ch,cmd);      //msg to balls    llSay(ch+1,cmd);}rezBalls() {    setBalls("DIE");    llRezObject("~ball",llGetPos(),ZERO_VECTOR,ZERO_ROTATION,ch);    llRezObject("~ball",llGetPos(),ZERO_VECTOR,ZERO_ROTATION,ch+1);    llMessageLinked(LINK_THIS,0,"REPOS",NULL_KEY);  //msg to pos    llMessageLinked(LINK_THIS,0,"POSE","0");        //msg to pos/pose    rez = 1;    alive = 2;    pose = pose0;    llSetTimerEvent(60);    if (chat) say("Balls ready");}default {        state_entry() {        // Particle Script 0.5 ******** START ********                                //updateParticles();        keystate = 0 ;        //target = llGetLinkKey(2) ;        updateParticles() ;        //llParticleSystem([]) ;        // Particle Script 0.5 ******** END ********                                //llSetScriptState("~run", TRUE);        llResetOtherScript("~pos");        llResetOtherScript("~pose");        llResetOtherScript("~pose1");        llResetOtherScript("~pose2");        ch = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1));  //fixed channel for prim        setBalls("DIE");        alpha = llGetAlpha(0);                                          //store object transparancy (alpha)        if (alpha < 0.1) alpha = 0.5; else visible = 1;                 //if invisible store a visible alpha        llMessageLinked(LINK_THIS,1,"OK?",NULL_KEY);                    //msg to memory: ask if ready    }    link_message(integer from, integer num, string str, key id) {        if (num == 2) {            if (str == "OK") state load;                                //memory ready        }    }}           state load {    state_entry() {        llGetNotecardLine(".MENUITEMS",0);                              //read first line of menuitems notecard    }    dataserver(key query_id, string data) {                                         if (data == EOF) state on;        i = llSubStringIndex(data,"//");                                //remove comments        if (i != -1) {            if (i == 0) data = "";            else data = llGetSubString(data, 0, i - 1);        }        while (llGetSubString(data, -1, -1) == " ") data = llDeleteSubString(data, -1, -1); //remove spaces from end        if (data != "") {            i = llSubStringIndex(data," ");            cmd = data;                                  if (i != -1) {                                              //split command from data                cmd = llGetSubString(data, 0, i - 1);                data = llGetSubString(data, i+1, -1);            }            list ldata = llParseString2List(data,["  |  ","  | "," |  "," | "," |","| ","|"],[]);            data = llList2String(ldata, 0);            if (cmd == "MENU") {                if (a < 2) {                    llOwnerSay("warning: first item in .MENUITEMS must be: POSE stand");                    llOwnerSay("warning: second item in .MENUITEMS must be: POSE default");                }                llOwnerSay("loading data for '"+data+"'");                             if (llList2String(ldata, 1) == "GROUP") menu = 1;       //access to submenus                else if (llList2String(ldata, 1) != "OWNER") menu = 2;  //0=owner 1=group 2=all                pose = llList2String(ldata, 2);                if (pose == "PINK") rez = PINK1;                else if (pose == "BLUE") rez = BLUE1;                pose = llList2String(ldata, 3);                if (pose == "PINK") rez += PINK2;                else if (pose == "BLUE") rez += BLUE2;                menus += [ data ];                balls += [ rez ];                buttonindex += [ b ];                users += [ menu ];                rez = 0;                b0 = 0;                menu = 0;            } else if (b0 < 12) {                                       //maximum 12 buttons per menu                if (cmd == "POSE") {                    llMessageLinked(LINK_THIS,1,data,(string)a);        //msg to memory                    llMessageLinked(LINK_THIS,9+a,llList2String(ldata, 1),llList2String(ldata, 2));  //msg to pose                    if (!a) pose0 = data;                    cmd = (string)a;                    ++a;                } else if (cmd == "REDO") {                    if (llList2String(ldata, 1) != "OFF") redo = 1;                } else if (cmd == "CHAT") {                    if (llList2String(ldata, 1) != "OFF") chat = 1;                } else if (cmd == "BALLUSERS") {                    if (llList2String(ldata, 1) == "GROUP") ballusers = 1;                } else if (cmd == "MENUUSERS") {                    if (llList2String(ldata, 1) == "GROUP") menuusers = 1;                    else if (llList2String(ldata, 1) != "OWNER") menuusers = 2;                }                   commands += [ cmd ];                buttons += [ data ];                ++b;                ++b0;            }        }        ++line;        llGetNotecardLine(".MENUITEMS",line);                           //read next line of menuitems notecard    }    state_exit() {        buttonindex += [ b ];                                           //enter last buttonindex        commands += [ "" ];                                             //empty command for undefined buttons (-1)        llOwnerSay("READY");        llOwnerSay((string)b+" menuitems loaded ("+llGetScriptName()+": "+(string)llGetFreeMemory()+" bytes free)");        llMessageLinked(LINK_THIS,1,"LOADED",(string)a);                //msg to memory        llMessageLinked(LINK_THIS,9+a,"LOADED",NULL_KEY);               //msg to pose    }}state on {    state_entry() {        owner = llGetOwner();        llSetTimerEvent(0);        llListenRemove(hear);        hear = llListen(ch - 1, "", NULL_KEY, "");                      //listen for pressed buttons    }    touch_start(integer i) {        user0 = llDetectedKey(0);        if (user0 == owner || (menuusers == 1 && llDetectedGroup(0)) || menuusers == 2) {   //0=owner 1=group 2=all            if (user0 != user) {                if (llGetTime() < 60) {                    llDialog(user0, "\n"+llKey2Name(user)+" has just selected the menu, do you want to continue?", ["Yes","Cancel"], ch - 1);                    return;                }                user = user0;                group = llDetectedGroup(0);            }            menu = 0; doMenu();                                         //mainmenu        }                     }        listen(integer channel, string name, key user0, string button) {        if (user0 != user) {            if (button == "Yes") {                user = user0;                group = llSameGroup(user0);                menu = 0; doMenu();            } else if (button != "Cancel") {                llDialog(user0, "\nSelection cancelled because "+llKey2Name(user)+" has just selected the menu, do you want to operate the menu again?", ["Yes","Cancel"], ch - 1);            }            return;        }        b = llListFindList(buttons,[ button ]);                         //find position of cmd        string cmd = llList2String(commands,b);                         //get command//        llSay(0,button+" "+cmd);                                      //debug                if (cmd == "Steam-On") {                llParticleSystem(sys);                llSay(0,"Steam ON");                            } else if (cmd == "Steam-Off") {                llParticleSystem([]);                llSay(0,"Steam OFF");            }        if (cmd == "Steam-HI") {                llParticleSystem(sys + [PSYS_PART_START_ALPHA, 0.5]);            llSay(0,"Steam ON HI");                } else if (cmd == "Steam-MED") {                        llParticleSystem(sys + [PSYS_PART_START_ALPHA, 0.3]);            llSay(0,"Steam ON MED");                 } else if (cmd == "Steam-LOW") {                        llParticleSystem(sys + [PSYS_PART_START_ALPHA, 0.1]);            llSay(0,"Steam ON LOW");           }                                                   if (cmd == "TOMENU") {                                                         menu = llListFindList(menus,[ button ]);                    //find submenu            if (menu == -1) return;            i = llList2Integer(users, menu);             if (user == owner || (i == 1 && group) || i == 2) {         //0=owner 1=group 2=all                doMenu(); return;            }            if (i == 1) llDialog(user0, "\n"+button+" menu deactivated\n(access by group only)", ["OK"], ch - 1);            else llDialog(user0, "\n"+button+" menu deactivated\n(access by owner only)", ["OK"], ch - 1);            menu = 0;            return;        } else if (cmd == "BACK") {            menu = 0; doMenu();                                         //mainmenu            return;        } else if ((integer)cmd > 0) {                                  //POSE            llMessageLinked(LINK_THIS,0,"POSE",cmd);                    //msg to pos/pose            if (chat) say(button);            pose = button;        } else if (cmd == "SWAP") {            llMessageLinked(LINK_THIS,0,"SWAP",NULL_KEY);               //msg to pos/pose            swap = !swap;        } else if (cmd == "STAND") {            llMessageLinked(LINK_THIS,0,"POSE","0");                    //STAND msg to pos/pose            if (chat) say(button);            menu = 0;            pose = pose0;        } else if (cmd == "STOP") {            llMessageLinked(LINK_THIS,0,"POSE","0");                    //STAND msg to pos/pose            if (chat) say(button);            setBalls("DIE");            if (chat && rez) say("Balls removed");            rez = 0;            llSetTimerEvent(0);            return;        } else if (cmd == "ADJUST") {            setBalls("ADJUST");        } else if (cmd == "HIDE") {            setBalls("0");        } else if (cmd == "SHOW") {            setBalls("SHOW");        } else if (cmd == "DUMP") {            llMessageLinked(LINK_THIS,1,"DUMP",NULL_KEY);        } else if (cmd == "INVISIBLE") {            visible = !visible;            llSetAlpha((float)visible*alpha, ALL_SIDES);        } else if (cmd == "REDO") {            redo = !redo;            if (redo) say(button+" ON"); else say(button+" OFF");        } else if (cmd == "CHAT") {            chat = !chat;            if (chat) say(button+" ON"); else say(button+" OFF");        } else if (cmd == "BALLUSERS") {            ballusers = !ballusers;            if (ballusers) {                llOwnerSay(button+" GROUP");                setBalls("GROUP");            } else {                    llOwnerSay(button+" ALL");                setBalls("ALL");            }        } else if (cmd == "MENUUSERS") {            if (user == owner) {                if (!menuusers) {                    menuusers = 1;                    llOwnerSay(button+" GROUP");                } else if (menuusers == 1) {                    menuusers = 2;                    llOwnerSay(button+" ALL");                } else if (menuusers == 2) {                    menuusers = 0;                    llOwnerSay(button+" OWNER");                }            } else llWhisper(0,button+" (can be switched by owner only)");        } else if (cmd == "RESET") {            llMessageLinked(LINK_THIS,0,"POSE","0");                    //STAND msg to pos/pose            setBalls("DIE");            //llSleep(0.5);                    if (chat) say(button);            llResetScript();        } else if (cmd == "OFF") {            llMessageLinked(LINK_THIS,0,"POSE","0");                    //STAND msg to pos/pose            setBalls("DIE");            //llSleep(0.5);            if (user == owner) {                llOwnerSay(button);                llResetOtherScript("~run");                llResetScript();            }            llDialog(user0, "\n"+button+" button deactivated\n(access by owner only)", ["OK"], -1);            return;        } else if (llGetSubString(cmd, 0, 0) == "Z" || (cmd == "SAVE")) {    //SAVE //Z-adjust            llMessageLinked(LINK_THIS,0,cmd,pose);                      //msg to pos/pose            doMenu();            return;        }        if (redo) doMenu();    }            link_message(integer from, integer num, string str, key id) {       if (str == "PRIMTOUCH") {        user0 = id ;        integer detected_group = num;            if (user0 == owner || (menuusers == 1 && detected_group) || menuusers == 2) {   //0=owner 1=group 2=all            if (user0 != user) {                if (llGetTime() < 60) {                    llDialog(user0, "\n"+llKey2Name(user)+" has just selected the menu, do you want to continue?", ["Yes","Cancel"], ch - 1);                    return;                }                user = user0;                group = llDetectedGroup(0);            }            menu = 0; doMenu();                                         //mainmenu        }                              return;      }              if (num != 2) return;        if (str == "ALIVE") {            ++alive;        } else if (str == "DIE") {                                      //suicide msg from ball            setBalls("DIE");            menu = 0;            rez = 0;            llSetTimerEvent(0);        }     }    on_rez(integer r) {        if (owner != llGetOwner()) llResetScript();    }    timer() {        if (alive > 1) {                alive = 0;            llSay(ch,"LIVE");           //msg to balls: stay alive            llSay(ch+1,"LIVE");         } else {                        //balls not rezzed properly anymore            rezBalls();            llSay(ch,(string)(c & 3));          //ball1color: mask with 3 = 0011 binary            llSay(ch+1,(string)(c >> 2));       //ball2color: shift 2 bits to the right            if (ballusers) setBalls("GROUP");   //if group access only        }    }                       }    

 

Thank you again..... 

Link to comment
Share on other sites

Two things......

First, you have four bogus lines in your user-defined function doLight.

//THIS one >> /*// As complicated as this looks, bad joke, we can`t be arsed to copy the dialog text 10 times list dM     = ["Glow", "Show Settings", "Exit", "Intensity", "Falloff", "Radius", "Light On", "Light Off", "Light Sun"];list dPM    = ["--", "++", "Back"];//THIS one >> */// No, it`s not the God function, christ...doLight(){    integer l = llGetNumberOfPrims();    for (; l >= 1; --l)    {        if (llGetLinkName(l) == "bulb")        {                        // We love burning electricity, ON!//            if (lState == 1 || (lState == 2 && sunDir.z <  0)) { //            llSetLinkPrimitiveParamsFast( l, [PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);//            }//            if (!lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0))) { //            llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff]); //            }//            if (lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0)))  { //            llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff, PRIM_GLOW, ALL_SIDES, lGlow, PRIM_COLOR, ALL_SIDES, (lColorOn/255), 1]); //            }//THIS one >> /*                    // Ok, we`re kindof green...off             if (lState == 0 || (lState == 2 && sunDir.z > 0)) {             llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);            }            if (!lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z >  0))) {             llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,FALSE, (lColorOn/255), lIntensity, lRadius, lFalloff]);             }            if (lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z > 0)))  {             llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT, FALSE, <0.0,1.0,0.0>,1.0, 10.0, 0.5, PRIM_GLOW, ALL_SIDES, lGlowDefault, PRIM_COLOR, ALL_SIDES, (lColorOff/255), 1]);             }//THIS one >>*/                    }     }}

The sequences /*"and */ have no meaning in LSL, so the compiler doesn't know what to do with them. Get rid of those lines. When I do, it compiles just fine. The second problem is less significant at the moment. You're not calling this function anywhere in your script.  It's just sitting there, doing nothing but causing a compile error.  You also have a raft of other unused global variables, BTW. 

Link to comment
Share on other sites

Hi, just a small point, C style comments in the form

 

/* meow*/

 

or

 

/* woof */

 

are supported in LSL. This change came with Second Life Server 1.25 in early 2009. The script joeyblueyes posted compiles OK with those commented lines included, on both VMs.

Older external tools may choke on them, but it is valid LSL.

Link to comment
Share on other sites


Rolig Loon wrote:

Two things......

First, you have four bogus lines in your user-defined function
doLight
.
//THIS one >> /*// As complicated as this looks, bad joke, we can`t be arsed to copy the dialog text 10 times list dM     = ["Glow", "Show Settings", "Exit", "Intensity", "Falloff", "Radius", "Light On", "Light Off", "Light Sun"];list dPM    = ["--", "++", "Back"];//THIS one >> */// No, it`s not the God function, christ...doLight(){    integer l = llGetNumberOfPrims();    for (; l >= 1; --l)    {        if (llGetLinkName(l) == "bulb")        {                        // We love burning electricity, ON!//            if (lState == 1 || (lState == 2 && sunDir.z <  0)) { //            llSetLinkPrimitiveParamsFast( l, [PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);//            }//            if (!lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0))) { //            llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff]); //            }//            if (lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0)))  { //            llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff, PRIM_GLOW, ALL_SIDES, lGlow, PRIM_COLOR, ALL_SIDES, (lColorOn/255), 1]); //            }//THIS one >> /*                    // Ok, we`re kindof green...off             if (lState == 0 || (lState == 2 && sunDir.z > 0)) {             llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);            }            if (!lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z >  0))) {             llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,FALSE, (lColorOn/255), lIntensity, lRadius, lFalloff]);             }            if (lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z > 0)))  {             llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT, FALSE, <0.0,1.0,0.0>,1.0, 10.0, 0.5, PRIM_GLOW, ALL_SIDES, lGlowDefault, PRIM_COLOR, ALL_SIDES, (lColorOff/255), 1]);             }//THIS one >>*/                    }     }}

The sequences
/*
"and
*/
have no meaning in LSL, so the compiler doesn't know what to do with them. Get rid of those lines. When I do, it compiles just fine. The second problem is less significant at the moment. You're not calling this function anywhere in your script.  It's just sitting there, doing nothing but causing a compile error.  You also have a raft of other unused global variables, BTW. 

The code for the lighting is only partial ATM, just to test for the error.  With the lines commented, it does compile fine, but ifv I Call the function, I get the error again!

 

Link to comment
Share on other sites

Oh,  THAT error.  I forgot about that one.  The stack/heap thing?

Change

integer l = llGetNumberOfPrims();for (; l >= 1; --l)

 to

integer l;    for (l = llGetNumberOfPrims(); l >= 1; --l)

 or, even better

integer l = llGetNumberOfPrims();while( l )   // That is, while i > 0{    // Bunch of stuff    --l;}

 

 

Link to comment
Share on other sites

Thank you Rolig!  This stack overflow error is relentless....  :-(

 

I changed the code as below:

 

vector  lColorOff   = <222, 187, 153>; // Color of the prim when the light is off (255 = white)vector  lColorOn    = <190, 0, 0>; // These are the RGB values as you see in the color pickerinteger lLinkBulbs  = TRUE;     // Set all linked "bulb" prims to emit light  TRUE = yes, FALSE = fullbrightfloat   lIntensity  = 0.6;      // Light intesity (doh)float   lFalloff    = 0.5;      // Light falloff (double doh)float   lRadius     = 6.0;      // Light radius (oh c`mon, like you didn`t guess that one coming...)float   lGlow       = 0.45;     // Glow amount, steps of 0.05float   lGlowDefault = 0.05;    // Amount of glow when the light is offdoLight(){    integer l = llGetNumberOfPrims();    while( l )   // That is, while i > 0    {        if (llGetLinkName(l) == "bulb")        {                        // We love burning electricity, ON!            if (lState == 1 || (lState == 2 && sunDir.z <  0)) {            llSetLinkPrimitiveParamsFast( l, [PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);            }//            if (!lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0))) { //            llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff]); //            }//            if (lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z <  0)))  { //            llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff, PRIM_GLOW, ALL_SIDES, lGlow, PRIM_COLOR, ALL_SIDES, (lColorOn/255), 1]); //            }/*                    // Ok, we`re kindof green...off              if (lState == 0 || (lState == 2 && sunDir.z > 0)) {             llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);            }            if (!lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z >  0))) {             llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,FALSE, (lColorOn/255), lIntensity, lRadius, lFalloff]);             }            if (lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z > 0)))  {             llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT, FALSE, <0.0,1.0,0.0>,1.0, 10.0, 0.5, PRIM_GLOW, ALL_SIDES, lGlowDefault, PRIM_COLOR, ALL_SIDES, (lColorOff/255), 1]);             }*/                    }         --l;    }}

 

I uncommented the first conditional statement to test, and I STILL get the error, 

However, if I comment the following......

 

// vector  lColorOff   = <222, 187, 153>; // Color of the prim when the light is off (255 = white)// vector  lColorOn    = <190, 0, 0>; // These are the RGB values as you see in the color picker

 

The error goes away, and the script compiles just fine......

BUT....

Of course I do need to define the above lines......

AND

Even with the above lines commented, if I make a call to the doLight() function, The Error Returns!

 

OMG...  This is crazy!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4266 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...