|
Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
|
11-17-2006 17:13
Hello. I have this little script I made a while ago.: string set; default { attach(key id) { llResetScript(); } state_entry() { llListen(110,"","",""); }
listen(integer channel, string name, key id, string message) { if(llGetOwnerKey(id) == llGetOwner()) { if(llToLower(llGetSubString(message,0,1)) == "ht") { set = llGetSubString(message,3,-1); llSetText(set,<1,1,1>,1); } } } }
Is there a way I can make it set the text but not the color and color but not text? As in separate actions? Thanks in advance.
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
11-17-2006 17:45
Yes. There are many ways it can be done, but I'll just give the first idea I have. Add an if else[/b[ that checks to see if the first two characters are 'hc' (HoverColor). You can then chat "/110 hc 0,0,1" for blue text, or "/110 ht title here" to replace the title text.
The magic is in how to get a vector out of the comma-separated RGB values you've chatted. So, take your sub-string (set) and do a llCSV2List() with it. Once you've done that, you can grab the values from the list for each of the 3 vector positions like so:
else if(llToLower(llGetSubString(message,0,1)) == "hc") { string sub = llDeleteSubString(message,0,1); list values = llCSV2List(sub); color.x = llList2Float(values, 0); color.y = llList2Float(values, 1); color.z = llList2Float(values, 2); llSetText(set, color, 1); }
Note: You'll need to make your set and color variables global variables, so the script will remember them between setting text or setting the color.
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
11-18-2006 01:19
I'd do something like DoteDote's approach.
You can make the vector in other ways though, for example once you've got your substring of the numbers (sub in the script there) you could do:
sub="<"+sub+">"; vector colour=(vector)sub;
or similar. Swings and roundabouts in a short one like this, but if you're doing it in a big script you might find this saves a small amount of memory and so is a little better. You might not though, not tested it, but it's worth mentioning as an option for typecasting directly.
|