Difference between revisions of "User:Dantia Gothly"

From Second Life Wiki
Jump to navigation Jump to search
Line 19: Line 19:
Here is a nonphysical train script
Here is a nonphysical train script
<lsl>
<lsl>
//Copyright (C) 2011 Dantia Gothly
http://www.youtube.com/watch?v=UiInBOVHpO8&feature=relmfu
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
////////////////////////////////////////////////////////////////////////////////////////
//                                    (Global Settings)
 
// Door movment:
float T_S2 = 2.0;//timer stopped before opening door.
float Train_leave = 0.8;//how long the train sits after closing the doors and takes off
float Door_open = 10.0;//How long the doors are Open.
integer door1 = 2;//find the link number for the door you want to move.
integer door2 = 3;
float Door_Slid_dist = 3.3;//sets the slide forward distance of the door on the X axis
 
//Math:
integer num = 1;//do math 1+1=__
integer num2 = 1;
 
//Predefined integers etc:
integer i;
integer t;
 
//Train turn timming:
float M_1 = 255;// first turn
float M_2 = 735;//second turn
float M_3 = 1215;//third turn
float M_4 = 1695;//forth turn
 
//Station stop timing:
float W_S = 1920;//start train at west station.
float E_S = 985;//stop at east station.
 
//Speed:(note:If this number changes the turn timming and stops must be changed)
float speed = .20;// Speed controls the PRIM_POSITION
 
//Timers:
float T_S1 = 0.001;//Timer controls the default timer
float Horn_timing = 1.0;//horn sound then door opens/closes.
float door_Open_timing = 1.7;
float door_Close_timing = 2.6;
 
//Sounds:
string Eng = "UUID";//train_motor
string movment = "UUID";//train-going
string Stops = "UUID";//train-breaks
string Horn = "UUID";//train-stand-clear
string DoorOpen = "UUID";//train-door-open
string DoorClose = "UUID";//train-door-close
 
 
//Volume:
float Vol3 = 1.0;// Volume high.
float Vol2 = 0.5;// Volume mid.
float Vol1 = 0.2;// Volume low.
float Vol0 = 0.0;// Volume mute.
 
