Tuesday, December 02, 2008
USERLOGIN PASSWORD Remember?
You are here » Learning Center ยป Forums

Openlife Forums

 Openlife Grid Forums
Minimize
 
  Openlife Forums  Scripting  LSL Discussion  Maccas slider script
Previous Previous
 
Next Next
New Post 6/23/2008 4:59 AM
Online now... Capt Macca
136 posts
Openlife Handyman




Maccas slider script 
Modified By Capt Macca  on 6/23/2008 5:05:01 AM)

Used the idea from Pratyeka's sliding door script and use Description field to hold the open/close data.

This seems to work while linked and across resets but could use some testing. I know it's not "good" code but I'm not a good coder.

Try this and improve it for all.


//June 2008
//Macca Rox's version
//---/---/---/------------------------------------------//_______________________>>
vector      DIST    = <0,-0.3,0.0>; //set movement amount and direction. Use a minus for reverse
float       SLEEP       = 0.2;      //set time between movements
//float       VOLUME      = 0.8;      // sound volume, 1.0 loudest, 0.0 to disable sound
//key         SOUND_OPEN  = "";
//key         SOUND_CLOSE = "";
vector      Pos;//Get the prims position
//---/---/---/------------------------------------------//_______________________>>
open()
{
         //llTriggerSound(SOUND_OPEN, VOLUME);
         Pos = llGetPos();
         llSetPos(llGetLocalPos() + DIST); //Add or remove these pairs for more or less steps
         llSleep(SLEEP);
         llSetPos(llGetLocalPos() + DIST);
         llSleep(SLEEP);
         llSetPos(llGetLocalPos() + DIST);
         llSleep(SLEEP);
         llSetPos(llGetLocalPos() + DIST);
         //llWhisper(0,"Opened");
         llSetObjectDesc("1"); //Sets object Description for open position
}
close()
{
         //llTriggerSound(SOUND_CLOSE, VOLUME);
         Pos = llGetPos();
         llSetPos(llGetLocalPos() - DIST);
         llSleep(SLEEP);
         llSetPos(llGetLocalPos() - DIST);
         llSleep(SLEEP);
         llSetPos(llGetLocalPos() - DIST);
         llSleep(SLEEP);
         llSetPos(llGetLocalPos() - DIST);
         //llWhisper(0,"Closed");
         llSetObjectDesc("0");//Sets object Description for close position
}
//---/---/---/------------------------------------------//_______________________>>
default
{
    state_entry()
    {
        if(llGetObjectDesc()=="") llSetObjectDesc("0"); // if any, initialize Object's Description as storage variable
    }  
    on_rez(integer start_param)
    {
        llResetScript();
    }
    changed(integer change)
    {
        if(change & CHANGED_OWNER) //Check for a new owner
        llResetScript();
    }
   
      
    touch_start(integer total_number)
    {   
        if(llGetObjectDesc()=="0")
        {
            open();
        }
        else if(llGetObjectDesc()=="1")
        {           
            close();
        }
     }
  
}

 


Captain of my realm... Rox (Goes off to make a new cap) Happy Gridding...
 
Previous Previous
 
Next Next
  Openlife Forums  Scripting  LSL Discussion  Maccas slider script
Privacy Statement | Terms Of UseAll Rights Reserved 2007,2008 3DX - Openlifegrid.com