Wolfen Greggan Posted April 7, 2011 Share Posted April 7, 2011 I'm not sure if this has been discussed before but my eyes are going wonky scanning through the forums and script library so I thought maybe someone could point me in the right direction. I'm building a barbeque and I'd like to have the flame turn on and off at the touch of a button, but I'm no scripter and I can't seem to locate a script that will do this. Link to comment Share on other sites More sharing options...
Sion Pearl Posted April 7, 2011 Share Posted April 7, 2011 It'd be a particle effect, right? The tutorial boxes at Sirena Hair (mentioned on the Mermaid Diaries site in the tutorial section) have at least one on/off particle script. It'd be super-easy to change the settings on that. Link to comment Share on other sites More sharing options...
Sion Pearl Posted April 7, 2011 Share Posted April 7, 2011 Here's what I'm thinking of: http://www.mermaiddiaries.com/2007/03/day-174-creating-particle-effects-part.html I expect that the regulars will come along soon with advice on how to make it better, but this is what I am thinking about. Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 7, 2011 Share Posted April 7, 2011 In this forum we usually discuss issues related to scripting - e.g. help someone with a script they are writing rather than provide scripts - there are other places for that. You won't find a script for what you want that will work without tweaking - but I sounds like a rather simple task to write a little script for a button. I will be on inworld in a few hours - you can have a look and fix it. Link to comment Share on other sites More sharing options...
ColeMarie Caramel Posted April 7, 2011 Share Posted April 7, 2011 Go to http://marketplace.secondlife.com Go down to scripts and click it. Type flame in under the keyword box and click search. A few scripts will pop up, just search through them and see if you find something. Hope this helps. ~ColeMarie~ Link to comment Share on other sites More sharing options...
Wolfen Greggan Posted April 7, 2011 Author Share Posted April 7, 2011 Thanks all...and I apologize for misusing the forum...it seemed like the best place to get an answer. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted April 7, 2011 Share Posted April 7, 2011 In addition to looking at the sample scripts at Sirena, I'd strongly suggest visiting The Particle Lab at http://maps.secondlife.com/secondlife/Teal/180/74/21 There (in the sandbox area downstairs) you'll find free OS sample templates for a wide variety of effects and triggers. Link to comment Share on other sites More sharing options...
conrad Evanier Posted April 7, 2011 Share Posted April 7, 2011 Hi i take it the flame is particle iv messed around with particles a lot and have a great engine if you still need help its click start stop just im me if you need it Link to comment Share on other sites More sharing options...
Wolfen Greggan Posted April 7, 2011 Author Share Posted April 7, 2011 I'm thinking I didn't phrase my question properly. Here's what I'm trying to do - I have a prim that I'm trying to activate the glow by touching a switch that is linked to the glow prim (I decided against particle flames). Ihave a touch-to-glow script working, but I want it to activate by touching another prim. All I need is what I'm told is a simple script to allow the remote prim to talk to the glow prim. Link to comment Share on other sites More sharing options...
Randall Ahren Posted April 8, 2011 Share Posted April 8, 2011 I think llMessageLinked will meet your needs. See http://wiki.secondlife.com/wiki/LlMessageLinked Put in a script in your switch prim this line of code at the appropriate location: llMessageLinked(LINK_SET, 0, "turn on", "") Then in your glow prim, put in a script having this line of code: link_message(integer sender_num, integer num, string msg, key id) Then do something if msg == "turn on" in the glow prim, like set the prim to full bright or change to an orange color or something or maybe both. You will also need to handle a "turn off" message as well or your bbq will be stuck in the on state. Link to comment Share on other sites More sharing options...
Sion Pearl Posted April 8, 2011 Share Posted April 8, 2011 Wolfen Greggan wrote: I'm thinking I didn't phrase my question properly. Here's what I'm trying to do - I have a prim that I'm trying to activate the glow by touching a switch that is linked to the glow prim (I decided against particle flames). Ihave a touch-to-glow script working, but I want it to activate by touching another prim. All I need is what I'm told is a simple script to allow the remote prim to talk to the glow prim. Iiiin that case, I started a similar couple of threads not long ago, which resulted in scripts that control glow, transparency and visibility. Here's one and here's another. They deal with worn objects, but the principles are similar. Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 8, 2011 Share Posted April 8, 2011 Just to make sure I understand correctly: You do have a script for a linked object that works fine - you want one for a non-linked object, right? If that's right, you need a script that uses chat commands. But your flame script will most likely have to be modded to receive chat commands as well. That's why I offered to have a look at it. You can post the script here as well. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted April 8, 2011 Share Posted April 8, 2011 I don't think you want to be putting slave scripts in link prims, at least not now we have llSetLinkPrimitiveParamsFast. Something like this will control the glow in all prims in a linkset that have the words "glow prim" (without the quotes, of course) as their description. Just drop it in a button prim (not the root unless you want it to turn on and off whenever the object is touched, rather than just when the prim is touched), and you are good to go. I know we said we don't do full scripts for people, but I find this technique of making a list of your target prims and then looping through it at run time so useful. string glow_prim = "glow prim"; integer i; integer max; integer toggle; //on/off binary toggle list glowing; list glow_on = [PRIM_GLOW,ALL_SIDES,0.05];// could change colour, texture and whatever here, too list glow_off = [PRIM_GLOW,ALL_SIDES,0.0]; list params; find_prims() { glowing=[]; //clear the list i=1; max = llGetNumberOfPrims(); do{ string s = llToLower((string) llGetLinkPrimitiveParams(i,[PRIM_DESC]));//get the description of each prim if(s==glow_prim){ //if the target name matches glowing +=[i]; //add the number to the list } //else if the description is something else, add it to another list if appropriate } while (i++<max); } default { state_entry() { find_prims(); max = llGetListLength(glowing); } changed (integer c){ if (c & CHANGED_LINK){ find_prims(); max = llGetListLength(glowing); } } touch_start(integer total_number) { toggle=!toggle; // i=0; i = max; if(toggle){ params = glow_on; } else{ params = glow_off; } while (i--) { llSetLinkPrimitiveParamsFast(llList2Integer(glowing,i),params); } // while(i++<max); } } Link to comment Share on other sites More sharing options...
conrad Evanier Posted April 8, 2011 Share Posted April 8, 2011 Hi all iv helped wolfen out inworld with this script and it did the job, you can add more effects to the glow prim light or colour. Am posting on here incase anyone else needs use of it ///THIS SCRIPT GOSE IN THE BUTTON PRIM/////////////////integer channel = 190;integer isOn;default{ state_entry() { } touch_start(integer num) { if (!isOn) { isOn = TRUE; llRegionSay(channel, "on"); } else { isOn = FALSE; llRegionSay(channel, "off"); } }}////////////////THEN PUT THIS SECOND SCRIPT IN GLOW PRIMS////////////////////////////////integer channel = 190;default{ state_entry() { llListen(channel,"","",""); } listen (integer channel, string name, key id, string message) { if (message == "on") { llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.9]); } if (message == "off") { llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.0]); } } } You can have as many glow prims as you like . Link to comment Share on other sites More sharing options...
Randall Ahren Posted April 8, 2011 Share Posted April 8, 2011 That looks like a very useful and efficient script. I have a follow-up question, how could I set alpha in a child prim with your script? Can it be done with the following line? glow_on = [PRIM_GLOW,ALL_SIDES,0.05];// could change colour, texture and whatever here, too Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 8, 2011 Share Posted April 8, 2011 For the alpha setting you can use llSetLinkAlpha Link to comment Share on other sites More sharing options...
Innula Zenovka Posted April 8, 2011 Share Posted April 8, 2011 To expand on Darkie's comment, one of the annoyances about llGet and llSetLinkPrimitiveParams is that the alpha value is part of the PRIM_COLOR flag, so while you can set the individual prims' alpha values as part of the llSetLinkPrimitiveParams call, in practice, if you do it that way, you have to check on the colour of each prim (which is possibly different for each face of the prim) and reset that, even though it may not be changing, at the same time you change the alpha value. So, in practice, it's usually far simpler (and not much slower) to set the alpha separately with llSetLinkAlpha, which leaves the colour alone. Link to comment Share on other sites More sharing options...
Randall Ahren Posted April 8, 2011 Share Posted April 8, 2011 OK, I think I understand. I need to add a few more lines of code for alpha. Something like: if(toggle){ params = glow_on; alpha_setting = alpha_half; } else{ params = glow_off; alpha_seting = alpha_zero; } do { llSetLinkPrimitiveParamsFast(llList2Integer(glowing,i),params); llSetLinkAlpha(llList2Integer(glowing,i),alpha_setting, ALL_SIDES); } I actually could not get the do loop to work. There was something incorrect with the link number, so I removed the do loop and hard-coded the correct link. My object is very simple. There are only two child prims and only one of the child prims does something. Unfortunately, my brain has a limited amount of RAM and my input buffer limit is often exceeded. Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 8, 2011 Share Posted April 8, 2011 I think there's a fencepost error in that sample code: it should try to execute the do loop one too many times because it's using postfix++, so it will increment after the comparison. Postfix increment/decrement is much more efficient than prefix in LSL -- I have no idea why. Anyway, i'd try replacing that loop with something like: i = max - 1;while (i--){ // do stuff} It will run through the prims in the opposite order, but that shouldn't matter. Of course, for a very simple application where you already know which prim you're changing and even what color it's supposed to be, you wouldn't need a loop at all and you can get by with a single call to llSetLinkPrimitiveParamsFast() specifying both PRIM_GLOW and, for the alpha, PRIM_COLOR. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted April 8, 2011 Share Posted April 8, 2011 Eep.. you are right, of course, Qie... sorry about that. I had tested it but the way I had linked it, the error was not apparent. I always seem to get that wrong. I will fix it in the example. ETA Are you sure it should be i = max -1 ? The only way I can get it to work decrementing it is if I set i=max: list prims_to_change;string change_me = "change me";list glow_on = [PRIM_GLOW,ALL_SIDES,0.05];// could change colour, texture and whatever here, toolist glow_off = [PRIM_GLOW,ALL_SIDES,0.0];list params;float alpha;integer toggle;integer i;integer max;find_prims() { prims_to_change=[]; //clear the list i=1; max = llGetNumberOfPrims(); do{ string s = llToLower((string) llGetLinkPrimitiveParams(i,[PRIM_DESC]));//get the description of each prim if(s==change_me){ //if the target name matches prims_to_change +=[i]; //add the number to the list // llOwnerSay((string)i); } //else if the description is something else, add it to another list if appropriate } while (++i<max);}default{ state_entry(){ find_prims(); max = llGetListLength(prims_to_change); } changed(integer change){ if(change & CHANGED_LINK){ find_prims(); max = llGetListLength(prims_to_change); } } touch_start(integer num){ toggle =!toggle; // llOwnerSay((string)prims_to_change); i= max; if(toggle){ params = glow_on; alpha = 0.5; } else{ params = glow_off; alpha = 1.0; } while(i--) { // llOwnerSay((string)i); // llOwnerSay((string)llList2Integer(prims_to_change,i)); llSetLinkPrimitiveParamsFast(llList2Integer(prims_to_change,i),params); llSetLinkAlpha(llList2Integer(prims_to_change,i),alpha,ALL_SIDES); } } } Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 8, 2011 Share Posted April 8, 2011 Innula Zenovka wrote: Are you sure it should be i = max -1 ? The only way I can get it to work decrementing it is if I set i=max: Oh jeez! You're right of course. (Dueling fenceposts!) Sorry for the confusion. Link to comment Share on other sites More sharing options...
Void Singer Posted April 8, 2011 Share Posted April 8, 2011 Qie Niangao wrote: [...] Postfix increment/decrement is much more efficient than prefix in LSL -- I have no idea why. [...] backwards.... prefix is the faster one (because it happens in line, so only one value on the stack) it's documented on the hacks page (and apparently x = -~x and x = ~-x are even faster still, although I haven't adopted them myself globally yet) Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 8, 2011 Share Posted April 8, 2011 Ah, yeah, thanks. Now that you mention the stack, that actually makes sense for the first time, so maybe I can remember it from now on. (I suppose I should feel bad about all the post-inc/decrementing I've gone out of my way to do, mistakenly thinking I was optimizing, but it pales in comparison to the amount of code I really should re-write once we get llRegionSayTo().) Link to comment Share on other sites More sharing options...
Void Singer Posted April 9, 2011 Share Posted April 9, 2011 lol, as far as mistakes fo,its a minor one.... and I hear you loud and clear on SayTo (although I'm not so sure about that name... it's really ObjectIM if you ask me... but no one ever really does lol) Link to comment Share on other sites More sharing options...
Recommended Posts
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