Patrick Playfair Posted August 8, 2017 Share Posted August 8, 2017 (edited) Haven't done a lot with strings, but am trying to convert text into a new "language". In the sample snippet below, I am reading the first 3 characters of string "said", and want to say the first 3 characters in English (which works fine), then say them in the alien language. But is only says the 1st character of the alien language 3 times. I am using llGetSubSring as the index, but it is not working as I expected. Any ideas or tips on how to accomplish this? list Alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","!","@","#","$","%","&"]; list AlienAlphabet; string said = "A crazy fox jumped over the moon"; default { state_entry() { } touch_start(integer total_number) { list AlienAlphabet = llListRandomize(Alphabet, 1); llOwnerSay("What was said -" + said); llOwnerSay("1st character of what was said " + llGetSubString(said, 0, 0)); llOwnerSay("2nd character of what was said " + llGetSubString(said, 1, 1)); llOwnerSay("3rd character of what was said " + llGetSubString(said, 2, 2)); llOwnerSay("Alien alphabet is " +(string)AlienAlphabet); llOwnerSay("1st character in Alien language " + llList2String(AlienAlphabet, (integer)llGetSubString(said, 0, 0))); llOwnerSay("2nd character in Alien language " + llList2String(AlienAlphabet, (integer)llGetSubString(said, 1, 1))); llOwnerSay("3rd character in Alien language " + llList2String(AlienAlphabet, (integer)llGetSubString(said, 2, 2))); } } Edited August 8, 2017 by Patrick Playfair Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 8, 2017 Share Posted August 8, 2017 (edited) Your variable, said, is a string, so llGetSubString(said,x,x) will also be a string, no matter what x is. Converting the character that you get from llGetSubString to an integer will always give you (integer)llGetSubString(said, x, x))) = -1 So, what you really want to do is find the index of the character from said in Alphabet and then find the same character in AlienAlphabet . integer index = llListFindList(Alphabet,[llGetSubString(said,0,0)]); llOwnerSay("1st character in Alien Language = " + llList2String(AlienAlphabet,index)); Edited August 8, 2017 by Rolig Loon 1 Link to comment Share on other sites More sharing options...
Patrick Playfair Posted August 9, 2017 Author Share Posted August 9, 2017 Thank you, that is exactly what I was looking for, and tried it once but kept failing. I had forgotten the square brackets in llGetSubString I'm sure I will need more assistance before I am through with this one. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted August 9, 2017 Share Posted August 9, 2017 You don't need square brackets in llGetSubString. I think you mean you had forgotten to put them round llGetSubString in llListFindList(lAlienAlphabet,[llGetSubString(sample, n, n)]). That's because llListFindList takes two lists as its arguments, and the square brackets cast the string returned by llGetSubString into a list. You probably know this, but I'm pointing it out for the benefit of people in the future who may be searching for ways of constructing their own alien alphabet translators. Link to comment Share on other sites More sharing options...
Patrick Playfair Posted August 10, 2017 Author Share Posted August 10, 2017 Thanks for your help. The rest of the script went a lot easier than I expected. I incorporated it into our Staff HUD. Now we speak Alien and only other AlienStaff members get the interpretation. 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