Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008032opensim[REGION] Script Functionspublic2016-10-08 12:062016-10-13 17:16
Reportercuteulala 
Assigned To 
PrioritylowSeveritytweakReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0008032: This script does not stop when touched
DescriptionThis script once touched starts to play a list of music files and then proceeds to loop it forever until clicked on again but it does not stop. it simply stops and then restarts on its own. this isn't the function this was scripted for.
Steps To Reproduce// remove this number for the script to work.

//Psyke's Music Script v4.15.1
//Song Player

//Modified by Psyke Phaeton... this script is free for anyone to use or copy.. please make it copyable from your "CD"
//Drop 9 second song clips in reverse order into the Inv of the obect, and touch to play.

//user variables

integer waves_to_preload = 3; //wave files to Preload ahead of the wav being played.
float preload_load_time = 0.5; // seconds pause between each preloaded wave file attempt b4 play comnences
//vector set_text_colour = <,0,0>; // colour of floating text label
float set_text_alpha = 1; //no idea what this is LOL
float timer_interval = 9.9; //time interval between requesting server to play the next 9 second wave
                                    // times just below 9 seconds are suitable as we use sound queueing
integer timer_started;

// program variables
list invlist;
integer total_wave_files; //number of wave files
integer last_wave_file_number; //final wave sequence number (note: sequence starts at zero
                                                            //- so this is 1 less than total wave files)
integer i; //used by timer() player
integer c; //user by sound() bufferer
string preloading_wave_name; //the name of the wave file being preloaded
string playing_wave_name; //the name of the wave being played
integer play = FALSE; //toggle for music playing or stopped

sound()
{
        total_wave_files = llGetInventoryNumber(INVENTORY_SOUND);
        last_wave_file_number = total_wave_files - 1; // because wav files are numbered from zero
        float length = total_wave_files*9.0;
        //llSay(0, "preloading " + (string)tottrack + " wavs. Play length " + (string)llFloor(length) + "secs");
        integer c = 0;
        //do full preload of sound
        llSetSoundQueueing(TRUE); //ONLY WORKS ON llPlaySound not llTriggerSound
        /////////////////
        //integer x = waves_to_preload;
        //if ( total_wave_files < waves_to_preload ) { x = total_wave_files; }
        ////////////////
        integer x = total_wave_files;
 // llSay(0, "(" + llGetScriptName() + ") " + llGetSubString((string)(x * preload_load_time),0,3) + " sec buffering..");
        timer_started = FALSE;
        for (c = 0 ; c <= (x - 1) ; c++) { //preload X wave files b4 we play
                                                          //since wavs are numbered from 0 we minus 1
            preloading_wave_name = llGetInventoryName(INVENTORY_SOUND, c);
 // llSetText(llGetObjectName() +
               // "\n(preloading " + llGetSubString((string)((x - c)*preload_load_time),0,3) + " secs)"
                    //////debug lines
                    //+ "\n--debug--\n"
                    //+ "Preload wav: " + (string)c
                    //+ " name: " + preloading_wave_name
                    //+ "\nkey: " + (string)llGetInventoryKey(preloading_wave_name)
                    //////end debug line
                     // +"\n.", <1,0,0>, set_text_alpha);

            //Attempt to preload first x wave files to local machines cache!
            llTriggerSound(preloading_wave_name, 0.0);
            llPreloadSound(preloading_wave_name);
            //llWhisper(0, (string)c + " of " + (string)tottrack);
            //llWhisper(0,"Preloading wav: " + (string)c + (string)llGetInventoryKey(preloading_wave_name));
            
            //start play sound timer in 'timer_interval' seconds when we are less than 'timer_interval' seconds from
            // finishing preloading.
            if ( ((total_wave_files - c) * preload_load_time) < timer_interval && !timer_started) {
                //llWhisper(0, "Starting timer:" + (string)timer_interval);
                llSetTimerEvent(timer_interval);
                timer_started = TRUE;
            }
            
            llSleep(preload_load_time);
        }
        i=0; c=0;
 // llSay(0, "Done! Playing.. (" + (string)llFloor(length) + " secs) Click to stop.");
        //llSetTimerEvent(8.85);
}

