Jump to content

PHYS Locator


JJValero Writer
 Share

You are about to reply to a thread that has been inactive for 3954 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

Script for search physical objects.

 

key TEXTURE_KEY = "75a05371-e8bb-5b16-fbbe-2ea82a03731f";
string SOUND = "bfd75b28-d5e2-d3f6-ed8b-1ad42d591391";
float TIME = 0.5;
key g_kLastDetected;

particle_start(key kTexture, key kDestiny, vector vEndEscale, vector vAcel) {
    
    llParticleSystem( [ 
       PSYS_SRC_TEXTURE, kTexture, 
       PSYS_PART_START_SCALE, <0.1, 0.1, 0>,  PSYS_PART_END_SCALE, vEndEscale, 
       PSYS_PART_START_COLOR, <1.0,1.0,1.0>,     PSYS_PART_END_COLOR, <1.0,1.0,1.0>, 
       PSYS_PART_START_ALPHA, 0.0,         PSYS_PART_END_ALPHA, 1.0,
         
       PSYS_SRC_BURST_PART_COUNT, 1, 
       PSYS_SRC_BURST_RATE,  0.9,
       PSYS_PART_MAX_AGE, 4.0, 
       PSYS_SRC_MAX_AGE, 0.0,  
        
       PSYS_SRC_PATTERN, 1, // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE,
       PSYS_SRC_ACCEL, vAcel,
           
       PSYS_SRC_BURST_RADIUS, 0.0,
       PSYS_SRC_BURST_SPEED_MIN, 0.0,   PSYS_SRC_BURST_SPEED_MAX, 0.0, 
        
       PSYS_SRC_ANGLE_BEGIN,  0*DEG_TO_RAD,       PSYS_SRC_ANGLE_END, 90*DEG_TO_RAD,  
       PSYS_SRC_OMEGA, <1,0,0>, 
        
       PSYS_SRC_TARGET_KEY,     kDestiny,       
              
       PSYS_PART_FLAGS, ( 0      
                            | PSYS_PART_INTERP_COLOR_MASK   
                            | PSYS_PART_INTERP_SCALE_MASK   
                         //   | PSYS_PART_EMISSIVE_MASK   
                         // | PSYS_PART_FOLLOW_VELOCITY_MASK 
                         //   | PSYS_PART_WIND_MASK            
                         //   | PSYS_PART_BOUNCE_MASK          
                          | PSYS_PART_FOLLOW_SRC_MASK     
                          | PSYS_PART_TARGET_POS_MASK     
                         // | PSYS_PART_TARGET_LINEAR_MASK    
    ) ]  );
    
    
} // particle_start

particle_stop() {
    
    llParticleSystem([ ]);
    
} // particle_stop


default {
    state_entry() {
        
        llSetMemoryLimit(4096 * 4);
        
        llSetLinkPrimitiveParamsFast(
            LINK_THIS,
            [
                PRIM_NAME, "Physical  Locator (v0.2.0)",
                PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>,
                PRIM_MATERIAL, PRIM_MATERIAL_GLASS,
                PRIM_SIZE, <0.5, 0.5, 0.5>,
                PRIM_TEXTURE, ALL_SIDES, "20298eb3-1240-791a-b7e3-0274d644895d", <3.0, 3.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
                PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_HIGH, PRIM_BUMP_NONE,
                PRIM_FULLBRIGHT, ALL_SIDES, TRUE
            ]);
            
        state off;

    } // state_entry

} // default

state off {
    
    state_entry() {
        
        llSetTextureAnim (FALSE, ALL_SIDES, 0, 0, 0, 0, 0.0);
        llSetText("Phys Locator: OFF\n", <0.0, 1.0, 1.0>, 1.0);

        particle_stop();

    } // state_entry
    
    on_rez(integer start_param) {
        
        llResetScript();
        
    } // on_rez
    
    touch_start(integer num_detected) {
        
        integer iCount;
        for (iCount = 0; iCount < num_detected; iCount++) {
            if (llDetectedKey(iCount) == llGetOwner()) {
                state on;
            } // if
        } // for
        
    } // touch_start
   
    touch_end(integer num_detected) {
    } // touch_end
     
} // state off

state on {
    
    state_entry() {
        
        g_kLastDetected = NULL_KEY;
        llSetTextureAnim (ANIM_ON | LOOP | SMOOTH, ALL_SIDES, 1, 1, 0, 0, 0.05);
        llSetText("Phys Locator: ON\n", <0.0, 1.0, 1.0>, 1.0);
        llSetTimerEvent(TIME);

    } // state_entry
    
    state_exit() {
        
        llSetTimerEvent(0.0);
        
    } // state_exit
    
    on_rez(integer start_param) {
        
        llResetScript();
        
    } // on_rez
    
    touch_start(integer num_detected) {
        
        integer iCount;
        for (iCount = 0; iCount < num_detected; iCount++) {
            if (llDetectedKey(iCount) == llGetOwner()) {
                state off;
            } // if
        } // for
        
    } // touch_start

    touch_end(integer num_detected) {
    } // touch_end

    timer() {

        llSensor("", NULL_KEY, ACTIVE | PASSIVE, 96.0, PI);
        
    } // timer
    
    sensor(integer num_detected) {
        
        integer bDetected = FALSE;
        integer iCount;
        for (iCount = 0; iCount < num_detected; iCount++) {
            
            key kObject = llDetectedKey(iCount);
            list lResults = llGetObjectDetails(
                                kObject, 
                                [ 
                                    OBJECT_PHYSICS, 
                                    OBJECT_PHYSICS_COST, 
                                    OBJECT_SCRIPT_TIME, 
                                    OBJECT_OWNER, 
                                    OBJECT_NAME 
                                ]);
            
            integer bIsPhysical = llList2Integer(lResults, 0);
            if (bIsPhysical == TRUE) {
                
                if (kObject != g_kLastDetected) {
                    llPlaySound(SOUND, 1.0);
                    g_kLastDetected = kObject;
                } // if
                
                bDetected = TRUE;
             
                float fPhysCost = llList2Float(lResults, 1);
                float fScriptTime = llList2Float(lResults, 2);
                string sOwner = llList2String(lResults, 3);
                string sName = llList2String(lResults, 4);
                
                string sMsg = "Phys Locator: ON\n";
                sMsg += "Phys Cost: " + (string) fPhysCost + "\n";
                sMsg += "Script Time: " + (string) fScriptTime + "\n";
                sMsg += "Owner: " + sOwner + "\n";
                sMsg += "Name; " + sName + "\n";
                
                llSetText(sMsg, <0.0, 1.0, 1.0>, 1.0);
                
                particle_start(TEXTURE_KEY, kObject, <2.0, 2.0, 0.0>, ZERO_VECTOR);
                
                iCount = num_detected; // Break
            }
                  
        } // for

        if (bDetected == FALSE) {
            llSetText("Phys Locator: ON\nNo physical objects detected.", <0.0, 1.0, 1.0>, 1.0);
            particle_stop();
            g_kLastDetected = NULL_KEY;
        }
        
    } // sensor
    
    no_sensor() {
     
        llSetText("Phys Locator: ON\nNothing detected.", <0.0, 1.0, 1.0>, 1.0);
        particle_stop();
        g_kLastDetected = NULL_KEY;
        
    }
        
} // state on

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3954 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...