| Scripting Discuss scripting for SL and other platforms |
| |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Texture/color change in certain prims (all sides) Okay, I've been looking for this for a while. I've seen things that come "close", but no cigar. So here's what I'm looking for, as best I can describe. I built a 6 prim couch. I want to put in say... 10 grayscale fabric textures. I want to be able to click that couch and get a blue menu with "Textures" and "Colors" options. Clicking the "textures" button, you can pick the texture you want from a list. Clicking the "colors" button will give you a list to color that texture. Here's the thing, though. For the "colors" menu, I want to be able to use my own RGB variables. Not the basic colors. On top of THAT, I would like for this couch, ONLY the cushions to change. Not the base. Or even perhaps put the same script in the base (bottom) of the couch with different texture/color options (like wood). I KNOW this is doable, I just haven't been able to find the script for it. Could someone help me pretty please? |
| | |
| | #2 (permalink) |
| dorkasaurus ![]() ![]() ![]() ![]() ![]() ![]() SLU Supporter ![]() ![]() ![]()
same as the old me
Join Date: Mar 2008 Location: N.E. United States
Posts: 1,586
My Mood: SLShopper Ads: 3 SL Join Date: Nov 2007
Business: Madhu's Cafe Blog Entries: 3 | I very recently wrote a script that does just this but it's very specialized for my application and I wouldn't be able to just pass it to you to do what you want. However, I can tell you what I learned in figuring out how to do it, if you can do a little scripting yourself. The LLSetLinkPrimitiveParams function (using the PRIM_COLOR option) is the function that do this for you. With that function, a menu script in the root prim of the object can change the color of whichever prims in the couch you want to whatever RGB values you put in. (I could probably write it for you but I am hesitant to volunteer because I'm (a) hardly more than a beginner scripter myself, and (b) overbooked in SL already. Maybe someone else who is a more experienced scripter than myself could do it for you. )
__________________ |
| | |
| | #3 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | You lost me at "LLSetLinkPrimitiveParams function", rofl. Scripting is NOT one of my strong points. At best, I can pick out bits and tweak them and eventually make simpler scripts work. |
| | |
| | #4 (permalink) |
| Junior Member ![]() Join Date: May 2009 Location: Germany
Posts: 16
SL Join Date: 3-5-2008 | Please try this (not tested yet): Put this script in your root prim Code: // your textures here
list Textures = ["Texture1","Texture2","Texture3"];
// your colors here
list Colors = [<0,0,0>,<1,0,0>,<0,1,0>];
// your buttons for colors here
list Buttons = ["Black","Red","Green"];
integer Channel;
key User;
Menu1()
{
llDialog(User, "Choose an option:", ["Textures", "Colors"], Channel);
}
Menu2()
{
llDialog(User, "Choose a texture:", Textures, Channel);
}
Menu3()
{
llDialog(User, "Choose a color:", Buttons, Channel);
}
default
{
state_entry()
{
Channel = -((integer)llFrand(99999) + 999);
llListen(Channel, "", NULL_KEY, "");
}
on_rez(integer start_param)
{
Channel = -((integer)llFrand(99999) + 999);
llListen(Channel, "", NULL_KEY, "");
}
touch_start(integer total_number)
{
User = llDetectedKey(0);
Menu1();
}
listen(integer channel, string name, key id, string message)
{
if(message == "Textures")
{
Menu2();
return;
} else if(message == "Colors")
{
Menu3();
return;
} else
{
integer x = llListFindList(Textures, [message]);
if(x != -1)
{
llMessageLinked(LINK_SET, 0, llList2String(Textures, x), NULL_KEY);
}
x = llListFindList(Buttons, [message]);
if(x != -1)
{
llMessageLinked(LINK_SET, 1, llList2String(Colors, x), NULL_KEY);
}
}
}
}
Code: default
{
link_message(integer sender_number, integer number, string message, key id)
{
if(number == 0) llSetTexture(message, ALL_SIDES);
else if(number == 1) llSetColor((vector)message, ALL_SIDES);
}
}
|
| | |
| | #5 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | I'll play with that as soon as I can log in. How do I put in my own colors in there? Last edited by Zanne Boucher; 10-22-2009 at 11:06 AM. |
| | |
| | #6 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | EDIT: OMG I'm such a doofus. Disregard that question. xD Testing it now, lol. |
| | |
| | #7 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Okay, I have it in there. The colors menu just isn't working. Well, the menu comes up right, it just doesn't change the prim color. I tried two different settings for that section. Here, I tried using the RGB values.... which didn't work Code: // your colors here list Colors = [<145,164,182>,<166,180,147>,<178,172,149>]; // your buttons for colors here list Buttons = ["Soft Blue","Soft Green","Tan"]; And here, I used the 0 &1 method which DID. Code: // your colors here list Colors = [<1,0,0>,<0,1,0>,<0,0,1>]; // your buttons for colors here list Buttons = ["Soft Blue","Soft Green","Tan"]; |
| | |
| | #8 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Okay yay I got it! Figured I'd try it in one of my yarn skeins with two color prims and one plain, with the different grayscale kinda yarn textures (wool, cotton, chenille). I converted the rgb colors I wanted (thanks to tango linking me to instructions how to do it in lsl wiki) et voila! Works like a charm. ![]() TYTY So much Rebekka! *hugs* |
| | |
| 1 User Said Thanks: |
| | #9 (permalink) |
| dorkasaurus ![]() ![]() ![]() ![]() ![]() ![]() SLU Supporter ![]() ![]() ![]()
same as the old me
Join Date: Mar 2008 Location: N.E. United States
Posts: 1,586
My Mood: SLShopper Ads: 3 SL Join Date: Nov 2007
Business: Madhu's Cafe Blog Entries: 3 | If you have the rgb values (three values that run between 0 and 255) all you have to do to convert them to values between 0 and 1 is divide the numbers by 255. So < 145, 164, 182 > becomes < 0.56863, 0.64314, 0.71373 >, etc. |
| | |
| | #10 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | TY, that's what I did and it worked. Now I just have one other issue. xD Is there any way to work around the 12 button limit? What if I want more than 12 color options? Any ideas? |
| | |
| | #11 (permalink) |
| Animates and Scripts ![]() Join Date: Oct 2009 Location: rural northeast US
Posts: 33
My Mood: SL Join Date: Sept 2006
Business: jeaniesing's things | if you are wanting to learn.... this script example taught me what i needed to know about menus longer than 12 Texture Menu Management - Second Life Wiki touch_start(integer total_number) { integer i = 0; MENU1 = []; MENU2 = []; // count the textures in the prim to see if we need pages integer c = llGetInventoryNumber(INVENTORY_TEXTURE); // or llGetListLength(mylist); if (c <= 12) { for (; i < c; ++i) MENU1 += llGetInventoryName(INVENTORY_TEXTURE, i); //llList2String(mylist,i); } else { for (; i < 11; ++i) MENU1 += llGetInventoryName(INVENTORY_TEXTURE, i); //llList2String(mylist,i); if(c > 22) c = 22; for (; i < c; ++i) MENU2 += llGetInventoryName(INVENTORY_TEXTURE, i); //llList2String(mylist,i); MENU1 += ">>"; MENU2 += "<<"; } // display the dialog Dialog(llDetectedKey(0), MENU1); } |
| | |
| | #12 (permalink) |
| Junior Member ![]() Join Date: May 2009 Location: Germany
Posts: 16
SL Join Date: 3-5-2008 | A menu which i use regularly. You can have as many buttons as you want. Code: // the buttons
list DlgItems = [];
string NEXT = ">>>";
string PREV = "<<<";
string DLGTITLE = "Choose a button:";
integer DLGCHANNEL;
integer DlgPage = 0;
integer Listener;
key User;
DlgShow()
{
list Dlg = [];
integer Count = llGetListLength(DlgItems);
integer Start = (DlgPage - 1) * 10 + 11;
if(DlgPage == 0)
{
Start = 0;
if(Count < 13) Dlg = DlgItems;
else Dlg = llList2List(DlgItems, 0, 1) + [NEXT] + llList2List(DlgItems, 2, 10);
} else
{
if(Count < Start + 12) Dlg = [PREV] + llList2List(DlgItems, Start, Start + 11);
else Dlg = [PREV] + llList2List(DlgItems, Start, Start) + [NEXT] + llList2List(DlgItems, Start + 1, Start + 9);
}
llListenRemove(Listener);
Listener = llListen(DLGCHANNEL, "", User, "");
llDialog(User, DLGTITLE, Dlg, DLGCHANNEL);
}
integer DlgMain(string msg)
{
if(msg == PREV)
{
DlgPage--;
DlgShow();
return TRUE;
} else if(msg == NEXT)
{
DlgPage++;
DlgShow();
return TRUE;
} else if(msg == " ")
{
DlgShow();
return TRUE;
}
else return FALSE;
}
default
{
state_entry()
{
integer i;
DLGCHANNEL = (integer)llFrand(10000) + 999;
// just for demonstration
DlgItems = [];
for(i = 0; i < 35; i++) DlgItems += [(string)i];
}
touch_start(integer total_number)
{
User = llDetectedKey(0);
DlgPage = 0;
DlgShow();
}
listen(integer channel, string name, key id, string message)
{
if(DlgMain(message)) return;
// your code here
llSay(0, "Button " + message + " was pressed.");
}
}
|
| | |
| | #13 (permalink) |
| The Purple ![]() ![]() ![]() ![]()
Kinda at work. Somewhat.
Join Date: Dec 2007 Location: Somewhere purple, Germany
Posts: 3,096
My Mood: | I strongly suggest -against- using a script that requires a script in each and every prim you want to re-texture or to recolor. Bad bad bad. It's the reason so many objects with recoloring or retexturing scripts eat alot more script time than they should, especially if they have alot of prims. Consider this: Code: //Ignore the firs value
list COLORS=[0,"Soft Blue",<145,164,182>,"Soft Green",<166,180,147>,"Tan",<178,172,149>];
// Why hold textures in inventory? Use menunames + texture keys :3
list TEXTURES=[0,"Texturename","Texturekey","Texturename","Texturekey"];
list BUTTONS=["Colors","Textures","<<",">>"]; // for listener, not button display!
//Ignore the firs value
list COLORS=[0,"Soft Blue",<145,164,182>,"Soft Green",<166,180,147>,"Tan",<178,172,149>];
// Why hold textures in inventory? Use menunames + texture keys :3
list TEXTURES=[0,"Texturename","Texturekey","Texturename","Texturekey"];
list BUTTONS=["Colors","Textures","<<",">>"]; // for listener, not button display!
list BUTTONS=["Colors","Textures","<<",">>"]; // for listener, not button display!
list lSpecialPrims; // Link numbers of speshul prims!
list lTextures; // List of inventory-loaded textures
list lTemp; // Multi-Purpose List
integer iListener;
integer iPrimCount; // Amount of prims of object
integer iPage; // Page of Texture/Color buttons
integer iFlags; //FLAGS: 1 - in use, 2 - textures, not colors
integer iTemp; // Multi-purpose integer
string sTemp; // Selected color value or texture key
key kToucher; // key of person who touched the object
setFlag(integer flag) // For setting iFlag values safely
{
if(!(iFlags & flag))
iFlags+=flag;
}
unsetFlag(integer flag) // For unsetting iFlag values safely
{
if(iFlags & flag)
iFlags-=flag;
}
getPrims() // Get all special prims
{
iTemp=iPrimCount=llGetNumberOfPrims();
lSpecialPrims=[];
do
{
if(llGetLinkName(iTemp) == "couchpotato")
lSpecialPrims+=iTemp;
}
while(iTemp=~-iTemp);
}
doMenu(integer page) // Menu System for Colors/Textures
{
llSetTimerEvent(10);
if((iTemp=(lTemp != [])) < 27) // if less than 13 colors/textures
llDialog(kToucher,"Colors:",llList2ListStrided(llDeleteSubList(lTemp,0,0),0,24,2),123456);
else if(((((iPage+1) * 10)+1) < ((iTemp/2)-1)) && iPage) // If more than 12 colors/textures and not on first page
llDialog(kToucher,"Colors:","<<" + llList2ListStrided(llDeleteSubList(lTemp,0,0),(iPage * 22),19 + (iPage * 22),2) + ">>",123456);
else if(iPage) // More than 12, last page
llDialog(kToucher,"Colors:","<<" + llList2ListStrided(llDeleteSubList(lTemp,0,0),(iPage * 22),21 + (iPage * 22),2),123456);
else // more than 12, first page
llDialog(kToucher,"Colors:",llList2ListStrided(llDeleteSubList(lTemp,0,0),0,21,2) + ">>",123456);
}
default
{
state_entry()
{
getPrims();
}
changed(integer change)
{
if(change & CHANGED_LINK)
getPrims();
}
touch_start(integer foo)
{
if(!(iFlags & 1)) // If nobody is using the menu, go go go!
{
setFlag(1);
iListener=llListen(123456,"",kToucher=llDetectedKey(0),"");
}
if(kToucher == llDetectedKey(0)) // Might be re-touching while in use, check sepereately like this
{
iPage=0;
llDialog(kToucher,"Change what?",["Colors","Textures"],123456);
llSetTimerEvent(10);
}
}
timer() // Turn off listener, allow others to use menu again
{
llListenRemove(iListener);
llSetTimerEvent(0);
unsetFlag(1);
unsetFlag(2);
kToucher=NULL_KEY;
}
listen(integer channel, string name, key id, string message)
{
llSetTimerEvent(10);
iTemp=llListFindList(BUTTONS,[message]); // speedhax
if(iTemp == 0) // "Colors"
{
unsetFlag(2);
lTemp=COLORS;
doMenu(iPage);
}
else if(iTemp == 1) // "Textures"
{
setFlag(2);
lTemp=TEXTURES;
doMenu(iPage);
}
else if(iTemp == 2) // "<<"
doMenu(iPage=~-iPage);
else if(iTemp == 3) // ">>"
doMenu(iPage=-~iPage);
else
{
sTemp=llList2String(lTemp,llListFindList(lTemp,[message])+1);
iTemp=(lSpecialPrims != []);
if(iFlags & 2) // Set Textures
{
do
llSetLinkTexture(llList2Integer(lSpecialPrims,iTemp=~-iTemp),sTemp,ALL_SIDES);
while(iTemp);
}
else // Set Colors
{
sTemp=(string)(((vector)sTemp) / 255);
do
llSetLinkColor(llList2Integer(lSpecialPrims,iTemp=~-iTemp),(vector)sTemp,ALL_SIDES);
while(iTemp);
}
llSetTimerEvent(0.01); // Shut off listener
}
}
}
Normal RGB colors are supported, and it uses texture keys instead of textures in inventory. Menu is multi-paged, and while a person uses the menu, noone else can. if you're just interested in how to get the special prims, see the getPrims() function I made, and how it's used in state_entry and the changed event. Note: Can't log in and test the whole script right now, so it might gloriously explode. :3 Yell if the menu melts or there are bugs. EDIT: Forgot to add ignorable '0' value at the start of texture list EDIT EDIT: iListener added and semicolon typo fixed EDIT^3: Tested in-world, fixed, updated. wee.
__________________ "Have you ever noticed that anybody driving slower than you is an idiot, and anyone going faster than you is a maniac?" - George Carlin Last edited by Chalice Yao; 10-23-2009 at 11:33 AM. |
| | |
| 1 User Agreed: |
| | #16 (permalink) |
| The Purple ![]() ![]() ![]() ![]()
Kinda at work. Somewhat.
Join Date: Dec 2007 Location: Somewhere purple, Germany
Posts: 3,096
My Mood: | on that note, I wish LSL-Plus (The Eclipse plugin) supported the fancy =~- and (list!= []) constructs. Right now I'm using SciTE with the lsl syntax support whenever I can't log in. It recently got updated :3 |
| | |
| | #17 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | OMG, I'm not a skilled scripter, but that's pretty code! TY Chalice, I'll go try it out now. |
| | |
| | #18 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Woops, it says there's a syntax error on line 115, and a blue "do" is highlighted. I have no clue what "do" does or doesn't do, lol. |
| | |
| | #20 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | LOL okay that's fixed, but now a new error on line 65. iListener=llListen(123456,"",kToucher=llDetectedKe y(0),""); Says Name not defined within scope... |
| | |
| | #22 (permalink) | |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | I know it looks like that on here. I saw it and went back to the script, but there's no space in the actual script. xD Quote:
| |
| | |
| | #23 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Grrr, I don't know why it's showing here like that. Let me repaste the code. I went back and typed over it again in the script to be sure, but it's still saying the same thing. |
| | |
| | #24 (permalink) | |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Quote:
| |
| | |
| | #25 (permalink) |
| Queen Dork ![]()
Mah eyes are tired!
Join Date: Oct 2009 Location: Florida
Posts: 74
My Mood: SLShopper Ads: 22 SL Join Date: 6/15/07
Business: *ZOE* Decor Blog Entries: 3 | Just so you know I'm not nuts, lol. Here's a pic of what I'm looking at. I even tried highlighting that detectedkey and replacing with LL's detectedkey text. |
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |