Difference between revisions of "Texture Particle Poofer"

From Second Life Wiki
Jump to: navigation, search
m
Line 2: Line 2:
  
 
Created by [[User:Kira Komarov|Kira Komarov]].
 
Created by [[User:Kira Komarov|Kira Komarov]].
 +
 +
=ChangeLog=
 +
 +
* 4 December 2011
 +
 +
[[User:Marla Kanto|Marla Kanto]] pointed out it never changed avatars when selecting an avatar from the menu again. I figured out more than that was broken, the script simply did not work as it should. Now fixed.
  
 
=Description=
 
=Description=
Line 23: Line 29:
 
// the disclaimer and warranty conditions.              //
 
// the disclaimer and warranty conditions.              //
 
//////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
 
+
 
//////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
 
//                    INTERNALS                        //
 
//                    INTERNALS                        //
 
//////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
 
+
 
list menu_items = [];
 
list menu_items = [];
 
list key_items = [];
 
list key_items = [];
 
integer mitra = 0;
 
integer mitra = 0;
 
list cList = [];
 
list cList = [];
 
+
 
list tgtKeys = [];
 
list tgtKeys = [];
 
list tgtNames = [];
 
list tgtNames = [];
 +
string texName = "";
 
integer o = 0;
 
integer o = 0;
 
integer comHandle = 0;
 
integer comHandle = 0;
 
integer comChannel = 0;
 
integer comChannel = 0;
 
+
 
list mFwd() {
 
list mFwd() {
 
     if(mitra+1>llGetListLength(menu_items)) return cList;
 
     if(mitra+1>llGetListLength(menu_items)) return cList;
Line 50: Line 57:
 
     return cList;
 
     return cList;
 
}
 
}
 
+
 
init() {
 
init() {
 
     llParticleSystem([]);
 
     llParticleSystem([]);
 
     comChannel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
 
     comChannel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
 
}
 
}
 
+
 
