Texture Particle Poofer

From Second Life Wiki
Revision as of 03:08, 17 November 2011 by Kira Komarov (Talk | contribs)

Jump to: navigation, search

Created by Kira Komarov.

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 = []; 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,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)]);
       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, menu_items=[]; itra<num; ++itra) {
           if(llDetectedKey(itra) != NULL_KEY) {
               tgtKeys += llDetectedKey(itra);
               tgtNames += llDetectedName(itra);
               menu_items += llGetSubString(llDetectedName(itra), 0, 8);
           }
       }
       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)llList2String(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) {
           tgtNames = (list)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>