Difference between revisions of "Texture Particle Poofer"

From Second Life Wiki
Jump to: navigation, search
m (<lsl> tag to <source>)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{LSL Header}}
+
{{KBnote|Due to licensing issues, all contributions to this wiki have stopped and the articles that we posted are just being maintained. This is one of the projects that has gone further and for updates you are cordially invited to [http://was.fm/secondlife:texture_particle_poofer the project page on our wiki.]}}
 
+
Created by [[User:Kira Komarov|Kira Komarov]].
+
  
 
=ChangeLog=
 
=ChangeLog=
 +
 +
* 18 December 2011
 +
 +
Fix for names / textures over 24 characters. Perhaps, in the future Linden can allow people to have names as long as [http://en.wikipedia.org/wiki/Titin Titin]. I'm sure it can all be justified in some way or other.
 +
 +
Another fix to knock out the velocity mask in the particle flags. The textures should not rotate anymore.
  
 
* 4 December 2011
 
* 4 December 2011
Line 22: Line 26:
  
 
=Code=
 
=Code=
<lsl>
+
<source lang="lsl2">
 
//////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
 
// [K] Kira Komarov - 2011, License: GPLv3              //
 
// [K] Kira Komarov - 2011, License: GPLv3              //
Line 75: Line 79:
 
     timer() {
 
     timer() {
 
         llSetTimerEvent(0);
 
         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)]);
+
         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)335),20,llList2Key(tgtKeys,0)]);
 
         if(!--o) {
 
         if(!--o) {
 
             llSetTimerEvent(0);
 
             llSetTimerEvent(0);
Line 92: Line 96:
 
         integer itra;
 
         integer itra;
 
         for(itra=0, mitra=0, tgtKeys=[], tgtNames=[], menu_items=[]; itra<num; ++itra) {
 
         for(itra=0, mitra=0, tgtKeys=[], tgtNames=[], menu_items=[]; itra<num; ++itra) {
 +
            string name = llDetectedName(itra);
 
             if(llDetectedKey(itra) != NULL_KEY) {
 
             if(llDetectedKey(itra) != NULL_KEY) {
 
                 tgtKeys += llDetectedKey(itra);
 
                 tgtKeys += llDetectedKey(itra);
                 tgtNames += llDetectedName(itra);
+
                 tgtNames += llGetSubString(name, 0, 23);
                 menu_items += llDetectedName(itra);
+
                 menu_items += llGetSubString(name, 0, 23);
 
             }
 
             }
 
         }
 
         }
Line 118: Line 123:
 
         if(channel == comChannel+1) {
 
         if(channel == comChannel+1) {
 
             llListenRemove(comHandle);
 
             llListenRemove(comHandle);
             tgtKeys = (list)llList2Key(tgtKeys, llListFindList(tgtNames, (list)message));
+
             integer itra=llGetListLength(tgtNames)-1;
             integer itra;
+
            do {
 +
                if(llGetSubString(message,0,23) == llList2String(tgtNames, itra)) {
 +
                    tgtKeys = (list)llList2Key(tgtKeys, itra);
 +
                    jump found_target;
 +
                }
 +
             } while(--itra>=0);
 +
@found_target;
 
             for(itra=0, mitra=0, menu_items=[]; itra<llGetInventoryNumber(INVENTORY_TEXTURE); ++itra) {
 
             for(itra=0, mitra=0, menu_items=[]; itra<llGetInventoryNumber(INVENTORY_TEXTURE); ++itra) {
                 menu_items += llGetInventoryName(INVENTORY_TEXTURE, itra);
+
                 menu_items += llGetSubString(llGetInventoryName(INVENTORY_TEXTURE, itra), 0, 23);
 
             }
 
             }
 
             if(!llGetListLength(menu_items)) {
 
             if(!llGetListLength(menu_items)) {
Line 133: Line 144:
 
         }
 
         }
 
         if(channel == comChannel+2) {
 
         if(channel == comChannel+2) {
             texName = message;
+
             integer itra=llGetInventoryNumber(INVENTORY_TEXTURE)-1;
 +
            do {
 +
                if(llGetSubString(llGetInventoryName(INVENTORY_TEXTURE, itra), 0, 23) == message) {
 +
                    texName = llGetInventoryName(INVENTORY_TEXTURE, itra);
 +
                    jump found_texture;
 +
                }
 +
            } while(--itra>=0);
 +
@found_texture;
 
             llListenRemove(comHandle);
 
             llListenRemove(comHandle);
            integer itra;
 
 
             for(itra=2, mitra=0, menu_items=[]; itra<512; itra=itra<<1) {
 
             for(itra=2, mitra=0, menu_items=[]; itra<512; itra=itra<<1) {
 
                 menu_items += (string)itra;
 
                 menu_items += (string)itra;
Line 152: Line 169:
 
     }
 
     }
 
}
 
}
</lsl>
+
</source>
  
[[Category:LSL Library]]
 
[[Category:LSL Examples]]
 
 
[[Category:Wizardry and Steamworks]]
 
[[Category:Wizardry and Steamworks]]

Latest revision as of 09:36, 25 January 2015

KBnote.png Note: Due to licensing issues, all contributions to this wiki have stopped and the articles that we posted are just being maintained. This is one of the projects that has gone further and for updates you are cordially invited to the project page on our wiki.

ChangeLog

  • 18 December 2011

Fix for names / textures over 24 characters. Perhaps, in the future Linden can allow people to have names as long as Titin. I'm sure it can all be justified in some way or other.

Another fix to knock out the velocity mask in the particle flags. The textures should not rotate anymore.

  • 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

//////////////////////////////////////////////////////////
// [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)335),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) {
            string name = llDetectedName(itra);
            if(llDetectedKey(itra) != NULL_KEY) {
                tgtKeys += llDetectedKey(itra);
                tgtNames += llGetSubString(name, 0, 23);
                menu_items += llGetSubString(name, 0, 23);
            }
        }
        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);
            integer itra=llGetListLength(tgtNames)-1;
            do {
                if(llGetSubString(message,0,23) == llList2String(tgtNames, itra)) {
                    tgtKeys = (list)llList2Key(tgtKeys, itra);
                    jump found_target;
                }
            } while(--itra>=0);
@found_target;
            for(itra=0, mitra=0, menu_items=[]; itra<llGetInventoryNumber(INVENTORY_TEXTURE); ++itra) {
                menu_items += llGetSubString(llGetInventoryName(INVENTORY_TEXTURE, itra), 0, 23);
            }
            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) {
            integer itra=llGetInventoryNumber(INVENTORY_TEXTURE)-1;
            do {
                if(llGetSubString(llGetInventoryName(INVENTORY_TEXTURE, itra), 0, 23) == message) {
                    texName = llGetInventoryName(INVENTORY_TEXTURE, itra);
                    jump found_texture;
                }
            } while(--itra>=0);
@found_texture;
            llListenRemove(comHandle);
            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);
        }
    }
}