Jump to content

Sabastian Zane

Resident
  • Posts

    3
  • Joined

  • Last visited

Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Dear All, I have been in SL quite a few years, but my scripting skills are still quite raw. I'm after some tips please to reduce my scripting down to less lines, as I am sure there must be a better way and I just can't understand on the wiki as they don't always explain all the possible configurations. I want to check the value of a time is between certain minutes (i.e. between 21and 30, between 31 and 40, between 41 and 50 or above 50) so that my "speaking clock" will read out "20","30","40" or "50" before it reads the minutes (i.e. "50" "1" for 51 minutes. Could anybody kindly help me in getting the syntax right so that it can check all of the above in one "IF" instead of having to do IF > ELSE in the same way I have? I'm basically hoping to say something like if (Minute>=21 && Minute<30) or (Minute>=31 && Minute<40) or (Minute>=41 && Minute<50) or (Minute>50) For your reference "Minute" is the variable taken from the time and represents the minutes in the hour. unimin = the unit measurement of the minutes, decmin = the tens measurement of the minutes (i.e. if the time is 15:34 then the decmin would equal "3" and the unimin would equal "4") a snippet of my huge code below - Thank you so much in advance!! if (Minute>=21 && Minute<30) { if (unimin==1) { llPlaySound("1",1.0); } else if (unimin==2) { llPlaySound("2",1.0); } else if (unimin==3) { llPlaySound("3",1.0); } else if (unimin==4) { llPlaySound("4",1.0); } else if (unimin==5) { llPlaySound("5",1.0); } else if (unimin==6) { llPlaySound("6",1.0); } else if (unimin==7) { llPlaySound("7",1.0); } else if (unimin==8) { llPlaySound("8",1.0); } else if (unimin==9) { llPlaySound("9",1.0); } } else if (Minute>=31 && Minute<40) { if (unimin==1) { llPlaySound("1",1.0); } else if (unimin==2) { llPlaySound("2",1.0); } else if (unimin==3) { llPlaySound("3",1.0); } else if (unimin==4) { llPlaySound("4",1.0); } else if (unimin==5) { llPlaySound("5",1.0); } else if (unimin==6) { llPlaySound("6",1.0); } else if (unimin==7) { llPlaySound("7",1.0); } else if (unimin==8) { llPlaySound("8",1.0); } else if (unimin==9) { llPlaySound("9",1.0); } } else if (Minute>=41 && Minute<50) { if (unimin==1) { llPlaySound("1",1.0); } else if (unimin==2) { llPlaySound("2",1.0); } else if (unimin==3) { llPlaySound("3",1.0); } else if (unimin==4) { llPlaySound("4",1.0); } else if (unimin==5) { llPlaySound("5",1.0); } else if (unimin==6) { llPlaySound("6",1.0); } else if (unimin==7) { llPlaySound("7",1.0); } else if (unimin==8) { llPlaySound("8",1.0); } else if (unimin==9) { llPlaySound("9",1.0); } } else if (Minute>50) { if (unimin==1) { llPlaySound("1",1.0); } else if (unimin==2) { llPlaySound("2",1.0); } else if (unimin==3) { llPlaySound("3",1.0); } else if (unimin==4) { llPlaySound("4",1.0); } else if (unimin==5) { llPlaySound("5",1.0); } else if (unimin==6) { llPlaySound("6",1.0); } else if (unimin==7) { llPlaySound("7",1.0); } else if (unimin==8) { llPlaySound("8",1.0); } else if (unimin==9) { llPlaySound("9",1.0); } } else if (Minute<10) { if (unimin==1) { llPlaySound("1",1.0); } else if (unimin==2) { llPlaySound("2",1.0); } else if (unimin==3) { llPlaySound("3",1.0); } else if (unimin==4) { llPlaySound("4",1.0); } else if (unimin==5) { llPlaySound("5",1.0); } else if (unimin==6) { llPlaySound("6",1.0); } else if (unimin==7) { llPlaySound("7",1.0); } else if (unimin==8) { llPlaySound("8",1.0); } else if (unimin==9) { llPlaySound("9",1.0); } }
  2. Thanks for your help. Yep Linked Prims worked, thanks for that Qie Niangao It might look a bit messy, but I managed to reduce the whole object from 11 scripts to this single script, and NO MORE SAYING AND LISTENING !! YAY!! And I know I might have found another method to make them light up, but having them light up in this order makes it look more realistic, as can be seen here :- https://gyazo.com/fd9d7c33094b4d0031aa538cdc1cd8b3 Script is as follows:- // VU METER - Sabastian Zane default { state_entry() { llSetTimerEvent(0.125); } timer() { integer rand = (integer)llFrand(10); { if (rand < 1) { llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE ]); } else if (rand < 2) { llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_LINK_TARGET,11, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,2, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); } else if (rand < 4) { llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_LINK_TARGET,11, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,2, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,10, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,3, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); } else if (rand < 6) { llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_LINK_TARGET,11, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,2, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,10, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,3, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,9, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,4, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); } else if (rand < 8) { llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_LINK_TARGET,11, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,2, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,10, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,3, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,9, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,4, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,8, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,5, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); } else if (rand > 7) { llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_LINK_TARGET,11, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,2, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,10, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,3, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,9, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,4, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,8, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,5, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,7, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); llSetLinkPrimitiveParamsFast(LINK_SET, [ PRIM_LINK_TARGET,6, PRIM_POINT_LIGHT, TRUE, <0.0,1.0,0.0>,0.1,10,0.0, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES,0.2 ]); } } } }
  3. Ok, so I'm quite new to this and need some guidance please. I've created a VU Meter, music volume lights that are meant to go up and down to the music. They don't really scan for music, but randomize a number (simulated volume) and flash according to the randomised number. Currently I have a controller prim which "Says" the code depending on the number, and then 5 prims that Listen, labeled A, B, C, D & E. I am restricted to a 1 second delay, and wondered if there was a way to speed up the lights to a more realistic reaction, but I am also aware that its saying and listening and could cause issues with lag/reaction times etc. Your assistance would be greatly appreciated. I am new to coding and for the most part piece together parts of coding from one script to another to make it work.. so still learning. So the controller script is:- // VU METER default { state_entry() { llSetTimerEvent(0.125); } timer() { integer rand = (integer)llFrand(10); { if (rand < 1) { llSay(-123, "Z");} else if (rand < 2) { llSay(-123, "A");} else if (rand < 4) { llSay(-123, "B");} else if (rand < 6) { llSay(-123, "C");} else if (rand < 8) { llSay(-123, "D");} else if (rand > 7) { llSay(-123, "E");} } } } And then the Listening Script looks like this (This is for the first Prim - A, which actually lights up on any number as it's the left most piece of the VU Meter and so lights up on ANY sound) integer light_s = TRUE; vector lightcolour = <0.0, 1.0, 0.0>; vector lightcolourdark = <0.0, 0.5, 0.0>; float intensity = 0.1; // 0-1 float radius = 10.0; // 0-10 float falloff = 0.0; // 0-1 float glow = 0.2; default { state_entry() { llListen(-123,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (message == "A") { // change color! llSetColor(lightcolour,ALL_SIDES); llSetPrimitiveParams([ PRIM_POINT_LIGHT, light_s, lightcolour, intensity, radius, falloff, PRIM_FULLBRIGHT, ALL_SIDES, light_s, PRIM_GLOW, ALL_SIDES, glow ]); } else if (message == "Z") { // change color! llSetColor(lightcolour,ALL_SIDES); llSetPrimitiveParams([ PRIM_POINT_LIGHT, FALSE, lightcolourdark, 0, radius, falloff, PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_GLOW, ALL_SIDES, 0 ]); } else if (message == "B") { // change color! llSetColor(lightcolour,ALL_SIDES); llSetPrimitiveParams([ PRIM_POINT_LIGHT, light_s, lightcolour, intensity, radius, falloff, PRIM_FULLBRIGHT, ALL_SIDES, light_s, PRIM_GLOW, ALL_SIDES, glow ]); } else if (message == "C") { // change color! llSetColor(lightcolour,ALL_SIDES); llSetPrimitiveParams([ PRIM_POINT_LIGHT, light_s, lightcolour, intensity, radius, falloff, PRIM_FULLBRIGHT, ALL_SIDES, light_s, PRIM_GLOW, ALL_SIDES, glow ]); } else if (message == "D") { // change color! llSetColor(lightcolour,ALL_SIDES); llSetPrimitiveParams([ PRIM_POINT_LIGHT, light_s, lightcolour, intensity, radius, falloff, PRIM_FULLBRIGHT, ALL_SIDES, light_s, PRIM_GLOW, ALL_SIDES, glow ]); } else if (message == "E") { // change color! llSetColor(lightcolour,ALL_SIDES); llSetPrimitiveParams([ PRIM_POINT_LIGHT, light_s, lightcolour, intensity, radius, falloff, PRIM_FULLBRIGHT, ALL_SIDES, light_s, PRIM_GLOW, ALL_SIDES, glow ]); } } } Many thanks in advance. Sab
×
×
  • Create New...