default
{
    on_rez(integer start_param)
    {
        //set text above object to the name of the object
     // llSetText(llGetObjectName() + "\n.", <0,1,0>, set_text_alpha);
        //llSetSoundQueueing(FALSE); //ONLY WORKS ON llPlaySound not llTriggerSound
    }
    touch_start(integer total_number)
    {
        if (!play) {
           //llTargetOmega(<0,1,0>,0.5,PI);
            sound();
        } else {
            //llTargetOmega(<0,1,0>,0,0);
            llSetTimerEvent(0.0);
            llStopSound();
            //llSetSoundQueueing(FALSE); //ONLY WORKS ON llPlaySound not llTriggerSound
   // llSay(0, "Stopping..");
   // llSetText(llGetObjectName() + "\n.", <0,1,0>, set_text_alpha);
        }
        
        play = !play;
    }
    
    timer()
    {
        if( i > last_wave_file_number )
            i = 0;

        playing_wave_name = llGetInventoryName(INVENTORY_SOUND, i);
            //llWhisper(0, "llPlaySound wav: " + (string)i + " " + (string)llGetInventoryKey(playing_wave_name) );
        llPlaySound(playing_wave_name, 1.0);
        // llSetText( llGetObjectName() +
              // "\n(playing " + (string)i +" of "+ (string)last_wave_file_number +")\n."
             // , <0,1,1>, set_text_alpha);
        
        if(i + waves_to_preload <= last_wave_file_number)
        {
            preloading_wave_name = llGetInventoryName(INVENTORY_SOUND, i + waves_to_preload);
                //llSetText( llGetObjectName() +
                // "\n(playing " + (string)i +" of "+ (string)last_wave_file_number +")"
                             //////debug line
                             //+ "\n--debug--\n"
                             //+ "Playing key: " + (string)llGetInventoryKey(playing_wave_name) + "\n"
                             //+ "Preloading sequence: " + (string)(i + waves_to_preload)
                             //+ " name: " + preloading_wave_name
                             //+ "\nPreloading key: " + (string)llGetInventoryKey(preloading_wave_name)
                             //////end debig line
                // , set_text_colour, set_text_alpha);
                
                //llWhisper(0, "Preloading wav:" + (string)(i + waves_to_preload) + " " +
                // (string)llGetInventoryKey(preloading_wave_name) +" last = " + (string)last_wave_file_number);
             llTriggerSound(llGetInventoryName(INVENTORY_SOUND, i + waves_to_preload), 0.0);
             llPreloadSound(llGetInventoryName(INVENTORY_SOUND, i + waves_to_preload));
        }

    i++; //increment for next wave file in sequence!
    }
}
Additional InformationJust reporting a script function that may be bugged
TagsNo tags attached.
Git Revision or version number
Run ModeStandalone (1 Region)
Physics EngineOther
Script Engine
Environment.NET / Windows64
Mono VersionNone
Viewer
Attached Files

- Relationships

-  Notes
(0031196)
UbitUmarov (administrator)
2016-10-08 12:10

events code needs to be short. It can't loop for ever.
They will be automatically killed, possible leaving the script in a bad state :(
(0031199)
mewtwo0641 (reporter)
2016-10-13 17:16

That llSleep(preload_load_time); line in sound() may be the problem. It looks like preload_load_time is set for 0.5 seconds, this is being called in a loop; One call per sound that you have in inventory. Not only that but llPreloadSound() also sleeps the script for 1 second per call... So you have 1.5 seconds of sleep time per sound while it's executing that loop. The default event time I believe is 30 seconds, so if that script is spending all that time in that loop with a bunch of sounds then XEngine is eventually going to interrupt that event after 30 seconds which could cause the problem you're seeing here. Try commenting the llPreloadSound(preloading_wave_name); and llSleep(preload_load_time); lines in sound() and see if that makes a difference in the functionality of the touch start/stop.

- Issue History
Date Modified Username Field Change
2016-10-08 12:06 cuteulala New Issue
2016-10-08 12:10 UbitUmarov Note Added: 0031196
2016-10-13 17:16 mewtwo0641 Note Added: 0031199


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker