Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Keys? Transparency/texture change help

Neglect Few
Registered User
Join date: 31 May 2004
Posts: 5
05-25-2006 15:19
I'm trying to make it so that when object is clicked upon, Dialog opens which allows to go to two more dialogs. From there one changes the color of one texture of a multiprem item, one changes the transparency (you can't do 100% transparent, so it needs to change texture, right?)

I have this so far, which I got done using the help of someone in game.

It tells me there's a syntax error at the " listen(1003... " (the cursor goes right in front of the 1003)

Help would be greatly appreciated.

From: someone


default
{
state_entry()

{
llListen(1003, "", NULL_KEY, "";);
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{
llDialog(llGetOwner(), "This chats so you can hear it.", ["Transparency" , "Color"], 1003);

}
listen(1003, "Transparency", llGetOwner(), "Transparency";);
{ llDialog(llGetOwner(), "This chats so you can hear it.", ["Transparent (Visor off)", "Translucent" , "Opaque"], 1003);

}

}

Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
events
05-25-2006 16:13
You can't put stuff in the events parameters like you did.. It needs to know what you plan on sending it.

The code is a bit tangly in other places as well, and yes you can go to 100% transparency in scripts.

CODE

integer listener; //Hold the listener.


default
{
state_entry()
{


}

touch_start(integer total_number)
{
llSetTimerEvent(120);//This is going to remove the listener after 2 minutes. In case they clicked and wandered off.
llListenRemove(listener); //Removes the listener so you don't wind up with a ton of them.
listener = llListen(1003, "", NULL_KEY, "");//moved to touch so listener isn't on all the time causing lag.


// This will give the owner the dialog no matter who clicks it.. How very annoying... llDialog(llGetOwner(), "This chats so you can hear it.", ["Transparency" , "Color"], 1003);


//The following line will only get the first person to touch. If you want to use this in a heavily trafficed area you will need a for loop to iterate through the detected keys.
llDialog(llDetectedKey(0), "This chats so you can hear it.", ["Transparency" , "Color"], 1003);


}
listen( integer channel, string name, key id, string message )
{

if(message == "Transparency")
{
llDialog(id, "Please select a visor setting.", ["Off", "Translucent" , "On"], 1003);

}
else if (message == "On")
{
//Turn the visor on.
//llSetLinkAlpha(); look this up on the wikipedia link below
}
else if(message == "Off")
{
//Turn the visor on.
//llSetLinkAlpha(); look this up on the wikipedia link below
}
else if(message == "Translucent")
{
}
else
{
llInstantMessage(id,message + " is an unknown command.")
}

}
timer()
{
llSetTimerEvent(0);//turns the timer off so it's not going on forever.
llListenRemove(listener); //Removes the listener so it's not running on and on with noone even around to listen to.
}

}


Url for wikipedia for llSetLinkAlpha = http://secondlife.com/badgeo/wakka.php?wakka=llSetLinkAlpha

WARNING UNTESTED SCRIPT!! I wrote it off the top of my head with a few peeks to wiki. If you get weird errors and can't figure them out send me an IM in world and I'll try to come help you figure it out.
Neglect Few
Registered User
Join date: 31 May 2004
Posts: 5
05-25-2006 18:35
Thanks a ton, trying this now. :)
Neglect Few
Registered User
Join date: 31 May 2004
Posts: 5
05-26-2006 11:49
Thanks a ton, trying this now. :)

Ok, I got it to pretty much work, but there's one problem.

Is there a certain number of functions you can have under something like "listen" ?

I have it set so that it makes 12 buttons, each of which set 9 prims a certain color. Theres one more prim that I would like to be seperate, so I made another set of 12 buttons. However, at a certain point, when I try to save, it says there's an error with the color <x,x,x>

Do you know what is causing this? There are 12 "else if" or "if" that make 9 prims a color, there are 3 that make that sole prim transparent,translucent, or opaque, and then when I try and make 12 more (of the same colors, but only editing the sole prim) there is an error in the script. "Syntax error"

