Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Multilink Texture and Color Changer Example
- Created: 2016-11-11, by Bugs Larnia
- Please keep annotations
- */
- //USER SETUP START
- integer giOwnerOnly = FALSE; //Set to TRUE for owner only; FALSE for everyone
- list glColorChangeLinks = ["1", "2", "3"]; //Link numbers eligible for color changes; encase entries in " "
- list glTextureChangeLinks = ["2", "4"]; //Link numbers eligible for texture changes; encase entries in " "
- //List of color vectors <red, green, blue>
- list glColors = [
- <1.0, 1.0, 1.0>,
- <1.0, 0.0, 0.0>,
- <0.0, 1.0, 0.0>,
- <0.0, 0.0, 1.0>
- ];
- //This is the list of color names - order has to match the glColors list
- list glColorNames = [
- "White",
- "Red",
- "Green",
- "Blue"
- ];
- //List of texture keys
- list glTextures = [
- "ec3d5e4a-21c4-e8b5-02ea-b4f03aa54bd9",
- "586e7250-0d32-d7a6-f833-f0988f4da20a",
- "d568a8ad-2637-33ac-90a6-f41e8b509a6e"
- ];
- //List of texture names - order has to match the glTextures list
- list glTextureNames = [
- "Fox",
- "Raccooon",
- "Goldbug"
- ];
- //USER SETUP END
- //==========================================================================
- list glLinks = ["[Cancel]", "All"];
- integer giEars;
- integer giLinkToChange;
- string gsChangeType;
- ShowMenu(key pkId, string psMsg, list plButtons)
- {
- integer iChannel = (integer)llFrand(-99999.0) - 100000;
- giEars = llListen(iChannel, "", pkId, "");
- llDialog(pkId, psMsg, plButtons, iChannel);
- llSetTimerEvent(45.0);
- }
- StopListening()
- {
- llSetTimerEvent(0.0);
- llListenRemove(giEars);
- }
- default
- {
- state_entry() { }
- touch_start(integer total_number)
- {
- key kId = llDetectedKey(0);
- if (giOwnerOnly && (kId != llGetOwner()))
- {
- return;
- }
- ShowMenu(kId, "Please select what to change:", ["[Cancel]", "Textures", "Colors"]);
- }
- listen(integer piChannel, string psName, key pkId, string psMsg)
- {
- StopListening();
- if (psMsg == "[Cancel]")
- {
- return;
- }
- if (psMsg == "Textures")
- {
- gsChangeType = psMsg;
- ShowMenu(pkId, "Please select the link to change:", glTextureChangeLinks);
- }
- else if (psMsg == "Colors")
- {
- gsChangeType = psMsg;
- ShowMenu(pkId, "Please select the link to change:", glColorChangeLinks);
- }
- //Change color and texture
- else if ((gsChangeType == "Colors") && (~llListFindList(glColorNames, [psMsg])))
- {
- integer i = llListFindList(glColorNames, [psMsg]);
- llSetLinkColor(giLinkToChange, llList2Vector(glColors, i), ALL_SIDES);
- }
- else if ((gsChangeType == "Textures") && (~llListFindList(glTextureNames, [psMsg])))
- {
- integer i = llListFindList(glTextureNames, [psMsg]);
- llSetLinkTexture(giLinkToChange, llList2String(glTextures, i), ALL_SIDES);
- }
- //Get link number
- else if (psMsg != "OK")
- {
- giLinkToChange = (integer)psMsg;
- if (gsChangeType == "Colors")
- {
- ShowMenu(pkId, "Please select the color:", glColorNames);
- }
- else if (gsChangeType == "Textures")
- {
- ShowMenu(pkId, "Please select the texture:", glTextureNames);
- }
- }
- }
- //Housekeeping
- on_rez(integer piParam)
- {
- llResetScript();
- }
- }
Add Comment
Please, Sign In to add comment