Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSetAlpha Question

Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 03:55
I have a (I Hope) simple question. I have a window tint script where I use the following code:
//Code Start
llSetLinkColor(linkNum, llList2Vector(gOutColor, index), faceWork);
llSetLinkTexture(linkNum, llList2String(gOutText, index), faceWork);
llSetLinkAlpha(linkNum, gMsgTint, faceWork);
//Code End

Where

gOutColor is a list that holds the original colors for each prim face
gOutText is a list that holds the original texture for each prim face
gMsgTint is a float defining the amount of Tint used

Now with the texture being the blank texture and color being white (<1.0, 1.0, 1.0>;) .. independent of the amount I set the alpha the color basically turns to a black .. with the proper alpha transparency, but black all the same. To actually get it back to the way it was I need to go into the prim and edit its color and transparency.

Why is this and can I do anything about it?

Thanks in advance!
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 04:46
I don't know, whether I understand your problem entirely... but I'll give it a try anyway :)

By saying «the blank texture» I assume, you're trying to apply a blank texture to the prim? (not just leaving the texture-variable empty).

Thus being assumed, what does the command look like?

The key for a 100% white, blank texture would be "5748decc-f629-461c-9a36-a35a221fe21f"

So you would have to enter this key into your list of textures... then it should actually work...
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 04:51
Haruki ...

That is the texture key I am using ... sorry for not being complete in my description. So the problem remains that even with setting this .. as soon as I use the llSetLinkAlpha the color of the prim goes black, again with the proper transparency as set by the funtion.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 04:58
I just tried to reproduce this, using a cube and applying color/texture/alpha to it...
which worked fine...?

So I guess, the problem is somewhere else in your script...

Can you post a little more than the snippet you posted?
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 05:07
Below is the full method used for setting the values on the prim ... the rest of the script is all about communications and management. The basic idea of the function is that you can chose to set a different texture/color when the window is set to full opaque (100% Alpha). In this test case the prim is set with the blank texture, white, and 75% transparency.

//Global Variables
//Data Lists
list gWindowLinkNum;
list gInFace;
list gInColor;
list gInText;
list gIn100Color;
list gIn100Text;
list gOutFace;
list gOutColor;
list gOutText;
list gOut100Color;
list gOut100Text;


integer call_windows()
{
integer i = 0;
integer x = 0;
integer quit = 0;
integer listLen = llGetListLength(gListPosit);
list indexList;
integer indexLen;
integer index;
integer linkNum;
integer faceWork;
string sText;
string message;

//Now call the windows
while (quit == 0 && i < listLen)
{
if (llList2String(gWindowOptions, i) == gWinSelected || gWinSelected == "All";)
{

//Need to Split out the List Positions Ids
indexList = llParseString2List(llList2String(gListPosit, i),["@"],[""]);
indexLen = llGetListLength(indexList);

for (x = 0; x < indexLen; x++)
{
index = llList2Integer(indexList, x);
linkNum = llList2Integer(gWindowLinkNum, index);

//Check for a negative Link ID .. this means that it is an unlinked window
if (linkNum < 0)
{
//Send ... WinControlID, SideMod, Tint .. The window has stored its texture/color values
message = CTRL_ID + "@" + gSideModifier + "@" + (string)gMsgTint;
llRegionSay(linkNum, message);
}
else
{

//Check for each side
if (gSideModifier != "Inside";)
{
faceWork = llList2Integer(gOutFace, index);

//Now depending on the Tint % we set one color or other
if (gMsgTint == 1)
{
//Only do this if we really have a texture ... a none will be here if not
sText = llList2String(gOut100Text, index);
if (sText != "non";)
{
llSetLinkColor(linkNum, llList2Vector(gOut100Color, index), faceWork);
llSetLinkTexture(linkNum, llList2String(gOut100Text, index), faceWork);
}
}
else
{
llSetLinkColor(linkNum, llList2Vector(gOutColor, index), faceWork);
llSetLinkTexture(linkNum, llList2String(gOutText, index), faceWork);
}
llSetLinkAlpha(linkNum, gMsgTint, faceWork);
}
if (gSideModifier != "Outside";)
{
faceWork = llList2Integer(gInFace, index);

//Now depending on the Tint % we set one color or other
if (gMsgTint == 1)
{
//Only do this if we really have a texture ... a none will be here if not
sText = llList2String(gOut100Text, index);
if (sText != "non";)
{
llSetLinkColor(linkNum, llList2Vector(gOut100Color, index), faceWork);
llSetLinkTexture(linkNum, llList2String(gOut100Text, index), faceWork);
}
}
else
{
llSetLinkColor(linkNum, llList2Vector(gInColor, index), faceWork);
llSetLinkTexture(linkNum, llList2String(gInText, index), faceWork);
}
llSetLinkAlpha(linkNum, gMsgTint, faceWork);
}
}
}
if (gWinSelected != "All";)
{
quit = 1;
}
}
i++;
}
return 0;
}//End call_windows
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 05:17
First - please use
CODE
..
-Tags when pasting scripts... :)