Any ideas?

I appreciate the help a lot!
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
05-26-2006 13:32
You CAN do 100% transparent through the API. It's onlythroug the GUI that you can't.
Neglect Few
Registered User
Join date: 31 May 2004
Posts: 5
05-26-2006 13:52
Yeah, I got that, but is there a certain number of functions that can be done under a command/thing like "listen" ?
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
05-26-2006 13:58
From: Neglect Few
Yeah, I got that, but is there a certain number of functions that can be done under a command/thing like "listen" ?

Not that I know of.

Can you be more concrete about "there's an error"? What's the actual text of the error?
Neglect Few
Registered User
Join date: 31 May 2004
Posts: 5
05-26-2006 14:16
I posted about it above your first reply.

It's a syntax error.


Here's the problem part of the script:
It works fine until, when I try to save, it g ives me a syntax error at the BLUE part. It puts the cursor right after the < when defining the lllinksetcolor for when "blue" is heard
From: someone

listen( integer channel, string name, key id, string message )
{

if(message == "Visor";)
{
llDialog(id, "Please select a visor setting.", ["Off", "Translucent" , "On" , " Color "], 1003);

}
else if (message == "On";)
{
llSetLinkAlpha(2, 1, ALL_SIDES);
//Turn the visor on.
//llSetLinkAlpha(); look this up on the wikipedia link below
}
else if(message == "Off";)
{
llSetLinkAlpha(2, 0, ALL_SIDES);
//Turn the visor on.
//llSetLinkAlpha(); look this up on the wikipedia link below
}
else if(message == "Translucent";)
{
llSetLinkAlpha(2, .5, ALL_SIDES);
}
else if(message == "Shell";)
{
llDialog(id, "Please select a shell color.", [ "Au" , "Ag" , "GunMetal" , "Blanche" , "Night" , "Rose" , "Navy" , "Royal" , "Spring" , "Sun" , "Yamaha" , "Alert" ], 1003);
}
else if(message == " Color ";)
{
llDialog(id, "Please select a visor color.", [ "Gold" , "Silver" , "Gray" , "White" , "Black" , "Pink" , "NavyBlue" , "Violet" , "Green" , "Yellow" , "Blue" , "Red" ], 1003);
}
else if(message == "Alert";)
{
llSetLinkColor(1, <1,0,0> , ALL_SIDES);
llSetLinkColor(3, <1,0,0> , ALL_SIDES);
llSetLinkColor(4, <1,0,0> , ALL_SIDES);
llSetLinkColor(5, <1,0,0> , ALL_SIDES);
llSetLinkColor(6, <1,0,0> , ALL_SIDES);
llSetLinkColor(7, <1,0,0> , ALL_SIDES);
llSetLinkColor(8, <1,0,0> , ALL_SIDES);
llSetLinkColor(9, <1,0,0> , ALL_SIDES);
llSetLinkColor(10, <1,0,0> , ALL_SIDES);
}
else if(message == "Rose";)
{
llSetLinkColor(1, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(3, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(4, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(5, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(6, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(7, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(8, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(9, <0.592157,0.023529,0.337255> , ALL_SIDES);
llSetLinkColor(10, <0.592157,0.023529,0.337255> , ALL_SIDES);
}
else if(message == "Navy";)
{
llSetLinkColor(1, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(3, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(4, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(5, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(6, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(7, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(8, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(9, <0.145098,0.192157,0.313725> , ALL_SIDES);
llSetLinkColor(10, <0.145098,0.192157,0.313725> , ALL_SIDES);
}
else if(message == "Royal";)
{
llSetLinkColor(1, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(3, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(4, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(5, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(6, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(7, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(8, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(9, <0.290196,0.176471,0.290196> , ALL_SIDES);
llSetLinkColor(10, <0.290196,0.176471,0.290196> , ALL_SIDES);
}
else if(message == "Yamaha";)
{
llSetLinkColor(1, <0,0,1> , ALL_SIDES);
llSetLinkColor(3, <0,0,1> , ALL_SIDES);
llSetLinkColor(4, <0,0,1> , ALL_SIDES);
llSetLinkColor(5, <0,0,1> , ALL_SIDES);
llSetLinkColor(6, <0,0,1> , ALL_SIDES);
llSetLinkColor(7, <0,0,1> , ALL_SIDES);
llSetLinkColor(8, <0,0,1> , ALL_SIDES);
llSetLinkColor(9, <0,0,1> , ALL_SIDES);
llSetLinkColor(10, <0,0,1> , ALL_SIDES);
}

else if(message == "Au";)
{
llSetLinkColor(1, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(3, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(4, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(5, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(6, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(7, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(8, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(9, <0.796078,0.690196,0.337255> , ALL_SIDES);
llSetLinkColor(10, <0.796078,0.690196,0.337255> , ALL_SIDES);
}
else if(message == "GunMetal";)
{
llSetLinkColor(1, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(3, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(4, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(5, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(6, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(7, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(8, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(9, <0.156863,0.156863,0.156863> , ALL_SIDES);
llSetLinkColor(10, <0.156863,0.156863,0.156863> , ALL_SIDES);
}
else if(message == "Ag";)
{
llSetLinkColor(1, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(3, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(4, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(5, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(6, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(7, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(8, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(9, <0.256863,0.256863,0.256863> , ALL_SIDES);
llSetLinkColor(10, <0.256863,0.256863,0.256863> , ALL_SIDES);
}
else if(message == "Blanche";)
{
llSetLinkColor(1, <1,1,1> , ALL_SIDES);
llSetLinkColor(3, <1,1,1> , ALL_SIDES);
llSetLinkColor(4, <1,1,1> , ALL_SIDES);
llSetLinkColor(5, <1,1,1> , ALL_SIDES);
llSetLinkColor(6, <1,1,1> , ALL_SIDES);
llSetLinkColor(7, <1,1,1> , ALL_SIDES);
llSetLinkColor(8, <1,1,1> , ALL_SIDES);
llSetLinkColor(9, <1,1,1> , ALL_SIDES);
llSetLinkColor(10, <1,1,1> , ALL_SIDES);
}
else if(message == "Spring";)
{
llSetLinkColor(1, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(3, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(4, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(5, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(6, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(7, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(8, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(9, <0.239216,1,0.184314> , ALL_SIDES);
llSetLinkColor(10, <0.239216,1,0.184314> , ALL_SIDES);
}
else if(message == "Night";)
{
llSetLinkColor(1, <0,0,0> , ALL_SIDES);
llSetLinkColor(3, <0,0,0> , ALL_SIDES);
llSetLinkColor(4, <0,0,0> , ALL_SIDES);
llSetLinkColor(5, <0,0,0> , ALL_SIDES);
llSetLinkColor(6, <0,0,0> , ALL_SIDES);
llSetLinkColor(7, <0,0,0> , ALL_SIDES);
llSetLinkColor(8, <0,0,0> , ALL_SIDES);
llSetLinkColor(9, <0,0,0> , ALL_SIDES);
llSetLinkColor(10, <0,0,0> , ALL_SIDES);
}
else if(message == "Sun";)
{
llSetLinkColor(1, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(3, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(4, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(5, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(6, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(7, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(8, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(9, <1,0.976471,0.035294> , ALL_SIDES);
llSetLinkColor(10, <1,0.976471,0.035294> , ALL_SIDES);
}
else if(message == "Red";)
{
llSetLinkColor(2, <1,0,0> , ALL_SIDES);
}
else if(message == "Pink";)
{
llSetLinkColor(2, <0.592157,0.023529,0.337255> , ALL_SIDES);
}
else if(message == "NavyBlue";)
{
llSetLinkColor(2, <0.145098,0.192157,0.313725> , ALL_SIDES);
}
else if(message == "Violet";)
{
llSetLinkColor(2, <0.290196,0.176471,0.290196> , ALL_SIDES);
}
else if(message == "Blue";)
{
llSetLinkColor(2, <0,0,1> , ALL_SIDES);
}

else if(message == "Gold";)
{
llSetLinkColor(2, <0.796078,0.690196,0.337255> , ALL_SIDES);
}
else if(message == "Gray";)
{
llSetLinkColor(2, <0.156863,0.156863,0.156863> , ALL_SIDES);
}
else if(message == "Silver";)
{
llSetLinkColor(2, <0.256863,0.256863,0.256863> , ALL_SIDES);
}
else if(message == "White";)
{
llSetLinkColor(2, <1,1,1> , ALL_SIDES);
}
else if(message == "Green";)
{
llSetLinkColor(2, <0.239216,1,0.184314> , ALL_SIDES);
}
else if(message == "Black";)
{
llSetLinkColor(2, <0,0,0> , ALL_SIDES);
}
else if(message == "Yellow";)
{
llSetLinkColor(2, <1,0.976471,0.035294> , ALL_SIDES);
}
else
{
llInstantMessage(id,message + " is an unknown command.";);
}

Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
05-26-2006 15:56
You're over the limit of else statements. From the wiki:
"Note: Only up to 23 else statements may be in a conditional chain."
http://secondlife.com/badgeo/wakka.php?wakka=IfElse

Note that you're repeating a lot of code here. You need to write your code once, and once only.
Adam Marker
new scripter
Join date: 2 Jan 2004
Posts: 104
05-26-2006 16:36
I'm not sure if it would help you or not, but there is a Dialog engine posted at the wiki that can handle some of the details for you -- configured via notecard.

http://secondlife.com/badgeo/wakka.php?wakka=LibraryGeneralMenuEngine
Neglect Few
Registered User
Join date: 31 May 2004
Posts: 5
05-26-2006 19:52
From: Angela Salome
You're over the limit of else statements. From the wiki:
"Note: Only up to 23 else statements may be in a conditional chain."
http://secondlife.com/badgeo/wakka.php?wakka=IfElse

Note that you're repeating a lot of code here. You need to write your code once, and once only.


Any suggestions on how to shorten it? I was hoping for all 12 colors, with visor and shell... plus the translucent/transparent/opaque. That's 27 <_<
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
05-26-2006 20:38
From: Neglect Few
Any suggestions on how to shorten it?

Option #1: use array of vectors to store the colours, in order matching the colour labels:
CODE

// globals
list colour_labels = [ "Black", "White", "Red" ];
list colour_values = [ <0,0,0>, <1,1,1>, <1,0,0> ];

// in the dialog loop

integer i;
for( i = 0; i < llGetListLength( colour_labels ); ++i ) {

if( message == llList2String( colour_labels, i ) ) {

llSetLinkColor( 1, llList2Vector( colour_values, i ), ALL_SIDES);
// etc
}
}

this can save you the part where you parse all possible colour choices by hand.

Option #2, instead of if-else chain use just:
CODE

if( condition ) {

// do your stuff
// return
}

if( another condition ) {

// do something else
// return
}

You can combine both these options, come to think of it ^^;;
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-27-2006 00:05
Since you've actually got three menus (main and two sub-menus) you could make the main menu change states, use different channels for the dialog boxes etc. as well. The states would essentially split the if chain in half, the different channels would introduce a couple more if's, but you'd have a pseudo structure like:

if(chan==mainMenuChannel) ... do main menu stuff
else if(chan==visorMenuChannel) ... do all that colour stuff
else if(chan==shellMenuChannel) ... do that shell stuff.

so you'd have less else in the sub sections which would save you the error.

The suggestions about lists and llListFindList then looking up the vectors in a different table for the colours to save you a string of if - elses, as is the suggestion you write a function to handle the shell colours, so you only write that code once. There's no point for visor colour since that's only one line.