Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

RGB Color Change via Chat?

Rena Kuhn
Registered User
Join date: 25 Jun 2007
Posts: 13
04-22-2008 17:56
Greetings fellow scripters.

I has a simple request of your mighty combined knowledge.

I'm looking for a way to make a color script in which it would listen on a channel for the RGB color vector (such as <1.0, 0.5, 0.1>, etc.) via chat and color the prim accordingly.

I'm trying to work a way for users of my products to be able to easily recolor the item in any color freely while still keeping the permissions no-mod.

Any assisstance or advice would be greatly appreciated. :3
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-22-2008 20:55
Simple enough. Something like:

CODE

integer CHANNEL = 17;

default
{
state_entry()
{
llListen(CHANNEL, "", llGetOwner(), "");
}

changed(integer changes)
{
if (changes & CHANGED_OWNER)
{
llResetScript();
}
}

listen(integer channel, string name, key id, string message)
{
if (llGetOwnerKey(id) != llGetOwner())
{
return;
}

llSetColor((vector)message, ALL_SIDES);
}
}


http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetColor
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llListen
Rena Kuhn
Registered User
Join date: 25 Jun 2007
Posts: 13
04-22-2008 21:40
From: Hewee Zetkin
Simple enough. Something like:

CODE

integer CHANNEL = 17;

default
{
state_entry()
{
llListen(CHANNEL, "", llGetOwner(), "");
}

changed(integer changes)
{
if (changes & CHANGED_OWNER)
{
llResetScript();
}
}

listen(integer channel, string name, key id, string message)
{
if (llGetOwnerKey(id) != llGetOwner())
{
return;
}

llSetColor((vector)message, ALL_SIDES);
}
}


http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetColor
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llListen


oh awesome. I see what I was missing. I needed (vector)message to set the chat message to the rgb.

thanks. :3
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-22-2008 22:03
From: Rena Kuhn
oh awesome. I see what I was missing. I needed (vector)message to set the chat message to the rgb.

thanks. :3


Yes, that's called typecasting. message in the case of the listen event is a string variable, but if that string is a vector, you can cast it to a vector, then use it as such. Read the wiki section on typecasting, it covers alot of 'need to know' info concerning variables.