Jump to content

walker script to toggle on touch on/off


JDroo
 Share

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

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

Recommended Posts

integer toggle;

default
{
    state_entry()
    {
        llStopSound();
        llSetTimerEvent(0.2);
    }
    
    timer()
    {
        if (llGetAgentInfo(llGetOwner()) & AGENT_WALKING)
        {
            state walking;
        }
    }
}
state walking
{
    state_entry()
    {
        llSetTimerEvent(0.2);
        llLoopSound("uuid",1.0);
    }
    timer()
    {
        if (!(llGetAgentInfo(llGetOwner()) & AGENT_WALKING))
        {
            state default;
        }
    }
}

 the walking script ^

integer toggle;

default
{
    state_entry()
    {
        //llSay(0, "Hello, Avatar!");
    }
    touch_end(integer total_number)
    {
        toggle=!toggle;//switch from FALSE to TRUE or vice versa
        if(toggle){
            //do stuff
        }
        else{
            //stop doing it
        }
    }
}

 simple touch on/off script i think ^

 

 

What i want to do is combine these scripts if possible so it plays sound when walking like normal, but i can turn it on and off when desired. It's probably really easy for someone who knows scripting to do this, but I'm not so talented in this area, anyone out there bored n wanna help me out?

 

Link to comment
Share on other sites

Hi you could make it a bit more fancy and involved like making it attach and all that but this will get you started :)

integer toggle;default{state_entry(){llStopSound();llSetTimerEvent(0.2);}touch_start(integer total_number){toggle=!toggle;if(toggle){llOwnerSay("Sound on");llSetTimerEvent(0.2);}else{llOwnerSay("Sound off");llSetTimerEvent(0.0);}}    timer(){if (llGetAgentInfo(llGetOwner()) & AGENT_WALKING){state walking;}}}state walking{state_entry(){llSetTimerEvent(0.2);llLoopSound("uuid",1.0);}timer(){if (!(llGetAgentInfo(llGetOwner()) & AGENT_WALKING)){state default;}}}

 

Link to comment
Share on other sites

With this script sound can be toggled when walking and not walking
It will only play the sound when walking

integer toggle;default{    state_entry()    {        llStopSound();        llSetTimerEvent(0.2);    }    touch_end( integer num )    {        toggle = !toggle;        if ( toggle ) llOwnerSay("Sound set ON");        else llOwnerSay("Sound set OFF");    }    timer()    {        if (llGetAgentInfo(llGetOwner()) & AGENT_WALKING) state walking;    }}state walking{    state_entry()    {        llSetTimerEvent(0.2);        if ( toggle ) llLoopSound("uuid",1.0);        else llStopSound();    }    touch_end( integer num )    {        toggle = !toggle;        if ( toggle ) llLoopSound("uuid",1.0);        else llStopSound();    }    timer()    {        if (!(llGetAgentInfo(llGetOwner()) & AGENT_WALKING)) state default;    }}

 It will remember the sound setting from one walk to the next

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4198 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...