Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Something intreguingly interesting!

Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
02-01-2004 18:12
I remember reading an old thread about a cambrage university study on how the human mind reads. I dug it up in the forums, here's the link.

Kohne Kato gave me the idea of scripting up a little doo-dad that automaticly scrambled each word within listen range, but only the characters between the first and last letters of each word.

Here it is :D :

CODE

list string2CharList(string str)
{
integer i;
integer len = llStringLength(str);
list ret;

for(i = 0; i < len; i++)
{
ret += llGetSubString(str,i,i);
}
return ret;
}

string charList2String(list chars)
{
return (string)chars;
}

string scrambleWordsIn(string str)
{
list words = llParseString2List(str,[" "],[]);

integer i;
integer len = llGetListLength(words);

str = "";

for(i = 0; i < len; i++)
{
llSetText((string)i,<0,1,0>,1.0);

string word = llList2String(words,i);
integer len = llStringLength(word);
if(len > 3)
{
string toScramble = llGetSubString(word,1,len - 2);
word = llDeleteSubString(word,1,len - 2);

toScramble = charList2String(llListRandomize(string2CharList(toScramble),1));

word = llInsertString(word,1,toScramble);

}
str += word + " ";
}
return str;
}


integer active = TRUE;

say(string message)
{
llSay(0,message);
}
default
{
state_entry()
{
llListen(0,"",NULL_KEY,"");
}
listen(integer c, string n, key id, string m)
{
if(active) say(scrambleWordsIn(m));
}

touch_start(integer total_number)
{
if(active)
{
say("Scrambler off.");
active = FALSE;
}
else
{
say("Scrambler on.");
active = TRUE;
}
}
}


Enjoy! :)

==Chris

PS. It can be a little slow depending on the length of the said text, how many spaces in the said text, and how many characters per word are in the said text. Blame it on the string2CharList() function :rolleyes:
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
02-02-2004 06:20
Being the Slashdot junkie I am, I also read this article.

There was also a follow-up article written which clarified this phenomenon a bit. It basically said that completely scrambling the inside letters of words doesn't always work, but transposing pairs of inside letters does. Just an FYI in case you want to modify the script to transpose letters rather than completely scramble. :-)
_____________________
Apotheus Silverman
Shop SL on the web - SLExchange.com

Visit Abbotts Aerodrome for gobs of flying fun.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
02-06-2004 10:17
Ah, simple :)

Just change the llListRandomize()'s second argument to 2 instead of 1.
Flip Uba
Registered User
Join date: 21 Aug 2006
Posts: 0
call me stupid
08-23-2007 11:24
i would really like to see this in action but im gettin syntax error right off the bat with



the most i know about scripting is cntrl+c and then butcher it till i break it so any help getting this code to work would be greaty apreachiated. plus does it go in an object on the ground or do i wear the object?