Kipz Arado Posted August 5, 2011 Share Posted August 5, 2011 Soo, Even though I'm a beginner scripter, and have been "dipping" into it for years now. I have this "perfectionist" side of me, that refuses to do anything half ass. With that being said, this is kind of my downfall when it comes to doing scripts and learning, considering the fact that I don't know what I'm doing half the time. Anyways, with all that being said, I'm still helping my friend script objects he is building on all the land he bought about a week ago.In continuation to the Home Controller I am making him in reguards to his doors, and windows, I wanted to make an appealing GUI via photoshop instead of making tons of buttons on a wall for him to click on. I could always make invisible prims and place them over my photoshoped image with buttons on the texture. However, isn't there a llDetectedTouchFace or similiar function that divides the prim into numbered "sections", when you can click directly on the prim? My question is, how would one go about making the script detect a range of sections which would technically be one button when you look at the texture.Once again, I apologize for the paragraph and "Wall of Text". Thank you! :D :D Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 5, 2011 Share Posted August 5, 2011 The LSL wiki is your friend. Take a look at each of the llDetectedTouch* functions, because they offer you different options, depending of whether you want to know which prim face you touched(llDetectedTouchFace), where you touched it in region coordinates (llDetectedTouchPos), or local face coordinates (llDetectedTouchST), or coordinates relative to the texture on the face (llDetectedTouchUV), or maybe what a unit vector perpendicular to the face is (llDetectedTouchNormal), or a vector tanget (binormal) to the face is (llDetectedTouchBinormal). Link to comment Share on other sites More sharing options...
Innula Zenovka Posted August 5, 2011 Share Posted August 5, 2011 The function you probably need is llDetectedTouchUV. How you actually use it depends, of course, on how you've made the texture, but essentially it's a matter of reading the x and y coodinates of where you've touched it, and then having the script figure out where that is on your grid. Link to comment Share on other sites More sharing options...
Kipz Arado Posted August 6, 2011 Author Share Posted August 6, 2011 Thank you both for the fast and helpful replies. Like I said, I come and go with my scripting habits and learning process. Half of my question was pretty much which llDetect function I would use, which was answered, Thank you . I've known how to do the: touch_start(integer UV_detected) { integer i = 0; for(; i<UV_detected; ++i) llWhisper(0, "UV clicked: " + (string)llDetectedTouchUV(i)); } That would be amazing if my button was the side of that VERY VERY small point in which i've clicked on. However, that is not the case with my buttons, and my question was, could anyone point me in the right direction on how to make a parameter type thing, such as a big sqaure type "radius" or "area" in which I if any point clicked in that area/radius, it clicks on the "button" painted on my texture? Would it be something along the lines of touch_start(integer total_number) { vector UV = llDetectedTouchUV(0); float U = UV.x; float V = UV.y; if(float UV.x = 2 - 4 & UV.y = 1-3) { click on button } } And another thing with my if statement is i dont know the correction operation for "through?" would i have to use greater than less thans? I am just wondering If i am approaching this the right way, and i apologize if I'm confusing . Thank you so much again! Link to comment Share on other sites More sharing options...
Void Singer Posted August 6, 2011 Share Posted August 6, 2011 the basic formula for aligned rectangular buttons is TexturePos = llDetectedTouchST( touch_number ); TexturePos.x > leftBound && TexturePos.x < rightBound && TexturePos.y > lowerBound && TexturePos.y < upperBound or TexturePos = (TexturePos - buttonCenter) TexturePos.x < halfButtonWidth && TexturePos.y < halfButtonHeight for circular buttons it's (TextturePos - buttonCenter) > buttonRadius all button bounds, centers, widths, and heights, are given as a percentage of the total button size, with 0 being the bottom left corner, and 1.0 being top right of the texture, regardless of the prim shape or mapping mode. Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 6, 2011 Share Posted August 6, 2011 default{ touch_start(integer num) { vector Spot = llDetectedTouchUV(0); if((Spot.x > 0.0) && (Spot.x < 0.5)&&(Spot.y > 0.0)&&(Spot.y < 0.5)) { llOwnerSay("You have just clicked in the lower left quadrant of " + (string)llDetectedTouchFace(0)); } else { float X = Spot.x - 0.5; float Y = Spot.y - 0.5; if ( (llSqrt(X*X + Y*Y)) <= 0.2) { llOwnerSay("You have just clicked inside a 0.2 radius circle at the center of " + (string)llDetectedTouchFace(0)); } } }} Link to comment Share on other sites More sharing options...
Kipz Arado Posted August 6, 2011 Author Share Posted August 6, 2011 I want to start out by saying thank you to everyone for taking the time to respond to my question and help me with this situation. Like I've said before, I could have been done with this project hours ago if I would have just put invisible cylinders over my textuer and used link messages. However, I am looking to do the best job that I can on all projects that I do. I'm sorry if I ask anything incredibly stupid or say something that does't make a lot of sense. I've understood exactly what I have to do, i guess the only problem I have is writing the "formulas" and just making sure the code itself is correct. That script you posted Rolig has been exactly what I was getting at, with you click within a certain area, and It lets me know what area I've clicked. Once again, the only problem I seem to have is with these formulas. Such as why float X = Spot.x - 0.5; float Y = Spot.y - 0.5; if ( (llSqrt(X*X + Y*Y)) <= 0.2) is the center of the face. My buttons are round, so I guess the easiest way for me to go about doing this would be get a simple llDetectTouchUV script on the wiki that spits on where i've clicked. Find the coordinates for the center of button 1, then change the spot.x, spot.y and radius to the size of the button painted on the texture? Or is that Still wrong? I'm sorry if you have to hold my hand through this, my brain is just being melted and I'm trying my best. lol Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 6, 2011 Share Posted August 6, 2011 Because <0.5, 0.5> is the center of the face, so X = Spot.x -0.5 and Y = Spot.y - 0.5 puts the center right there.... an offset of 0.5 in each. And a circle is described by the set of points that lie on sqrt (x*x + y*y). sqrt (x*x + y*y) = 0.2 would be a circle of radius 0.2 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