|
Marianne McCann
Feted Inner Child
Join date: 23 Feb 2006
Posts: 7,145
|
05-06-2008 08:54
So I'm biting off more than I can chew, and I want to make a device that will convert ROT-13 http://www.rot13.com/http://en.wikipedia.org/wiki/ROT13Say, for example, owner types "fvyyl" in chat on a secure channel. the worn object hears it, and returns "silly." Is such an action even possible? Anyone have any idea of how this might work? It seems like it might work similar to Babbler, or it could have an array within the script -- I dunno. Mari
_____________________
  "There's nothing objectionable nor illegal in having a child-like avatar in itself and we must assume innocence until proof of the contrary." - Lewis PR Linden "If you find children offensive, you're gonna have trouble in this world  " - Prospero Linden
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-06-2008 09:15
Sure but since LSL doesn't really grok ASCII, you'll need to a method to convert every possible character into a number. From there, just call it on each character in the string, ROT-13 it then add it to the translated string.
/me is at work now and they don't allow me to run SL here. Dorks. If somebody doesn't supply some source code, feel free to send me a poke and I'll fix you up.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Imnotgoing Sideways
Can't outlaw cute! =^-^=
Join date: 17 Nov 2007
Posts: 4,694
|
05-06-2008 09:19
That sounds like something fun to play with... I haven't looked hard enough to find CHR() or ASCII() type functions in LSL. But, any way to turn the string characters numeric would work, then run a loop that has a simple formula to shift the numbers. Finally convert the number list back to a string and win. (^_^) Maybe take a look at how these functions work: http://wiki.secondlife.com/wiki/LlBase64ToStringhttp://wiki.secondlife.com/wiki/LlStringToBase64http://wiki.secondlife.com/wiki/LlIntegerToBase64http://wiki.secondlife.com/wiki/LlBase64ToIntegerI've done this kind of stuff before in VB6. Someday, I just might memorize the ASCII chart I keep referring back to it so much. (=_=)y
|
|
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
|
05-06-2008 09:23
Very possible. Gimme a sec to find a link for ya, there's an easily changed script on the LSL wiki that could do exactly what you want.
_____________________
Tutorials for Sculpties using Blender! Http://www.youtube.com/user/BlenderSL
|
|
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
|
05-06-2008 09:25
http://lslwiki.net/lslwiki/wakka.php?wakka=ExampleText2LeetJust change the 'leet' values to the values used in Rot-13, and it should be good to go. ETA:: This is only the partial script, the bit that does the converting, not an entire script. If you wanna go from ROT-13 to normal, then you'd prolly want the list called 'Text' to be the Rot-13 values, and the list called 'Leet' to be the normal values.
_____________________
Tutorials for Sculpties using Blender! Http://www.youtube.com/user/BlenderSL
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-06-2008 09:52
Easy enough. This will convert only simple ASCII alphabetic characters, and preserve case. Punctuation, digits, special characters, etc. will be left unchanged. (Note: hasn't been compiled yet. May need minor syntax fixes.) string ALPHA_LOWER = "abcdefghijklmnopqrstuvwxyz"; string ALPHA_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string rot13(string input) { integer len = llStringLength(input);
string output = ""; integer i; for (i = 0; i < len; ++i) { string char = rotChar13(llGetSubString(input, i, i)); output = (output="")+output+char; }
return output; }
string rotChar13(string inputChar) { integer index;
index = llSubStringIndex(ALPHA_LOWER, inputChar); if (index >= 0) { index = (index+13)%26; return llGetSubString(ALPHA_LOWER, index, index); }
index = llSubStringIndex(ALPHA_UPPER, inputChar); if (index >= 0) { index = (index+13)%26; return llGetSubString(ALPHA_UPPER, index, index); }
return inputChar; }
|
|
Marianne McCann
Feted Inner Child
Join date: 23 Feb 2006
Posts: 7,145
|
05-06-2008 16:58
Thanks everyone for pointing me in the right direction, both here and inworld. I did't tink it would be possible. 
_____________________
  "There's nothing objectionable nor illegal in having a child-like avatar in itself and we must assume innocence until proof of the contrary." - Lewis PR Linden "If you find children offensive, you're gonna have trouble in this world  " - Prospero Linden
|