default {
 
default {
   
+
 
     state_entry() {
 
     state_entry() {
 
         init();
 
         init();
 
     }
 
     }
   
+
 
     on_rez(integer param) {
 
     on_rez(integer param) {
 
         init();
 
         init();
 
     }
 
     }
   
+
 
     timer() {
 
     timer() {
 
         llSetTimerEvent(0);
 
         llSetTimerEvent(0);
         llParticleSystem([12,llList2String(tgtNames,0),5,<0.2,0.2,0.2>,6,<0.45,0.45,0.45>,1,<1.0,1.0,1.0>,3,<1.0,1.0,1.0>,2,((float)1.0),4,((float)1.0),15,((integer)2),13,((float)0.8),7,((float)5.0),9,((integer)8),17,((float)0.5),18,((float)0.5),16,((float)0.5),22,(((float)0.4) * 3.14159274),23,(((float)0.0) * 3.14159274),8,<0.0,0.0,-0.1>,0,((integer)355),20,llList2Key(tgtKeys,0)]);
+
         llParticleSystem([12,texName,5,<0.2,0.2,0.2>,6,<0.45,0.45,0.45>,1,<1.0,1.0,1.0>,3,<1.0,1.0,1.0>,2,((float)1.0),4,((float)1.0),15,((integer)2),13,((float)0.8),7,((float)5.0),9,((integer)8),17,((float)0.5),18,((float)0.5),16,((float)0.5),22,(((float)0.4) * 3.14159274),23,(((float)0.0) * 3.14159274),8,<0.0,0.0,-0.1>,0,((integer)355),20,llList2Key(tgtKeys,0)]);
 
         if(!--o) {
 
         if(!--o) {
 
             llSetTimerEvent(0);
 
             llSetTimerEvent(0);
Line 76: Line 83:
 
         llSetTimerEvent(1);
 
         llSetTimerEvent(1);
 
     }
 
     }
 
+
 
     touch_start(integer num) {
 
     touch_start(integer num) {
 
         llOwnerSay("Please wait, scanning for avatars...");
 
         llOwnerSay("Please wait, scanning for avatars...");
 
         llSensor("", "", AGENT, 96, TWO_PI);
 
         llSensor("", "", AGENT, 96, TWO_PI);
 
     }
 
     }
   
+
 
     sensor(integer num) {
 
     sensor(integer num) {
 
         integer itra;
 
         integer itra;
         for(itra=0, mitra=0, menu_items=[]; itra<num; ++itra) {
+
         for(itra=0, mitra=0, tgtKeys=[], tgtNames=[], menu_items=[]; itra<num; ++itra) {
 
             if(llDetectedKey(itra) != NULL_KEY) {
 
             if(llDetectedKey(itra) != NULL_KEY) {
 
                 tgtKeys += llDetectedKey(itra);
 
                 tgtKeys += llDetectedKey(itra);
 
                 tgtNames += llDetectedName(itra);
 
                 tgtNames += llDetectedName(itra);
                 menu_items += llGetSubString(llDetectedName(itra), 0, 8);
+
                 menu_items += llDetectedName(itra);
 
             }
 
             }
 
         }
 
         }
Line 99: Line 106:
 
         llDialog(llGetOwner(), "Please select an avatar to poof from the list below:\n", cList, comChannel+1);
 
         llDialog(llGetOwner(), "Please select an avatar to poof from the list below:\n", cList, comChannel+1);
 
     }
 
     }
 
+
 
     listen(integer channel, string name, key id, string message) {
 
     listen(integer channel, string name, key id, string message) {
 
         if(message == "<= Back") {
 
         if(message == "<= Back") {
Line 111: Line 118:
 
         if(channel == comChannel+1) {
 
         if(channel == comChannel+1) {
 
             llListenRemove(comHandle);
 
             llListenRemove(comHandle);
             tgtKeys = (list)llList2String(tgtKeys, llListFindList(tgtNames, (list)message));
+
             tgtKeys = (list)llList2Key(tgtKeys, llListFindList(tgtNames, (list)message));
 
             integer itra;
 
             integer itra;
 
             for(itra=0, mitra=0, menu_items=[]; itra<llGetInventoryNumber(INVENTORY_TEXTURE); ++itra) {
 
             for(itra=0, mitra=0, menu_items=[]; itra<llGetInventoryNumber(INVENTORY_TEXTURE); ++itra) {
Line 126: Line 133:
 
         }
 
         }
 
         if(channel == comChannel+2) {
 
         if(channel == comChannel+2) {
             tgtNames = (list)message;
+
             texName = message;
 
             llListenRemove(comHandle);
 
             llListenRemove(comHandle);
 
             integer itra;
 
             integer itra;
Line 137: Line 144:
 
             return;
 
             return;
 
         }
 
         }
 
+
 
         if(channel == comChannel+3) {
 
         if(channel == comChannel+3) {
 
             llListenRemove(comHandle);
 
             llListenRemove(comHandle);

Revision as of 08:53, 4 December 2011

Created by Kira Komarov.

ChangeLog

  • 4 December 2011

Marla Kanto pointed out it never changed avatars when selecting an avatar from the menu again. I figured out more than that was broken, the script simply did not work as it should. Now fixed.

Description

This is a generic dialog-based particle-texture poofer. It will allow you to select an avatar, a texture in the object's inventory and for how many seconds to poof the avatar with the texture. It uses the endless menus from Giver in order to support an endless amount of loaded textures and avatars.

Setup

  1. Create a primitive.
  2. Drop this script inside it.
  3. Open the primitive and add textures to it.

You are set. Just click the primitive and use the menus to select your options.

Code

<lsl> ////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // //////////////////////////////////////////////////////////

////////////////////////////////////////////////////////// // INTERNALS // //////////////////////////////////////////////////////////

list menu_items = []; list key_items = []; integer mitra = 0; list cList = [];

list tgtKeys = []; list tgtNames = []; string texName = ""; integer o = 0; integer comHandle = 0; integer comChannel = 0;

list mFwd() {

   if(mitra+1>llGetListLength(menu_items)) return cList;
   cList = llListInsertList(llListInsertList(llList2List(menu_items, ++mitra, (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2);
   return cList;

}

list mBwd() {

   if(mitra-19<0) return cList;
   cList = llListInsertList(llListInsertList(llList2List(menu_items, (mitra-=19), (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2);
   return cList;

}

init() {

   llParticleSystem([]);
   comChannel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;

}

default {

   state_entry() {
       init();
   }

   on_rez(integer param) {
       init();
   }

   timer() {
       llSetTimerEvent(0);
       llParticleSystem([12,texName,5,<0.2,0.2,0.2>,6,<0.45,0.45,0.45>,1,<1.0,1.0,1.0>,3,<1.0,1.0,1.0>,2,((float)1.0),4,((float)1.0),15,((integer)2),13,((float)0.8),7,((float)5.0),9,((integer)8),17,((float)0.5),18,((float)0.5),16,((float)0.5),22,(((float)0.4) * 3.14159274),23,(((float)0.0) * 3.14159274),8,<0.0,0.0,-0.1>,0,((integer)355),20,llList2Key(tgtKeys,0)]);
       if(!--o) {
           llSetTimerEvent(0);
           llParticleSystem([]);
           return;
       }
       llSetTimerEvent(1);
   }

   touch_start(integer num) {
       llOwnerSay("Please wait, scanning for avatars...");
       llSensor("", "", AGENT, 96, TWO_PI);
   }

   sensor(integer num) {
       integer itra;
       for(itra=0, mitra=0, tgtKeys=[], tgtNames=[], menu_items=[]; itra<num; ++itra) {
           if(llDetectedKey(itra) != NULL_KEY) {
               tgtKeys += llDetectedKey(itra);
               tgtNames += llDetectedName(itra);
               menu_items += llDetectedName(itra);
           }
       }
       if(!llGetListLength(menu_items)) {
           llOwnerSay("Sorry, I could not find anybody around to poof.");
           return;
       }
       cList = llListInsertList(llListInsertList(llList2List(menu_items, mitra, (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2);
       comHandle = llListen(comChannel+1, "", llGetOwner(), "");
       llDialog(llGetOwner(), "Please select an avatar to poof from the list below:\n", cList, comChannel+1);
   }

   listen(integer channel, string name, key id, string message) {
       if(message == "<= Back") {
           llDialog(id, "Please browse the available items:\n", mBwd(), channel);
           return;
       }
       if(message == "Next =>") {
           llDialog(id, "Please browse the available items:\n", mFwd(), channel);
           return;
       }
       if(channel == comChannel+1) {
           llListenRemove(comHandle);
           tgtKeys = (list)llList2Key(tgtKeys, llListFindList(tgtNames, (list)message));
           integer itra;
           for(itra=0, mitra=0, menu_items=[]; itra<llGetInventoryNumber(INVENTORY_TEXTURE); ++itra) {
               menu_items += llGetInventoryName(INVENTORY_TEXTURE, itra);
           }
           if(!llGetListLength(menu_items)) {
               llOwnerSay("Sorry, I have no textures loaded in my inventory. Drop some textures in my inventory first.");
               return;
           }
           cList = llListInsertList(llListInsertList(llList2List(menu_items, mitra, (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2);
           comHandle = llListen(comChannel+2, "", llGetOwner(), "");
           llDialog(llGetOwner(), "Please select a texture to poof an avatar with:\n", cList, comChannel+2);
           return;
       }
       if(channel == comChannel+2) {
           texName = message;
           llListenRemove(comHandle);
           integer itra;
           for(itra=2, mitra=0, menu_items=[]; itra<512; itra=itra<<1) {
               menu_items += (string)itra;
           }
           cList = llListInsertList(llListInsertList(llList2List(menu_items, mitra, (mitra+=9)), ["<= Back"], 0), ["Next =>"], 2);
           comHandle = llListen(comChannel+3, "", llGetOwner(), "");
           llDialog(llGetOwner(), "Please select the number of seconds the avatar will be poofed:\n", cList, comChannel+3);
           return;
       }

       if(channel == comChannel+3) {
           llListenRemove(comHandle);
           o = (integer)message;
           llSetTimerEvent(2);
       }
   }

} </lsl>