CataeaAstrielle Posted December 13, 2023 Share Posted December 13, 2023 Hello! I am BRAND new to scripting, and wrote up two separate scripts that I'm trying to now combine to get a candle flame to animate, toggle on and off by touch, and glow (also toggled). I keep getting a syntax error and just have no idea where I'm going wrong. I'd LOVE to have the script put in the object itself and not just the specific face in the linkset, but that seems beyond my understanding at this point. Any help would be greatly appreciated. integer OFF = TRUE; integer toggleState = 0; // 0: Normal state, 1: Active state integer faceToToggle = ALL_SIDES; // Replace with the face number you want to control default { state_entry() { llSetTextureAnim (ANIM_ON | LOOP, ALL_SIDES, 5, 2, 0, 0,14.0); llSetAlpha(1.0, ALL_SIDES); } on_rez(integer start_param) { llResetScript(); } touch_start(integer num) { if(llDetectedKey(0) == llGetOwner()) { if(OFF) { llSetAlpha(1.0, ALL_SIDES); OFF = FALSE; { // Toggle between states on touch toggleState = 1 - toggleState; { // Turn off glow, set full bright to false, set transparency to 100 llSetPrimitiveParams( [PRIM_GLOW, faceToToggle, 0.0, PRIM_FULLBRIGHT, faceToToggle, FALSE]); llSetLinkAlpha(LINK_THIS, 0.0, faceToToggle); } else { llSetAlpha(0.01, ALL_SIDES); OFF = TRUE; { // Turn on glow, set full bright to true, set transparency to 0 llSetPrimitiveParams( [PRIM_GLOW, faceToToggle, 0.3, PRIM_FULLBRIGHT, faceToToggle, TRUE]); llSetLinkAlpha(LINK_THIS, 1.0, faceToToggle); } Link to comment Share on other sites More sharing options...
Quistess Alpha Posted December 14, 2023 Share Posted December 14, 2023 At a glance, it looks like not all of your '{'s have matching '}'s. Some of your '{'s look like maybe you intended them to be '}'s. Usually, we as scripters use indentation to make it more clear where the brackets are and are supposed to be. 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted December 14, 2023 Share Posted December 14, 2023 integer OFF = TRUE; // this variable is never read, remove it: //integer toggleState = 0; // 0: Normal state, 1: Active state integer faceToToggle = ALL_SIDES; // Replace with the face number you want to control default { state_entry() { llSetTextureAnim (ANIM_ON | LOOP, ALL_SIDES, 5, 2, 0, 0,14.0); llSetAlpha(1.0, ALL_SIDES); } on_rez(integer start_param) { llResetScript(); } touch_start(integer num) { if(llDetectedKey(0) != llGetOwner()) return; // some would say this is bad form, but IMO it's more neat than enclosing the rest of the event in a section. OFF = !OFF; // because each condition set it to the opposite value, it makes more sense to reverse it before the if clause. // ^ roughly the same as OFF = 1-OFF; if(OFF) { llSetAlpha(1.0, ALL_SIDES); // Toggle between states on touch // Turn off glow, set full bright to false, set transparency to 100 llSetPrimitiveParams( [ PRIM_GLOW, faceToToggle, 0.0, PRIM_FULLBRIGHT, faceToToggle, FALSE ]); llSetLinkAlpha(LINK_THIS, 0.0, faceToToggle); } else { llSetAlpha(0.01, ALL_SIDES); // Turn on glow, set full bright to true, set transparency to 0 llSetPrimitiveParams( [ PRIM_GLOW, faceToToggle, 0.3, PRIM_FULLBRIGHT, faceToToggle, TRUE ]); llSetLinkAlpha(LINK_THIS, 1.0, faceToToggle); } } } is how it might look with better indentation and a few fixes. I haven't tested it. Link to comment Share on other sites More sharing options...
CataeaAstrielle Posted December 19, 2023 Author Share Posted December 19, 2023 On 12/13/2023 at 6:53 PM, Quistess Alpha said: is how it might look with better indentation and a few fixes. I haven't tested it. I appreciate your answer! And it does work, however the states seem to be sequential and not simultaneous. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted December 19, 2023 Share Posted December 19, 2023 (edited) 9 hours ago, CataeaAstrielle said: however the states seem to be sequential and not simultaneous. search/ replace "llSetAlpha(" -> "llSetLinkAlpha(LINK_THIS, " "llSetPrimitiveParams( " -> "llSetLinkPrimitiveParamsFast(LINK_THIS, " some 'older functions' have a built in delay. Without the delay it should look like things that happen very rapidly in succession happen at the same time. ETA: llSetAlpha doesn't actually have a delay, so that search/replace is unnecessary. Edited December 19, 2023 by Quistess Alpha 1 Link to comment Share on other sites More sharing options...
CataeaAstrielle Posted December 19, 2023 Author Share Posted December 19, 2023 6 hours ago, Quistess Alpha said: search/ replace "llSetAlpha(" -> "llSetLinkAlpha(LINK_THIS, " "llSetPrimitiveParams( " -> "llSetLinkPrimitiveParamsFast(LINK_THIS, " some 'older functions' have a built in delay. Without the delay it should look like things that happen very rapidly in succession happen at the same time. ETA: llSetAlpha doesn't actually have a delay, so that search/replace is unnecessary. Thank you so much! I appreciate all your help. So much to learn! Link to comment Share on other sites More sharing options...
HoRuS Petrov Posted December 22, 2023 Share Posted December 22, 2023 On 12/14/2023 at 1:53 AM, Quistess Alpha said: integer OFF = TRUE; // this variable is never read, remove it: //integer toggleState = 0; // 0: Normal state, 1: Active state integer faceToToggle = ALL_SIDES; // Replace with the face number you want to control default { state_entry() { llSetTextureAnim (ANIM_ON | LOOP, ALL_SIDES, 5, 2, 0, 0,14.0); llSetAlpha(1.0, ALL_SIDES); } on_rez(integer start_param) { llResetScript(); } touch_start(integer num) { if(llDetectedKey(0) != llGetOwner()) return; // some would say this is bad form, but IMO it's more neat than enclosing the rest of the event in a section. OFF = !OFF; // because each condition set it to the opposite value, it makes more sense to reverse it before the if clause. // ^ roughly the same as OFF = 1-OFF; if(OFF) { llSetAlpha(1.0, ALL_SIDES); // Toggle between states on touch // Turn off glow, set full bright to false, set transparency to 100 llSetPrimitiveParams( [ PRIM_GLOW, faceToToggle, 0.0, PRIM_FULLBRIGHT, faceToToggle, FALSE ]); llSetLinkAlpha(LINK_THIS, 0.0, faceToToggle); } else { llSetAlpha(0.01, ALL_SIDES); // Turn on glow, set full bright to true, set transparency to 0 llSetPrimitiveParams( [ PRIM_GLOW, faceToToggle, 0.3, PRIM_FULLBRIGHT, faceToToggle, TRUE ]); llSetLinkAlpha(LINK_THIS, 1.0, faceToToggle); } } } is how it might look with better indentation and a few fixes. I haven't tested it. integer OFF = TRUE; // this variable is never read, remove it: //integer toggleState = 0; // 0: Normal state, 1: Active state integer faceToToggle = ALL_SIDES; // Replace with the face number you want to control default { state_entry() { llSetTextureAnim (ANIM_ON | LOOP, ALL_SIDES, 5, 2, 0, 0,14.0); llSetAlpha(1.0, ALL_SIDES); } on_rez(integer start_param) { llResetScript(); } touch_start(integer num) { if(llDetectedKey(0) != llGetOwner()) return; // some would say this is bad form, but IMO it's more neat than enclosing the rest of the event in a section. //OFF = !OFF; // because each condition set it to the opposite value, it makes more sense to reverse it before the if clause. // ^ roughly the same as OFF = 1-OFF; //if(OFF) { llSetAlpha(1.0-!(OFF=!OFF)*0.09, ALL_SIDES); // Toggle between states on touch // Turn off glow, set full bright to false, set transparency to 100 llSetPrimitiveParams( [ PRIM_GLOW, faceToToggle,!OFF*0.3, PRIM_FULLBRIGHT, faceToToggle,!OFF]); llSetLinkAlpha(LINK_THIS,!OFF, faceToToggle); } /*else { llSetAlpha(0.01, ALL_SIDES); // Turn on glow, set full bright to true, set transparency to 0 llSetPrimitiveParams( [ PRIM_GLOW, faceToToggle, 0.3, PRIM_FULLBRIGHT, faceToToggle, TRUE ]); llSetLinkAlpha(LINK_THIS, 1.0, faceToToggle); }*/ } } 1 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