// default location = <67.797,124.500,33.107>
////////////////////////////////////////////////////////////////////////////////////////
//User defined functions are wonderful
SetLinkPosLocal2Root(integer linknum,vector offset)
{
    llSetLinkPrimitiveParamsFast(linknum, [PRIM_POSITION, ((llList2Vector(
    llGetLinkPrimitiveParams(linknum, [PRIM_POSITION]),0) - llGetPos())/llGetRot())+offset]);
}
/////////////////////////////////////////////////////////////////////////////////////////
default
{
////////////////////////////////////////////////////////////////////////////////////////
    state_entry()
    {
        llSetTimerEvent(T_S1);
        llLoopSound(Eng,Vol3);
        llLoopSound(movment,Vol3);
    }
/////////////////////////////////////////////////////////////////////////////////////////
    timer()
    {
        integer t;
        rotation rot=llGetRot();
       
        num += num2;
        llSetLinkPrimitiveParamsFast(LINK_THIS,
        [PRIM_POSITION, llGetPos()+(< speed,0.0,0.0>*llGetRot())]);
   
        if(num == M_1)
        {
            llSay(0,"in check M_2");
          for(t=0;t<=90;t++)
          {
              llSetLinkPrimitiveParamsFast(LINK_THIS,
              [PRIM_POSITION, llGetPos()+(< speed,0.0,0.0>*llGetRot()),
              PRIM_ROTATION,(rot/llEuler2Rot(<0,0,t>*DEG_TO_RAD))]);
              llSleep(0.04);
            }
        }
        else if (num == M_2)
        {
            llSay(0,"in check M_3");
            for(t=0;t<=90;t++)
          {
              llSetLinkPrimitiveParamsFast(LINK_THIS,
              [PRIM_POSITION, llGetPos()+(< speed,0.0,0.0>*llGetRot()),
              PRIM_ROTATION,(rot/llEuler2Rot(<0,0,t>*DEG_TO_RAD))]);
              llSleep(0.04);
            }
        }
        else if (num == M_3)
        {
            llSay(0,"in check M_4");
          for(t=0;t<=90;t++)
          {
              llSetLinkPrimitiveParamsFast(LINK_THIS,
              [PRIM_POSITION, llGetPos()+(< speed,0.0,0.0>*llGetRot()),
              PRIM_ROTATION,(rot/llEuler2Rot(<0,0,t>*DEG_TO_RAD))]);
              llSleep(0.04);
            }
        }
        else if (num == M_4)
        {
          llSay(0,"in check M_1");
          for(t=0;t<=90;t++)
          {
              llSetLinkPrimitiveParamsFast(LINK_THIS,
              [PRIM_POSITION, llGetPos()+(< speed,0.0,0.0>*llGetRot()),
              PRIM_ROTATION,(rot/llEuler2Rot(<0,0,t>*DEG_TO_RAD))]);
              llSleep(0.04);
            }
        }
        else if(num == W_S)
        {
            num = 0;
            llTriggerSound(Stops,Vol3);
            llLoopSound(movment,Vol0);
            llLoopSound(Eng,Vol1);
            llSetTimerEvent(0.0);
            llSay(0,"At West station");
            state two;
        }
        else if(num == E_S)
        {
            llTriggerSound(Stops,Vol3);
            llLoopSound(movment,Vol0);
            llLoopSound(Eng,Vol1);
            llSetTimerEvent(0.0);
            llSay(0,"At East station");
            state two;
        }         
        llSetText((string)num,<1,1,1>,1.0);
    }
}
///////////////////////////////////////////////////////////////////////////////////////
state two
{
    state_entry()
    {
        llSetTimerEvent(T_S2);
    }
    timer()
    {
        llTriggerSound(Horn,Vol3);
        llSleep(Horn_timing);
        llTriggerSound(DoorOpen,Vol3);
        llSleep(door_Open_timing);
        SetLinkPosLocal2Root(door1,<Door_Slid_dist,0.0,0.0>);
        SetLinkPosLocal2Root(door2,<Door_Slid_dist,0.0,0.0>);
        llSleep(Door_open);
        llTriggerSound(Horn,Vol3);
        llSleep(Horn_timing);
        llTriggerSound(DoorClose,Vol3);
        llSleep(door_Close_timing);
        SetLinkPosLocal2Root(door1,<-Door_Slid_dist,0.0,0.0>);
        SetLinkPosLocal2Root(door2,<-Door_Slid_dist,0.0,0.0>);
        llSleep(Train_leave);
 
        state default;
    }
}
</lsl>
</lsl>



Revision as of 23:47, 27 March 2011

Dans open source scripts

Hello there! I'm Dantia Gothly

Scripter,Sculpter,Texture artist.

creater of TopHat Viewer link->(http://terminalproxy.com/)

I believe you can do just about everything in 1 script

but that also depends on what it is your doing. For the most part it can be.


quote:"dose it work? Yes it do."

..........................................................................................................................

Here is a nonphysical train script <lsl> http://www.youtube.com/watch?v=UiInBOVHpO8&feature=relmfu </lsl>

This is a good way to do Random llRezObject.

<lsl> integer i;

DGRandomRez(float number) {

   for(i=(integer)llFrand(number);i>0;i--)
   {
       llRezObject("Object", llGetPos() + <0.0,0.0,1.0>, <llFrand(3.0),llFrand(3.0),llFrand(3.0)>, <0.0,0.0,llFrand(360),1.0>, 0);   
   }  

}

default {

  state_entry()
  {
     DGRandomRez(5);//This will rez an object at random 1-5.
  }

}

</lsl> Sound looper for when your walking. <lsl> float Timer = 1; integer Sound = 1;//what sound to play. float Vol = 0.8; integer GLL; list Sounds = ["","","","",""];//List of sounds. default {

   state_entry()
   {
       GLL = llGetListLength(Sounds);
       llSetTimerEvent(Timer);
       integer Q;
       
       for(Q=0;Q<GLL;Q++)//Preload sounds!
       {
           llPreloadSound((string)llList2Key(Sounds,Q));
       }
   }
   timer()
   {
       if((llGetAgentInfo(llGetOwner()) & AGENT_WALKING))
       {
           llLoopSound((string)llList2Key(Sounds,Sound),Vol);//single sound;
           //or you can use this for random sounds.
           llLoopSound((string)llList2Key(Sounds,(integer)llFrand(GLL)),Vol);//Random sound.
       }
       else
       {
           llStopSound();
       }
   }

} </lsl>