Could this maybe cause the problem?

CODE


//Only do this if we really have a texture ... a none will be here if not

if (sText != "non")
{
llSetLinkColor(linkNum, llList2Vector(gOut100Color, index), faceWork);
llSetLinkTexture(linkNum, llList2String(gOut100Text, index), faceWork);
}


In your remark, you say that there will be «a none» if theres no texture.
But then you're checking against «non» (sText != "non";)...

If this isn't it, I'd love to see the values of the lists containing the colors/textures...
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 05:20
Sorry about the tags <smiles sheepishly>

Yes I saw that too .. but that code never gets executed. The color lists are all <1.0, 1.0, 1.0> and the texture lists are all 5748decc-f629-461c-9a36-a35a221fe21f. First thing I checked was those to make sure.
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 05:32
just tried something ... i commented out the sections that set the color and texture and the problem goes away ... not quite sure what that means but will look a bit further in. Will cause a problem for what i want to do though.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 05:39
hmmm - I'm almost sure, that there's a bug in those lists somewhere...

please post the code where you setting them... :)
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 05:56
Hmmm .. must be how the value got into the list? I checked the following:

<php>
vector vec;

llSay (0, llList2String(gOutColor, index));
vec = llList2Vector(gOutColor, index);
llSay (0, (string)vec);
</php>

And the results are:
<1.00000, 1.00000, 1.00000>
<0.00000, 0.00000, 0.00000>

....
the values come to the controller script from a script in a prim. They are passed as part of a string :value@value@value ... . Then I use llParseString2List to break them out and then assign the individual lists with llList2List.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 06:04
Think we're getting closer :)

So I guess it must be something with the typecast when you split up the lists...

You might post the part, where you split up the string that you receive...
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 06:14
Found it .. though do not understand. So ...

<php>
string str;
vector vec;
vector vec2;

str = llList2String(dataList, 2);
vec = (vector)str;
vec = llList2Vector(dataList,2);

</php>

When examined the values of these are:
str = <1.00000, 1.00000, 1.00000>
vec = <1.00000, 1.00000, 1.00000>
vec2 = <0.00000, 0.00000, 0.00000>

Doesn't make much sense to me but it seems that if the list was made from string values, unless I pass it to a string before trying to convert to a vector it messes up.

Btw the code that parses the string is simply:

<php>
dataList = llParseString2List(message, ["@"],[""]);
</php>

And the code that created is:

<php>
dataMessage = WINDOW_NAME + "@" + (string)inFace;
dataMessage = (dataMessage="";) + dataMessage + "@" + (string)llGetColor(inFace);
dataMessage = (dataMessage="";) + dataMessage + "@" + llGetTexture(inFace);
dataMessage = (dataMessage="";) + dataMessage + "@" + (string)IN_100_COLOR;
dataMessage = (dataMessage="";) + dataMessage + "@" + IN_100_TEXT;
dataMessage = (dataMessage="";) + dataMessage + "@" + (string)outFace;
dataMessage = (dataMessage="";) + dataMessage + "@" + (string)llGetColor(outFace);
dataMessage = (dataMessage="";) + dataMessage + "@" + llGetTexture(outFace);
dataMessage = (dataMessage="";) + dataMessage + "@" + (string)OUT_100_COLOR;
dataMessage = (dataMessage="";) + dataMessage + "@" + OUT_100_TEXT;
</php>
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 06:19
Yes this is a bug in the list-functions. From the wiki:

Q: Have the old problems concerning the odd behavior of llList2Vector and llList2Rot when requesting a TYPE_STRING element from the list been fixed yet?
A: No. If a list element is a string containing text that would otherwise be directly typecast to a vector or rotation, It will not be converted. The resulting vector or rotation will be ZERO_VECTOR or ZERO_ROTATION respectively. This is a bug. To get around it, use llList2String to retrieve elements from your list, then cast them to vectors or rotations as needed: (vector)llList2String(positions,2);

So in your case you would use:

vec = (vector)llList2String(dataList, 2);

which should produce the needed result...
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
04-17-2008 06:22
yep .. works like a charm ... guess I should have looked into the Wiki for known bugs.

Thanks for helping me work through this Haruki. Have a great day!
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-17-2008 06:45
My pleasure...

I usually use this wiki, instead of the official one - I find it's more useful and faster:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=HomePage