Tattooshop Posted July 28, 2021 Share Posted July 28, 2021 (edited) Hello! I am trying to make a sliders to adjust the glossiness and environment levels of the object. I read somewhere that you can split the prim surface into multiple sections, and depending on which section you click on, a value will be assigned, but I can't find it. Please nudge me in the right direction? Edited July 28, 2021 by Tattooshop Link to comment Share on other sites More sharing options...
KT Kingsley Posted July 28, 2021 Share Posted July 28, 2021 (edited) You can use the function llDetectedTouchUV in one of the touch events to get the texture coordinates for where the prim was touched, and then scale the X or Y value (depending on which way the prim is orientated) by 255 (and convert to integer) to get the values you want. (Or use the function llDetectedTouchST to get the prim surface coordinates.) Edited July 28, 2021 by KT Kingsley 2 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 28, 2021 Share Posted July 28, 2021 (edited) If you just want a 1-dimensional slider, I recently posted the code for that in the lsl library: Edited July 28, 2021 by Quistess Alpha 1 1 Link to comment Share on other sites More sharing options...
Tattooshop Posted July 28, 2021 Author Share Posted July 28, 2021 (edited) 5 hours ago, KT Kingsley said: You can use the function llDetectedTouchUV in one of the touch events to get the texture coordinates for where the prim was touched, and then scale the X or Y value (depending on which way the prim is orientated) by 255 (and convert to integer) to get the values you want. (Or use the function llDetectedTouchST to get the prim surface coordinates.) 3 hours ago, Quistess Alpha said: If you just want a 1-dimensional slider, I recently posted the code for that in the lsl library: Thanks a lot for the answers and great examples! 👍 Here's what I've done so far, (it would be great to add the visual slider primitive itself, though ). But also faced such a problem that I need to change the glossiness / environment level without changing the texture itself. Is it possible to set their value without changing the texture? I mean PRIM_SPECULAR / PRIM_NORMAL things or whatever the way. default { touch_start(integer total_number) { if (llDetectedKey(0) != llGetOwner()) return; { vector touchUV = llDetectedTouchUV(0); integer gloss = (integer) (touchUV.x * 255); integer envir = (integer) (touchUV.x * 255); string slider = llGetLinkName(llDetectedLinkNumber(0)); if (slider == "gloss_slider_prim") { llSay(0, (string)gloss); } if (slider == "envir_slider_prim") { llSay(0, (string)envir); } } } } Edited July 28, 2021 by Tattooshop Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 28, 2021 Share Posted July 28, 2021 (edited) 19 minutes ago, Tattooshop said: Is it possible to set their value without changing the texture? IMO it's best practice to llGetLinkPrimitiveParams() the texture info, then llListReplaceList() the values that you want to change, and finally llSetLinkPrimitiveParamsFast() the modified list of parameters. PRIM_NORMAL and PRIM_SPECULAR have a lot of options, most of which you generally want to leave alone. (The forum's being mean to me with the formatting:) PRIM_NORMAL 37 Sets the prim's normal map attributes. [ PRIM_NORMAL, integer face, string texture, vector repeats, vector offsets, float rotation_in_radians ] PRIM_SPECULAR 36 Sets the prim's specular map attributes. [ PRIM_SPECULAR, integer face, string texture, vector repeats, vector offsets, float rotation_in_radians, vector color, integer glossiness, integer environment ] Edited July 28, 2021 by Quistess Alpha 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 28, 2021 Share Posted July 28, 2021 (edited) 32 minutes ago, Tattooshop said: (it would be great to add the visual slider primitive itself, though ) The easy lazy way to do that would be to just set the position of the "visual slider primitive" to llDetectedTouchPos(), after that there are a few refinements you can make that are build-specific. (be sure to either have the indicator prim be hollow, or add an offset to put it behind the touchable portion of the slider. P.S. IIRC it's possible to set the click-action to none for the background prim on your hud, so the mouse-pointer changes shape only when you hover over a buton or interactable element. Edited July 28, 2021 by Quistess Alpha 1 Link to comment Share on other sites More sharing options...
Tattooshop Posted July 29, 2021 Author Share Posted July 29, 2021 (edited) 13 hours ago, Quistess Alpha said: The easy lazy way to do that would be to just set the position of the "visual slider primitive" to llDetectedTouchPos(), after that there are a few refinements you can make that are build-specific. (be sure to either have the indicator prim be hollow, or add an offset to put it behind the touchable portion of the slider. P.S. IIRC it's possible to set the click-action to none for the background prim on your hud, so the mouse-pointer changes shape only when you hover over a buton or interactable element. Thanks a lot! Now the slider moves to almost any position in which I pressed, if the strip is very thin, then it is not very noticeable, and if it is thick, then not very much cute... How to make the slider move only along the X-axis? And I think I broke my HUD, if i change its position the slider goes off-screen ... gPos = llDetectedTouchPos(0); ... if (slider == "gloss_slider_prim") { llSetLinkPrimitiveParamsFast(3, [PRIM_POS_LOCAL, gPos]); } if (slider == "envir_slider_prim") { llSetLinkPrimitiveParamsFast(2, [PRIM_POS_LOCAL, gPos]); } Edited July 29, 2021 by Tattooshop Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 29, 2021 Share Posted July 29, 2021 For making the slider only go along the x-axis, I bet you could set the z-coordinate of the position to the z-coordinate of the bar's position: gPos = llDetectedTouchPos(0); vector posLink = llList2Vector(llGetLinkPrimitiveParams(llDetectedLinkNumber(0),[PRIM_POSITION]),0); gPos.z = posLink.z; // fixes up and down movement; //gPos.x = posLink.x-0.05; // put the slider behind the bar. /* ... */ if (slider == "gloss_slider_prim") { // using PRIM_POSITION instead of PRIM_POS_LOCAL should fix the problm that happens if you move the HUD. llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, gPos]); } // "else if" is more efficient here: else if (slider == "envir_slider_prim") { llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, gPos]); } 1 Link to comment Share on other sites More sharing options...
Tattooshop Posted July 29, 2021 Author Share Posted July 29, 2021 (edited) 6 hours ago, Quistess Alpha said: For making the slider only go along the x-axis, I bet you could set the z-coordinate of the position to the z-coordinate of the bar's position: gPos = llDetectedTouchPos(0); vector posLink = llList2Vector(llGetLinkPrimitiveParams(llDetectedLinkNumber(0),[PRIM_POSITION]),0); gPos.z = posLink.z; // fixes up and down movement; //gPos.x = posLink.x-0.05; // put the slider behind the bar. /* ... */ if (slider == "gloss_slider_prim") { // using PRIM_POSITION instead of PRIM_POS_LOCAL should fix the problm that happens if you move the HUD. llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, gPos]); } // "else if" is more efficient here: else if (slider == "envir_slider_prim") { llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, gPos]); } Thank you so much! I did some tests but the slider doesnt move if I use PRIM_POSITION to get llGetLinkPrimitiveParams. I tried to use PRIM_POS_LOCAL there and then it moves ok, no z axis offsets 👍 ... but then HUD move problem arise. What did I miss? I put full script here: vector gPos; default { touch_start(integer total_number) { if (llDetectedKey(0) != llGetOwner()) return; { string slider = llGetLinkName(llDetectedLinkNumber(0)); { gPos = llDetectedTouchPos(0); vector posLink = llList2Vector(llGetLinkPrimitiveParams(llDetectedLinkNumber(0), [PRIM_POSITION]), 0); gPos.z = posLink.z; // fixes up and down movement; //gPos.x = posLink.x-0.05; // put the slider behind the bar. vector touchUV = llDetectedTouchUV(0); integer gloss = (integer)(touchUV.x * 255); integer envir = (integer)(touchUV.x * 255); if (slider == "gloss_slider_prim") { // using PRIM_POSITION instead of PRIM_POS_LOCAL should fix the problm that happens if you move the HUD. llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, gPos]); llSay(0, "gloss: " + (string) gloss); } // "else if" is more efficient here: else if (slider == "envir_slider_prim") { llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, gPos]); llSay(0, "envir: " + (string) envir); } } } } } Edited July 29, 2021 by Tattooshop Link to comment Share on other sites More sharing options...
Tattooshop Posted July 30, 2021 Author Share Posted July 30, 2021 (edited) By the way, as soon as I use PRIM_POS_LOCAL either in that place vector posLink = llList2Vector(llGetLinkPrimitiveParams(llDetectedLinkNumber(0), [PRIM_POSITION]), 0); or that llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, gPos]); the slider starts working, but when I move HUD, the slider moves off-screen again ... When using PRIM_POSITION both there and there the slider does not seem to move at all ... Edited July 30, 2021 by Tattooshop Link to comment Share on other sites More sharing options...
Tattooshop Posted July 30, 2021 Author Share Posted July 30, 2021 And here's another question. Previously, I only had to pass "yes or no" style messages, but here it is from 0 to 255 values, how can I get the listener to perceive such a range and so that the script listener will recognize which value to assign to gloss and which to environment? Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 30, 2021 Share Posted July 30, 2021 20 minutes ago, Tattooshop said: And here's another question. Previously, I only had to pass "yes or no" style messages, but here it is from 0 to 255 values, how can I get the listener to perceive such a range and so that the script listener will recognize which value to assign to gloss and which to environment? you can typecast other values into strings, and add the strings together with separators, then use either llCSV2list or llParseString2List to get the values back out. 1 Link to comment Share on other sites More sharing options...
CaithLynnSayes Posted July 31, 2021 Share Posted July 31, 2021 Here's something i threw together a couple of years ago. Its an example prim with 5 sliders that uses this single script. let me know if you want me to send you a working version inworld. integer memoryLimit = 30000; vector screenPos; vector screenScale; rotation screenRot; vector hudPos; vector crossPos; // make it global. list params; // make it global. //LINKS integer LINK_screen;//the currently active screen integer LINK_sliderbase1; integer LINK_sliderarrow1; integer LINK_sliderbase2; integer LINK_sliderarrow2; integer LINK_sliderbase3; integer LINK_sliderarrow3; integer LINK_sliderbase4; integer LINK_sliderarrow4; integer LINK_sliderbase5; integer LINK_sliderarrow5; integer LINK_slider1text; integer LINK_slider2text; integer LINK_slider3text; integer LINK_slider4text; integer LINK_slider5text; string name; memoryLimitTest() { llSetMemoryLimit(memoryLimit); llScriptProfiler(PROFILE_SCRIPT_MEMORY); llScriptProfiler(PROFILE_NONE); // /* llSetText("Limited Memory " + (string)llGetMemoryLimit() + "\nUsed Memory " + (string)llGetUsedMemory() + "\nFree Memory " + (string)llGetFreeMemory(),<1,1,1>,1); // */ integer freeMemoryLeft = llGetFreeMemory(); float lowMemoryTrigger = 500; if (freeMemoryLeft < lowMemoryTrigger) { //llSay(0,"Running out of memory!"); llOwnerSay("Possible lag detected. Freeing up memory. Please wait one second..."); llResetScript(); } } getLinks() { integer total = llGetNumberOfPrims() + 1; string name; while ((total--) -1) { name = llGetLinkName(total); if (name == "SliderBase1") { LINK_sliderbase1 = total; } else if (name == "SliderArrow1") { LINK_sliderarrow1 = total; } else if (name == "SliderBase2") { LINK_sliderbase2 = total; } else if (name == "SliderArrow2") { LINK_sliderarrow2 = total; } else if (name == "SliderBase3") { LINK_sliderbase3 = total; } else if (name == "SliderArrow3") { LINK_sliderarrow3 = total; } else if (name == "SliderBase4") { LINK_sliderbase4 = total; } else if (name == "SliderArrow4") { LINK_sliderarrow4 = total; } else if (name == "SliderBase5") { LINK_sliderbase5 = total; } else if (name == "SliderArrow5") { LINK_sliderarrow5 = total; } else if (name == "Slider1Text") { LINK_slider1text = total; } else if (name == "Slider2Text") { LINK_slider2text = total; } else if (name == "Slider3Text") { LINK_slider3text = total; } else if (name == "Slider4Text") { LINK_slider4text = total; } else if (name == "Slider5Text") { LINK_slider5text = total; } } name = ""; } //this function is because i often ask for a local position vector llGetLinkLocalOffset(integer link) { return llList2Vector(llGetLinkPrimitiveParams(link, [PRIM_POS_LOCAL]), 0); } //we generate a params list with this function list moveSlider(integer link, vector pos, vector rr) { //This vector puts the slider in the middle if the mouse cursor went off the slider prim while sliding to avoid the -100 value from being send. //(May need to find a better solution, but works for now :/) // A better solution would be to remember the last postition and return to that if the mouse went off sliding and button released, like any program does. I may get around it. Possibly. vector midCrossPos = screenPos + (<0, 0.500 * screenScale.y, 0.50 * screenScale.z> - screenScale * 0.5 ) * (<0, 0, 1, 0> * screenRot); vector crossPos = screenPos + (<0, 0.500 * screenScale.y, rr.y * screenScale.z> - screenScale * 0.5 ) * (<0, 0, 1, 0> * screenRot); if (link == LINK_sliderbase1) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow1, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow1, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase2) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow2, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow2, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase3) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow3, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow3, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase4) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow4, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow4, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase5) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow5, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow5, PRIM_POS_LOCAL, midCrossPos ]; } } return params; } default { on_rez(integer param) { llResetScript(); } state_entry() { getLinks(); memoryLimitTest(); } touch_start(integer total_number) { LINK_screen = llDetectedLinkNumber(0); hudPos = llGetLocalPos(); //scroll screen screenPos = llGetLinkLocalOffset(LINK_screen); screenScale = llList2Vector(llGetLinkPrimitiveParams(LINK_screen, [PRIM_SIZE]), 0); screenRot = llList2Rot(llGetLinkPrimitiveParams(LINK_screen, [PRIM_ROT_LOCAL]), 0); //memoryLimitTest(); } touch(integer num) { vector rrGlobalOffset = llDetectedTouchUV(0); float outcome = rrGlobalOffset.y * 100; if (LINK_screen == LINK_sliderbase1) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider1text, PRIM_TEXT, "Slider 1\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider1text, PRIM_TEXT, "Slider 1\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase2) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider2text, PRIM_TEXT, "Slider 2\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider2text, PRIM_TEXT, "Slider 2\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase3) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider3text, PRIM_TEXT, "Slider 3\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider3text, PRIM_TEXT, "Slider 3\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase4) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider4text, PRIM_TEXT, "Slider 4\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider4text, PRIM_TEXT, "Slider 4\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase5) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider5text, PRIM_TEXT, "Slider 5\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider5text, PRIM_TEXT, "Slider 5\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } //Global Position Vector llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_screen, PRIM_TEXT, (string)rrGlobalOffset, <1.0, 1.0, 1.0>, 0.0 ] + moveSlider(LINK_screen, llDetectedTouchPos(0), rrGlobalOffset)); memoryLimitTest(); } touch_end(integer num) { //Value from 0.0 to 1.0 vector rrGlobalOffset = llDetectedTouchUV(0); float outcome = rrGlobalOffset.y * 100; if (LINK_screen == LINK_sliderbase1) { if (outcome == -100) { llSay(0,"Slider 1 said: 50"); return; } llSay(0,"Slider 1 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase2) { if (outcome == -100) { llSay(0,"Slider 2 said: 50"); return; } llSay(0,"Slider 2 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase2) { if (outcome == -100) { llSay(0,"Slider 2 said: 50"); return; } llSay(0,"Slider 2 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase3) { if (outcome == -100) { llSay(0,"Slider 3 said: 50"); return; } llSay(0,"Slider 3 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase4) { if (outcome == -100) { llSay(0,"Slider 4 said: 50"); return; } llSay(0,"Slider 4 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase5) { if (outcome == -100) { llSay(0,"Slider 5 said: 50"); return; } llSay(0,"Slider 5 said: " + (string)llRound(outcome)); } LINK_screen = LINK_THIS; } } 1 Link to comment Share on other sites More sharing options...
Tattooshop Posted July 31, 2021 Author Share Posted July 31, 2021 1 hour ago, CaithLynnSayes said: Here's something i threw together a couple of years ago. Its an example prim with 5 sliders that uses this single script. let me know if you want me to send you a working version inworld. integer memoryLimit = 30000; vector screenPos; vector screenScale; rotation screenRot; vector hudPos; vector crossPos; // make it global. list params; // make it global. //LINKS integer LINK_screen;//the currently active screen integer LINK_sliderbase1; integer LINK_sliderarrow1; integer LINK_sliderbase2; integer LINK_sliderarrow2; integer LINK_sliderbase3; integer LINK_sliderarrow3; integer LINK_sliderbase4; integer LINK_sliderarrow4; integer LINK_sliderbase5; integer LINK_sliderarrow5; integer LINK_slider1text; integer LINK_slider2text; integer LINK_slider3text; integer LINK_slider4text; integer LINK_slider5text; string name; memoryLimitTest() { llSetMemoryLimit(memoryLimit); llScriptProfiler(PROFILE_SCRIPT_MEMORY); llScriptProfiler(PROFILE_NONE); // /* llSetText("Limited Memory " + (string)llGetMemoryLimit() + "\nUsed Memory " + (string)llGetUsedMemory() + "\nFree Memory " + (string)llGetFreeMemory(),<1,1,1>,1); // */ integer freeMemoryLeft = llGetFreeMemory(); float lowMemoryTrigger = 500; if (freeMemoryLeft < lowMemoryTrigger) { //llSay(0,"Running out of memory!"); llOwnerSay("Possible lag detected. Freeing up memory. Please wait one second..."); llResetScript(); } } getLinks() { integer total = llGetNumberOfPrims() + 1; string name; while ((total--) -1) { name = llGetLinkName(total); if (name == "SliderBase1") { LINK_sliderbase1 = total; } else if (name == "SliderArrow1") { LINK_sliderarrow1 = total; } else if (name == "SliderBase2") { LINK_sliderbase2 = total; } else if (name == "SliderArrow2") { LINK_sliderarrow2 = total; } else if (name == "SliderBase3") { LINK_sliderbase3 = total; } else if (name == "SliderArrow3") { LINK_sliderarrow3 = total; } else if (name == "SliderBase4") { LINK_sliderbase4 = total; } else if (name == "SliderArrow4") { LINK_sliderarrow4 = total; } else if (name == "SliderBase5") { LINK_sliderbase5 = total; } else if (name == "SliderArrow5") { LINK_sliderarrow5 = total; } else if (name == "Slider1Text") { LINK_slider1text = total; } else if (name == "Slider2Text") { LINK_slider2text = total; } else if (name == "Slider3Text") { LINK_slider3text = total; } else if (name == "Slider4Text") { LINK_slider4text = total; } else if (name == "Slider5Text") { LINK_slider5text = total; } } name = ""; } //this function is because i often ask for a local position vector llGetLinkLocalOffset(integer link) { return llList2Vector(llGetLinkPrimitiveParams(link, [PRIM_POS_LOCAL]), 0); } //we generate a params list with this function list moveSlider(integer link, vector pos, vector rr) { //This vector puts the slider in the middle if the mouse cursor went off the slider prim while sliding to avoid the -100 value from being send. //(May need to find a better solution, but works for now :/) // A better solution would be to remember the last postition and return to that if the mouse went off sliding and button released, like any program does. I may get around it. Possibly. vector midCrossPos = screenPos + (<0, 0.500 * screenScale.y, 0.50 * screenScale.z> - screenScale * 0.5 ) * (<0, 0, 1, 0> * screenRot); vector crossPos = screenPos + (<0, 0.500 * screenScale.y, rr.y * screenScale.z> - screenScale * 0.5 ) * (<0, 0, 1, 0> * screenRot); if (link == LINK_sliderbase1) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow1, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow1, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase2) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow2, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow2, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase3) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow3, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow3, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase4) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow4, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow4, PRIM_POS_LOCAL, midCrossPos ]; } } else if (link == LINK_sliderbase5) { if (rr != TOUCH_INVALID_TEXCOORD) { params += [ PRIM_LINK_TARGET, LINK_sliderarrow5, PRIM_POS_LOCAL, crossPos ]; } else { params += [ PRIM_LINK_TARGET, LINK_sliderarrow5, PRIM_POS_LOCAL, midCrossPos ]; } } return params; } default { on_rez(integer param) { llResetScript(); } state_entry() { getLinks(); memoryLimitTest(); } touch_start(integer total_number) { LINK_screen = llDetectedLinkNumber(0); hudPos = llGetLocalPos(); //scroll screen screenPos = llGetLinkLocalOffset(LINK_screen); screenScale = llList2Vector(llGetLinkPrimitiveParams(LINK_screen, [PRIM_SIZE]), 0); screenRot = llList2Rot(llGetLinkPrimitiveParams(LINK_screen, [PRIM_ROT_LOCAL]), 0); //memoryLimitTest(); } touch(integer num) { vector rrGlobalOffset = llDetectedTouchUV(0); float outcome = rrGlobalOffset.y * 100; if (LINK_screen == LINK_sliderbase1) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider1text, PRIM_TEXT, "Slider 1\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider1text, PRIM_TEXT, "Slider 1\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase2) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider2text, PRIM_TEXT, "Slider 2\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider2text, PRIM_TEXT, "Slider 2\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase3) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider3text, PRIM_TEXT, "Slider 3\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider3text, PRIM_TEXT, "Slider 3\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase4) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider4text, PRIM_TEXT, "Slider 4\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider4text, PRIM_TEXT, "Slider 4\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } else if (LINK_screen == LINK_sliderbase5) { if (outcome == -100) { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider5text, PRIM_TEXT, "Slider 5\n 50", <1.0, 1.0, 1.0>, TRUE ]); } else { llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_slider5text, PRIM_TEXT, "Slider 5\n" + (string)llRound(outcome), <1.0, 1.0, 1.0>, TRUE ]); } } //Global Position Vector llSetLinkPrimitiveParamsFast(0, [ PRIM_LINK_TARGET, LINK_screen, PRIM_TEXT, (string)rrGlobalOffset, <1.0, 1.0, 1.0>, 0.0 ] + moveSlider(LINK_screen, llDetectedTouchPos(0), rrGlobalOffset)); memoryLimitTest(); } touch_end(integer num) { //Value from 0.0 to 1.0 vector rrGlobalOffset = llDetectedTouchUV(0); float outcome = rrGlobalOffset.y * 100; if (LINK_screen == LINK_sliderbase1) { if (outcome == -100) { llSay(0,"Slider 1 said: 50"); return; } llSay(0,"Slider 1 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase2) { if (outcome == -100) { llSay(0,"Slider 2 said: 50"); return; } llSay(0,"Slider 2 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase2) { if (outcome == -100) { llSay(0,"Slider 2 said: 50"); return; } llSay(0,"Slider 2 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase3) { if (outcome == -100) { llSay(0,"Slider 3 said: 50"); return; } llSay(0,"Slider 3 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase4) { if (outcome == -100) { llSay(0,"Slider 4 said: 50"); return; } llSay(0,"Slider 4 said: " + (string)llRound(outcome)); } else if (LINK_screen == LINK_sliderbase5) { if (outcome == -100) { llSay(0,"Slider 5 said: 50"); return; } llSay(0,"Slider 5 said: " + (string)llRound(outcome)); } LINK_screen = LINK_THIS; } } Thank you! It would be very nice to receive it! Link to comment Share on other sites More sharing options...
CaithLynnSayes Posted July 31, 2021 Share Posted July 31, 2021 Assuming you have the same name inworld as here, item send... 1 Link to comment Share on other sites More sharing options...
Tattooshop Posted July 31, 2021 Author Share Posted July 31, 2021 17 hours ago, Quistess Alpha said: you can typecast other values into strings, and add the strings together with separators, then use either llCSV2list or llParseString2List to get the values back out. Thanks again and sorry for continuing to torment you! Well, for example, my HUD sends a message like this llRegionSay(10, "gloss: " + (string) gloss); how can I make the listener recognize which parameter to change? The examples in the wiki are of course very interesting, but how to apply them here? default { state_entry() { llListen(10, "", "", ""); } listen(integer channel, string name, key id, string message) { if (channel != 10) return; //??? } } Link to comment Share on other sites More sharing options...
Quistess Alpha Posted July 31, 2021 Share Posted July 31, 2021 52 minutes ago, Tattooshop said: default { state_entry() { llListen(10, "", "", ""); } listen(integer channel, string name, key id, string message) { if (channel != 10) return; //??? } } If you're only listening to channel 10, testing that the channel isn't 10 doesn't do anything for you. Link to comment Share on other sites More sharing options...
Xiija Posted August 2, 2021 Share Posted August 2, 2021 (edited) Quote how can I make the listener recognize which parameter to change? llRegionSay(10, "gloss: " + (string) gloss); in the listen event... string my_string = message; // "gloss: 123"; list my_list = llParseString2List(my_string,[":"],[] ); string command = llList2String(my_list,0); float amt = llList2Float( my_list,1); then do normal stuff like, ... if( command == "gloss") etc etc you could also use just a texture slider, with no moving prims... example: using a texture like ... you could then do something along these lines.... float uvMax = 1.0; float uvMin = 0.0; float txtrMax = -0.87; float txtrMin = 0.0; float touch_UV = 0.0; float myOffset; vector touchUV; integer face; float offsetter( float touch_UV ) { float OldRange = (uvMax - uvMin); float NewRange = (txtrMax - txtrMin); float NewValue = (((touch_UV - uvMin) * NewRange) / OldRange) + txtrMin; return NewValue; } default { state_entry() { } touch_start(integer total_number) { touchUV = llDetectedTouchST(0); myOffset = offsetter( (float)touchUV.x ); face = llDetectedTouchFace(0); llOffsetTexture( myOffset, 0.0, face); } } now, if you touch the face with this texture, the button on the slider will move to that point. sadly, i think the only way to get a drag slider would be to use controls, and arrow keys? , mebbe? I've made volume sliders that use buttons ( with touch start & touch end) to control text/texture sliders also Edited August 2, 2021 by Xiija 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted August 2, 2021 Share Posted August 2, 2021 2 hours ago, Xiija said: sadly, i think the only way to get a drag slider would be to use controls, There's nothing magical about drag sliders, you can litteraly just change touch_start to touch in your example and it will be a drag slider. Thanks for the cool idea! 1 Link to comment Share on other sites More sharing options...
Xiija Posted August 2, 2021 Share Posted August 2, 2021 @Quistess Alpha wow, tysm for the heads up on the touch event Link to comment Share on other sites More sharing options...
Tattooshop Posted August 2, 2021 Author Share Posted August 2, 2021 (edited) 7 hours ago, Xiija said: llRegionSay(10, "gloss: " + (string) gloss); in the listen event... string my_string = message; // "gloss: 123"; list my_list = llParseString2List(my_string,[":"],[] ); string command = llList2String(my_list,0); float amt = llList2Float( my_list,1); then do normal stuff like, ... if( command == "gloss") etc etc you could also use just a texture slider, with no moving prims... example: using a texture like ... you could then do something along these lines.... float uvMax = 1.0; float uvMin = 0.0; float txtrMax = -0.87; float txtrMin = 0.0; float touch_UV = 0.0; float myOffset; vector touchUV; integer face; float offsetter( float touch_UV ) { float OldRange = (uvMax - uvMin); float NewRange = (txtrMax - txtrMin); float NewValue = (((touch_UV - uvMin) * NewRange) / OldRange) + txtrMin; return NewValue; } default { state_entry() { } touch_start(integer total_number) { touchUV = llDetectedTouchST(0); myOffset = offsetter( (float)touchUV.x ); face = llDetectedTouchFace(0); llOffsetTexture( myOffset, 0.0, face); } } now, if you touch the face with this texture, the button on the slider will move to that point. sadly, i think the only way to get a drag slider would be to use controls, and arrow keys? , mebbe? I've made volume sliders that use buttons ( with touch start & touch end) to control text/texture sliders also Thanks a lot! I didn't even hope to finish this project, and I didn't even believe it right away*, but hey, it works! 👍 Special thanks for the texture slider! * Edit: when it started working Edited August 2, 2021 by Tattooshop Link to comment Share on other sites More sharing options...
Tattooshop Posted August 2, 2021 Author Share Posted August 2, 2021 6 hours ago, Xiija said: llRegionSay(10, "gloss: " + (string) gloss); in the listen event... string my_string = message; // "gloss: 123"; list my_list = llParseString2List(my_string,[":"],[] ); string command = llList2String(my_list,0); float amt = llList2Float( my_list,1); then do normal stuff like, ... if( command == "gloss") etc etc you could also use just a texture slider, with no moving prims... example: using a texture like ... you could then do something along these lines.... float uvMax = 1.0; float uvMin = 0.0; float txtrMax = -0.87; float txtrMin = 0.0; float touch_UV = 0.0; float myOffset; vector touchUV; integer face; float offsetter( float touch_UV ) { float OldRange = (uvMax - uvMin); float NewRange = (txtrMax - txtrMin); float NewValue = (((touch_UV - uvMin) * NewRange) / OldRange) + txtrMin; return NewValue; } default { state_entry() { } touch_start(integer total_number) { touchUV = llDetectedTouchST(0); myOffset = offsetter( (float)touchUV.x ); face = llDetectedTouchFace(0); llOffsetTexture( myOffset, 0.0, face); } } now, if you touch the face with this texture, the button on the slider will move to that point. sadly, i think the only way to get a drag slider would be to use controls, and arrow keys? , mebbe? I've made volume sliders that use buttons ( with touch start & touch end) to control text/texture sliders also What would you recommend on how to fix the problem with the sliders offset from the hud movement? 🖖 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