Alec Walsh Posted October 2, 2019 Share Posted October 2, 2019 (edited) Hello, I have been scripting in SL for many years, but tonight I came across an issue that I have never seen before, and one that is baffling me beyond belief. I figured I would try to reach out in here to find a solution. I have an external device that I bought, which I am trying to make a score card for. The object states "Alec Walsh got a hole in one!". I have listened, and captured that text through a listener, storing it in a variable called message. I even had the LSL say message to confirm that it has heard the message, (code below) which it has. I also check the name, which I am picking up when the user clicks reset on the hud I have built - and have confirmed that the name is accurate. Now, if it listens to the text from the other object, the user name is underlined, and linked to a profile, and when I compare it to the name I have in the string, it fails. However, if I copy that message text, then paste it outside of SL, copy it again, bring it back in, thus removing the profile link, the compare works, and the script works as expected. My question, is there a way for either a) use LSL to convert the message string to a true string with no links to a profile, or b) to compare the string to a true string, and have LSL recognize that they are equal. Problem is, I need the persons name from the text spoken by the object to know whose score I am keeping. Many Thanks for any help!! Debug and actual text sample // message is :"Alec Walsh got a hole in one!" // Actual_name is :Alec Walsh (Checked all spaces etc) llSay(0,Actual_name); // Check Name llSay(0,message); // Check message - confirm name is in message spaceIndex = llSubStringIndex(message, Actual_name); llSay(0,(string)spaceIndex); // SpaceIndex keeps coming back as -1 when listening to the object talk, but with a value when I paste the exact same text. if(spaceIndex != -1) // Fail - this should pass, but fails when the object gives the message, but if I paste the same message, it works. Edited October 2, 2019 by Alec Walsh Turn Notify me of replies on Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted October 2, 2019 Share Posted October 2, 2019 (edited) There's a special thing about what you're seeing and what there actually is. When you see text like this: That line of text is actually this: That long bunch of stuff is called a URI (not URL), which is a special pattern that your viewer can convert on-the-fly to a usable link that does something. (Opens a profile, in this case.) The exact name shown in chat depends on your viewer settings. For some people, it would only show a display name. To be more clear, these are the first 10 characters of that string that displays my name: string message = "secondlife:///app/agent/779e1d56-5500-4e22-940a-cd7b5adddbe0/about says hello!"; llOwnerSay(message); // "Wulfie Reanimator says hello!" string first10 = llGetSubString(message, 0, 9); llOwnerSay(first10); // "secondlife" If you know that the message always begins with a URI, you can easily get the key with llGetSubString, convert that to a username with llKey2Name (for example), and then replace the whole URI with the plain-text username. You can also do a pattern-search for "secondlife:///app/agent/" with llSubStringIndex if you don't know where exactly the URI will be. Edited October 2, 2019 by Wulfie Reanimator Link to comment Share on other sites More sharing options...
Alec Walsh Posted October 3, 2019 Author Share Posted October 3, 2019 That worked perfect!! Learn something new every day. Many thanks for the assist. 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