RilaVirum Posted February 15, 2021 Share Posted February 15, 2021 (edited) Hello, need help please! I'm getting a syntax error in my script, this is the line: float lightIntensity = 1.0; //Syntax Error //Living Room Table that flashes colors //(Rewriting this script from 2 objects to one) list TableLinkNumber = [1]; // Set the color of the table when it is OFF vector TableOFF = <0.434, 0.434, 0.434>; //Make the list of colors I'm picking two colors for right now list sequenceOfColors = [<0.163, 0.845, 0.022>,<0.760, 0.039, 0.021>]; //How many seconds between color changes? Whole Numbers only for this one integer InSECONDS = 5; // GLOW - how much glow in the object? float GlowNumber = 1.0; // Light emissions if enabled the object will emit light when on integer LightOn = TRUE float lightIntensity = 1.0; //Syntax Error float lightRadius = 5.0; float lightFallOff = 1.0; // on-rez state integer rezON = TRUE; //Set TRUE to rez "on" set FALSE to rez "off" // ==== END OF CONFIG ==== // These are integers to control the time and the state of the tables changing colors integer timerSeconds = 0; integer colorState = 0; integer colorTime = 0; //Functions go here //I need help with the FUNCTIONS part of this script! I'm not sure if this section is needed for a one color flashing object. //This FUNCTION section seems to be set up for more than one object DoColorCycle() { //This is where the magic happens! //Update all the colors and other parameters list params = []; integer i; integer max = llGetListLength(TableLinkNumber); for (i=0;i<max;i++) { params += [PRIM_COLOR,ALL_SIDES,1.0]; params += [PRIM_GLOW,ALL_SIDES,GlowNumber]; params += [PRIM_POINT_LIGHT,ALL_SIDES,LightOn,llList2Vector(sequenceOfColors,colorState),lightIntensity,lightRadius,lightFalloff]; //Note params += [PRIM_LINK_TARGET] Removed } llSetLinkPrimitiveParamsFast(0,params); } default { // the default state is used ONLY for validating our config and setup. state_entry() { //ok, we've just been rezzed or reset. Setup time! //scan the linkset looking for "Object1 on the description box, make sure what you write in the description box is detected. integer n = llDetectedKey(0); if (n == 1) { //Object Detected llOwnerSay("Link Number Detected"); return; } integer i; for (i=1;i<=n;i++) //DESCRIPTION BOX SET-UP { string description = llList2String(llGetPrimitiveParams(i,[PRIM_DESC]),0); if (description == "Object1") { TableLinkNumber += [i]; } //ok, now the list is connected to the description section, we need to make sure the Object Link Number is Valid and Unique TableLinkNumber = SortUniqueLinks(TableLinkNumber); // Recheck this here if (!(llGetListLength(TableLinkNumber))) { //oops! The List length is zero llOwnerSay(Object1 is not detected Fix this and re-rez or click me to reset the script."); return; } // Now set up the timer parameter. The most efficient cycle length is the highest common divisor of the cycle times // for both color cycles. Obviously if either is prime and not a divisor of the other, this will end up being 1, but // if we can be more efficient than triggering a timer event every second, why not do it? // // first, though, let's make sure the timer intervals are valid! if (!(InSECONDS >= 1)) { //oops! no they aint valid. Timer intervals must be a positive integer. llOwnerSay("The timer intervals must be a positive whole number Fix this and either re-rez or touch me to reset the script."); return; } timerSeconds = Hcd(InSECONDS); // All validations have now passed and setup is complete. We're good to go! // set either running or off state depending on the "rezOn" config setting. if (rezOn) state running; else state off; } touch_start(integer num) { // we'll only stay in the default state if there was a config error, so touching means reset the script. llResetScript(); } on_rez(integer start) { // always reset on rez. llResetScript(); } } state running { // this state runs the timer, progressing the cycle state forward every time the timer ticks. // a touch in this state will halt this process and switch to the off state. state_entry() { // set up the timer llSetTimerEvent((float)timerSeconds); //don't update the numbers, just pick up where we left off DoColorCycle(); } timer() { //the timer has ticked. *something* needs an update! But what? integer update1 = FALSE; integer update2 = FALSE; // Let's find out. Increment both cycles time by the length of the timer cycle. colorTime += timerSeconds; //I deleted color2time here // if either one is at its threshold, update its cycle and set the flag for an update. if (colorTime >= InSeconds) { update1 =TRUE; colorTime = 0; colorState++; if (colorState >= llGetListLength(sequenceOfColors)) colorState = 0; } // If all we needed to do was update the times, we're done. But if either cycle passed its threshold we // must update the object params. if (update1) DoColorCycle(); } // for "functional" touches, it's always better to detect the end of the mouse-click so we use // a touch_end event instead of a touch_start touch_end(integer num) { // switch to off state. state off; } on_rez(integer start) { // always reset on rez. llResetScript(); } } state off { // this state is real simple. it kills the timer, sets the "off" color with no glow or light emission // then waits for a touch to start running again. state_entry() { llSetTimerEvent(0.0); list params = []; integer i; integer max = llGetListLength(TableLinkedNumber); for (i=0;i<max;i++) { //PRIM_LINK_TARGET removed, I'm not sure if I need it params += [PRIM_COLOR,ALL_SIDES,TableOFF,1.0]; params += [PRIM_GLOW,ALL_SIDES,0.0]; params += [PRIM_POINT_LIGHT,FALSE,ZERO_VECTOR,0.0,0.0,0.0]; } llSetLinkPrimitiveParamsFast(0,params); } // for "functional" touches, it's always better to detect the end of the mouse-click so we use // a touch_end event instead of a touch_start touch_end(integer num) { // switch to running state. state running; } on_rez(integer start) { // always reset on rez. llResetScript(); } } Edited February 15, 2021 by RilaVirum Link to comment Share on other sites More sharing options...
Qie Niangao Posted February 15, 2021 Share Posted February 15, 2021 The previous line isn't terminated by a semicolon. (I haven't loaded this into the editor or looked at the code at all to see what other problems await.) 1 1 Link to comment Share on other sites More sharing options...
sandi Mexicola Posted February 15, 2021 Share Posted February 15, 2021 34 minutes ago, RilaVirum said: integer LightOn = TRUE Well, Qie beat me to the answer, but yes, you need a semicolon after TRUE. 2 Link to comment Share on other sites More sharing options...
RilaVirum Posted February 15, 2021 Author Share Posted February 15, 2021 Oh! haha I see it now. Ok thank you Link to comment Share on other sites More sharing options...
RilaVirum Posted February 15, 2021 Author Share Posted February 15, 2021 Ok I'm having another syntax error where it says: touch_start(Integer num) Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 15, 2021 Share Posted February 15, 2021 Go back and double check the { brackets in that event. You are missing one. Errors like this are very common but are also very easy to detect. As you script, indent carefully so that you know where each scope within the script begins and ends. Keep track of matching brackets and parentheses. Watch for missing semicolons. We all have lapses of attention from time to time, but errors like that are easy to spot and fix. It might help to use a script editor like Sublime Text that watches for those things automatically. 2 1 Link to comment Share on other sites More sharing options...
RilaVirum Posted February 15, 2021 Author Share Posted February 15, 2021 Ok! I will check for these syntax errors, thank you 1 Link to comment Share on other sites More sharing options...
sandi Mexicola Posted February 18, 2021 Share Posted February 18, 2021 Sublime is my favorite! 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