Change font size
It is currently Thu Aug 13, 2020 7:18 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Scripted object not restarting on grid/region restart
PostPosted: Tue Jun 30, 2020 5:37 pm 

Joined: Tue Jun 30, 2020 5:23 pm
Posts: 2
Hi all :) So I'm using "Sound_Prim_Script__Intermittent_Day" (and night) which I found on Outworldz in an object with bird sounds that plays random bird calls during daylight hours. It was working perfectly up until our grid restarted and is now dead/silent. I can restart it by edit/reset scripts, it starts by itself on rez, it is not touch to start (I want it to be be self start when region starts). Any thoughts or ideas would be appreciated!

{L_CODE}:
// :CATEGORY:Sound
// :NAME:Sound_Prim_Script__Intermittent_Day
// :AUTHOR:Anonymous
// :CREATED:2010-01-10 05:20:56.000
// :EDITED:2013-09-18 15:39:04
// :ID:811
// :NUM:1121
// :REV:1.0
// :WORLD:Second Life
// :DESCRIPTION:
// Sound Prim Script - Intermittent Day.lsl
// :CODE:


// Sound Prim Script - Intermittent Daytime
//
// If the sun is above the horizon, this
// randomly picks a sound in inventory, plays it,
// waits a random interval, repeats.
//
// Set this between 0.0 and 1.0
float LOUDNESS = 1.0;
//
// Interval in seconds to be silent.
// If you set these to be less than 10 seconds,
// they default to 10 seconds.
integer SHORTEST = 10;
integer LONGEST = 40;
//
////////////////////////////////////////////////
default
{

state_entry()
{
    if (SHORTEST < 10 )     SHORTEST = 10;
    if (LONGEST < 10 )      LONGEST = 10;
    if (SHORTEST > LONGEST) SHORTEST = LONGEST;

    llSleep( 1.0 );   
    state noisy;
}

on_rez(integer start_param)
{
    llSleep( 1.0 );
    state noisy;
}

}
////////////////////////////////////////////////
state noisy
{

state_entry()
{
    vector sun_point = llGetSunDirection();
    if ( sun_point.z < 0.0 ) state silent;
   
    integer sounds = llGetInventoryNumber(INVENTORY_SOUND);
    if ( sounds <= 0 ) state default;

    string soundname = llGetInventoryName( INVENTORY_SOUND, llFloor(llFrand(sounds)) );
    if ( soundname != "" )
    {
        llPlaySound( soundname, LOUDNESS );
    }
   
    state silent;
}

on_rez(integer start_param)
{
    state default;
}

}
////////////////////////////////////////////////
state silent
{

state_entry()
{   
    llSleep( (float)(llFloor(llFrand(LONGEST - SHORTEST)) + SHORTEST) );
    state noisy;
}

on_rez(integer start_param)
{
    state default;
}

}

// END //


Top
 Profile  
 
 Post subject: Re: Scripted object not restarting on grid/region restart
PostPosted: Wed Jul 01, 2020 7:17 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 291
Location: Belgium / Brussels
This is your script modified:
{L_CODE}:
// Sound Prim Script - Intermittent Daytime v0.1 by Anonymous (2010)
// Modified by djphil (2020) to start automaticly

float LOUDNESS = 1.0;
integer SHORTEST = 10;
integer LONGEST = 40;

default
{
    state_entry()
    {
        if (SHORTEST < 10 ) SHORTEST = 10;
        if (LONGEST < 10 ) LONGEST = 10;
        if (SHORTEST > LONGEST) SHORTEST = LONGEST;
        llSleep(1.0);   
        state noisy;
    }

    on_rez(integer param)
    {
        llResetScript();
    }

    changed(integer change)
    {
        if (change & CHANGED_REGION_START)
        {
            llResetScript();
        }
    }
}

state noisy
{
    state_entry()
    {
        vector sun_point = llGetSunDirection();
        if ( sun_point.z < 0.0 ) state silent;
       
        integer sounds = llGetInventoryNumber(INVENTORY_SOUND);
        if ( sounds <= 0 ) state default;
   
        string soundname = llGetInventoryName( INVENTORY_SOUND, llFloor(llFrand(sounds)) );
        if ( soundname != "" )
        {
            llPlaySound( soundname, LOUDNESS );
        }
       
        state silent;
    }
   
    on_rez(integer param)
    {
        llResetScript();
    }

    changed(integer change)
    {
        if (change & CHANGED_REGION_START)
        {
            llResetScript();
        }
    }
}

state silent
{
    state_entry()
    {   
        llSleep( (float)(llFloor(llFrand(LONGEST - SHORTEST)) + SHORTEST) );
        state noisy;
    }
   
    on_rez(integer param)
    {
        llResetScript();
    }

    changed(integer change)
    {
        if (change & CHANGED_REGION_START)
        {
            llResetScript();
        }
    }
}

Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Last edited by dj phil on Wed Jul 01, 2020 7:24 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Scripted object not restarting on grid/region restart
PostPosted: Wed Jul 01, 2020 7:18 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 291
Location: Belgium / Brussels
But i suggest this one:
{L_CODE}:
// Random Daytime Sound Player v0.1 by djphil (CC-BY-NC-SA 4.0)

float volume = 1.0;
float tempo = 5.0;
integer total;

default
{
    state_entry()
    {
        total = llGetInventoryNumber(INVENTORY_SOUND);
        if (total <= 0) {llOwnerSay("Inventory sound missing ..."); return;}
        if (tempo < 5.0) tempo = 5.0;
        llSetTimerEvent(0.1);
    }

    timer()
    {
        llSetTimerEvent(tempo + llFrand(tempo));
        vector sundir = llGetSunDirection();

        if (sundir.z > 0.0)
        {
            string sound = llGetInventoryName(INVENTORY_SOUND, llFloor(llFrand(total)));
            if (sound != "") llPlaySound(sound, volume);
        }
    }

    on_rez(integer param) {llResetScript();}

    changed(integer change)
    {
        if (change & CHANGED_REGION_START) {llResetScript();}
        if (change & CHANGED_REGION_RESTART) {llResetScript();}
    }
}

Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: Scripted object not restarting on grid/region restart
PostPosted: Wed Jul 01, 2020 8:46 am 

Joined: Tue Jun 30, 2020 5:23 pm
Posts: 2
Perfect! Thank you both SO much! Tried both and they both restart on region start so yay! I like the random interval settings between sounds in the first one, but I can make use of the second one too 8-) Exactly what I needed, thanks again :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net