Original creations in Second Life by Oggy Fink.

Tuesday, October 18, 2011

Touch and Glow

Halloween is coming people ! Why not make some creeeeepy objects glow and play scary sounds ?

The following script is able to do just that. Adjust the parameters (written in bold in the script) to match your taste, put it into your prim and you're going !

Some explanations about settings are given as comments in the script, they should be quite easy to follow. If not, feel free to ask for more, either by commenting this post or by sending me an email : oggy.fink(at)gmail.com...


// Touch & Glow by Oggy Fink
// Use this script to make your prim glow when it's touched and play a
// (probably creepy) sound.
// See the parameters below.
// This script is free and full perm, but don't sell it as is. Using it
// into your creations (and selling them) is fine.

string sound="ee186da7-36c5-082a-f6ab-613cc33d3444";    // set this to the
    // name or UUID of the sound to play, or "" to disable sound
float volume=1.0;   // volume for the sound, between 0 (silent) and 1 (full
    // volume)
float maxglow=1.0;  // maximum amount of glow when active (between 0 and 1)

integer steps=25;   // number of steps for the glow. More means smoother and
    // longer transition
float stepdelay=0.1;    // time (in seconds) between each step. More means
    // longer.
float sustainglow=0.0;  // time to remain at full glow

// here are the face numbers that will receive the glow. You can add more but
// you will have to modify the rules (see below)
// you can also set one face to ALL_SIDES
integer facea=1;    // number of first face
integer faceb=3;    // number of second face
// could have used a list and a loop, but efficiency was the priority...

default {
    touch_start(integer total_number) {
        integer i;
        llPlaySound(sound,volume);
        for (i=1;i<=steps;i++) {
// modify the following line if you want to add or remove one face. Just copy
// the PRIM_GLOW,facenumber,i*maxglow/steps for each face
            llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_GLOW,facea,
                i*maxglow/steps,PRIM_GLOW,faceb,i*maxglow/steps]);
            llSleep(stepdelay);
        }
        if (sustainglow>0.0) llSleep(sustainglow);
        for (i=steps-1;i>=0;i--) {
// same modifications expected here
            llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_GLOW,facea,
                i*maxglow/steps,PRIM_GLOW,faceb,i*maxglow/steps]);
            llSleep(stepdelay);
        }
    }
}

The following simple script will help you determine a face number. Just put it into your prim and it will tell you which face is touched. Use the number in the Touch&Glow script to achieve exactly the desired effect. This script is called - trumpets, play ! - "Detectface" :)
// This script will tell which face was touched.

default {
    touch_start(integer total_number) {
        llSay(PUBLIC_CHANNEL,"Touched face #"+((string)llDetectedTouchFace(0)));
    }
}
All this is downloadable for free at my marketplace store. Comments, constructive criticism, (good) ratings and donations are welcome :)

3 comments:

  1. Hi.. I can´t seem to make it work :( I placed the scripts (touch&glow and detectface) in the object, but when I click it only starts the sound... no glow. Any advice? thanks in advance and for your work :)

    ReplyDelete
  2. You are not supposed to put both scripts into your objects ! You problem probably comes from a bad face number (not all faces exist for every kind of prim).

    First, put Detectface (and make sure it's "running"). Then touch the face you want to glow. The script will tell you which face number it is. As it is the script Touch&Glow can make 2 faces glow (see article on how to add more, or use ALL_SIDES if everything is to glow).

    Then remove DetectFace and put in the touch&glow script. You will have to modify the facea and faceb values in the script (see article) to the numbers you got from DetectFace.

    Save the script in your object, make sure it is running, and it should glow as desired.

    Feel free to IM me in world if it still doesn't work...

    ReplyDelete
  3. Dude I´m in debt with you thanks a lot!!!!! I will put a nice review on this item on marketplace!!!

    ReplyDelete

Comments are welcome, spam is not.