Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

set timer event problems

Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
03-23-2009 23:41
i am having a syntax error and i can not figure out what i am doing wrong with the script.

default
{
state_entry() {
llListen(0,"", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message) {
if (message == "start";)
{
llTriggerSound("62e6535d-646f-6098-ff6d-718595ec0cd4", 1.0);
llSetTimerEvent(10);
}

timer()
{
llLoopSound("4ba2839b-9462-69e4-17af-cf8f2432a623", 1);

}

if (message == "stop";)
{

llStopSound();
llTriggerSound("69b9805c-a6b8-ece4-7cd6-0c226c20040d", 1.0);

}
}
}
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Jim Gustafson
Registered User
Join date: 6 Feb 2007
Posts: 84
03-24-2009 00:00
this seems to be messed up completely :)

make sure you check that every open { has a closing }
for example you must close the bracket before the timer() event but it seems that the timer() event is misplaced because you have a if (message == "stop";) after that

I think this is what you wanted to do intentionally:


default
{
state_entry() {
llListen(0,"", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message) {
if (message == "start";)
{
llTriggerSound("62e6535d-646f-6098-ff6d-718595ec0cd4", 1.0);
llSetTimerEvent(10);
}

if (message == "stop";)
{
llStopSound();
llTriggerSound("69b9805c-a6b8-ece4-7cd6-0c226c20040d", 1.0);
}
}

timer()
{
llLoopSound("4ba2839b-9462-69e4-17af-cf8f2432a623", 1);

}
}
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
03-24-2009 00:03
thats very close, the sound loop started again after i used the stop command but way closer than anything i managed thanks :)
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
03-24-2009 00:12
From: Jim Gustafson
this seems to be messed up completely :)

make sure you check that every open { has a closing }
for example you must close the bracket before the timer() event but it seems that the timer() event is misplaced because you have a if (message == "stop";) after that

I think this is what you wanted to do intentionally:


default
{
state_entry() {
llListen(0,"", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message) {
if (message == "start";)
{
llTriggerSound("62e6535d-646f-6098-ff6d-718595ec0cd4", 1.0);
llSetTimerEvent(10);
}

if (message == "stop";)
{
llStopSound();
llTriggerSound("69b9805c-a6b8-ece4-7cd6-0c226c20040d", 1.0);
}
}

timer()
{
llLoopSound("4ba2839b-9462-69e4-17af-cf8f2432a623", 1);

}
}

very close, i just need to figure out how to switch it so the loop is played between the start and stop command (with the 10 second delay, with the non looping sounds triggered by the start/stop commands and then blisful silence afterwards
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
03-24-2009 03:35
in the stop you want to set the timer to 0 also

From: someone

default
{
state_entry() {
llListen(0,"", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message) {
if (message == "start";)
{
llTriggerSound("62e6535d-646f-6098-ff6d-718595ec0cd4", 1.0);
llSetTimerEvent(10);
}

if (message == "stop";)
{
llSetTimerEvent(0); //stops the timer event
llStopSound();
llTriggerSound("69b9805c-a6b8-ece4-7cd6-0c226c20040d", 1.0);
}
}

timer()
{
llLoopSound("4ba2839b-9462-69e4-17af-cf8f2432a623", 1);

}
}
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-24-2009 04:08
be aware, setting the timer to 0 won't clear a timer event already queued, so you might want to use a variable to test it and shortcut the timer code if it's been queued

something like
//-- in the start code
gBooRun = TRUE;

//-- in the stop code
gBooRun = FALSE;
llSetTimerEvent ( gBooRun );

//-- in the timer event
if (gBooRun){
//-- loop sound
}

although really I don't see the need for the timer to keep running at all since it's a looped sound, so setting the timer to 0 IN the timer event is probably more effective, but you may still want to use that check variable because the stop message could come before the first timer event is run... so more like this

CODE

integer gBooRun;

default{
state_entry() {
llListen(0,"", NULL_KEY, "");
}

listen(integer channel, string name, key id, string message) {
if ("start" == message){
llTriggerSound( "62e6535d-646f-6098-ff6d-718595ec0cd4", 1.0 );
gBooRun = TRUE;
llSetTimerEvent( 10 );
}else if ("stop" == message){
llStopSound();
llTriggerSound( "69b9805c-a6b8-ece4-7cd6-0c226c20040d", 1.0 );
gBooRun = FALSE;
}
}

timer(){
if (gBooRun){
llLoopSound( "4ba2839b-9462-69e4-17af-cf8f2432a623", 1 );
}
llSetTimerEvent( 0 );
}
}

will keep edge cases of the timer firing after the fact by being queued as an event already, AND keep from needlessly retriggering a sound that's already looping on it's own .
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -