Page 5 of 9

Re: Scripts Library

Posted: Mon Mar 24, 2014 6:54 pm
by Kayaker Magic
I wrote this cannon ball script that explodes when it hits land or other prims. But it just sank to the bottom of the water and exploded on the bottom. So I added a test while flying to detect when it crosses the boundary from air to water, calculate the intersection with the water, and put in a water splash particle blue/white explosion in that location! Using Nickola Martynov's cannon script (with a few improvements) I have been firing at my friend's sailing ships. The water explosion makes it easy to predict which way to change the cannon angle (I'm just using the build tools to aim) and when you hit the ship, the explosion turns orange! Too much fun!

Code: Select all

    // cannon ball with effects
//
//    This cannon ball explodes when it hits land or a prim
//    and makes a splash when it passes through water
//    NOTE: to prevent it from exploding at the munitions factory (in my hands)
//        it has a safety: It won't explode unless it is rezzed with 1 in the last
//        parameter of llRezObject()
//    Wwittenby Kayaker Magic
//        I hereby give this code away without restrictions
//        use it for whatever, even put it in products for sale
//        all I ask is that you think kindly of me.
//
integer mode=0;  //mode for using timer, 0 is flying, 1 is dying
vector last;    //where I was last tick

explode()        //used when colliding with land or other prims
{
    if (llGetStartParameter()==0) return;       //check the safety
    llSetStatus(STATUS_PHYSICS,FALSE);        //stop where you are
                llSetLinkPrimitiveParamsFast(LINK_THIS,[
                    PRIM_ROTATION,ZERO_ROTATION,    //rotate to 0 so the particle explosion goes up
                    PRIM_COLOR, 0, <0,0,0>, 0.0    //become invisible, so they only see particles
                ]);
    llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION,ZERO_ROTATION]);
    llSetStatus(STATUS_PHANTOM,TRUE);
                    //rotate to 0 so the particle explosion goes up
    llPlaySound("boom",1.0);            //explosion sound
    llParticleSystem([                //explosion particles
        PSYS_PART_FLAGS, PSYS_PART_INTERP_COLOR_MASK|PSYS_PART_INTERP_SCALE_MASK|PSYS_PART_WIND_MASK,
        PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,
        PSYS_SRC_BURST_RADIUS, 0.2,
        PSYS_SRC_ANGLE_BEGIN, 0.0,
        PSYS_SRC_ANGLE_END, 0.4,
        PSYS_PART_START_COLOR, <1,0.5,0>,        //start orange
        PSYS_PART_END_COLOR, <0,0,0>,            //fade to black
        PSYS_PART_START_ALPHA, 1.0,                //start opaque
        PSYS_PART_END_ALPHA, 0.0,                //fade to transparent
        PSYS_PART_START_SCALE, <0.5,0.5,1>,     //start small
        PSYS_PART_END_SCALE, <4.0,4.0,1>,       //end big
        PSYS_SRC_TEXTURE,"",                    //default texture
        PSYS_SRC_MAX_AGE, 0.2,                    //explosion emits for only this long
        PSYS_PART_MAX_AGE, 5.0,                    //each particle lives this long
        PSYS_SRC_BURST_RATE, 0.02,                //a value of 0 here "starves" other emitters
        PSYS_SRC_BURST_PART_COUNT, 20,            //how many per burst
        PSYS_SRC_ACCEL, <0,0,-4.0>,                //make them fall back down
        PSYS_SRC_BURST_SPEED_MIN, 6.0,            //how fast they jump
        PSYS_SRC_BURST_SPEED_MAX, 8.0
    ]);
    llSetTimerEvent(2);        //give the particles time to happen
    mode=1;                    //then die
}

default
{
    state_entry()
    {
        llOwnerSay("reset");
        llSetStatus(STATUS_PHYSICS,TRUE);    //in case you forgot to do this
        llSetStatus(STATUS_PHANTOM,FALSE);
        llParticleSystem([]);        //turn off any old particles
    }
    on_rez(integer armed)
    {
        llSetTimerEvent(0);     //don't want an old one going off
        if (armed>0)            //only work when fired with a parameter
        {
            llSetTimerEvent(0.09);  //check often for water
            mode=0;
            last=llGetPos();    //record the starting position
        }
    }
    timer()
    {
        if (llGetStartParameter()==0) return;       //check the safety
        if (mode==0)        //still flying, check for water
        {
            float wat=llWater(ZERO_VECTOR);        //how high the water is
            vector pos=llGetPos();                //where cannon ball is now
            if (last.z>wat && pos.z<=wat)        //did I pass through the water surface?
            {
                llSetStatus(STATUS_PHYSICS,FALSE);        //stop where you are
                                //interpolate your position back to water's surface
                pos=last+(pos-last)*(last.z-wat)/(last.z-pos.z);
                llSetLinkPrimitiveParamsFast(LINK_THIS,[
                    PRIM_ROTATION,ZERO_ROTATION,    //rotate to 0 so the particle explosion goes up
                    PRIM_POSITION,pos,              //sit on the surface
                    PRIM_COLOR, 0, <0,0,0>, 0.0    //become invisible, so they only see particles
                ]);
                llSetStatus(STATUS_PHANTOM,TRUE);
                llPlaySound("boom",1.0);        //splash sound
                llParticleSystem([                //explosion particles
                    PSYS_PART_FLAGS, PSYS_PART_INTERP_COLOR_MASK|PSYS_PART_INTERP_SCALE_MASK|PSYS_PART_WIND_MASK|PSYS_PART_EMISSIVE_MASK ,
                    PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,
                    PSYS_SRC_BURST_RADIUS, 0.2,
                    PSYS_SRC_ANGLE_BEGIN, 0.0,
                    PSYS_SRC_ANGLE_END, 0.4,
                    PSYS_PART_START_COLOR, <0.125,.25,.35>,    //start aquamarine
                    PSYS_PART_END_COLOR, <1,1,1>,            //fade to white
                    PSYS_PART_START_ALPHA, 1.0,                //start opaque
                    PSYS_PART_END_ALPHA, 0.0,                //fade to transparent
                    PSYS_PART_START_SCALE, <0.5,0.5,1>,     //start small
                    PSYS_PART_END_SCALE, <4.0,4.0,1>,       //end big
                    PSYS_SRC_TEXTURE,"",                    //default texture
                    PSYS_SRC_MAX_AGE, 0.3,                    //explosion emits for only this long
                    PSYS_PART_MAX_AGE, 5.0,                    //each particle lives this long
                    PSYS_SRC_BURST_RATE, 0.02,                //a value of 0 here "starves" other emitters
                    PSYS_SRC_BURST_PART_COUNT, 20,            //how many per burst
                    PSYS_SRC_ACCEL, <0,0,-4.0>,                //make them fall back down
                    PSYS_SRC_BURST_SPEED_MIN, 6.0,            //how fast they jump
                    PSYS_SRC_BURST_SPEED_MAX, 8.0
                ]);
                llSetTimerEvent(2);        //give the particles and sound time to happen
                mode=1;                    //then die
            }
            last=pos;        //record this position for next test
        }
        else    //mode 1, die when the timer happens now.
        {
            llDie();
        }
    }
    collision_start(integer num)
    {
        explode();
    }
    land_collision_start( vector pos )
    {
        explode();
    }
}
Note that the cannot must fire it with the "safety off", or a 1 in the last argument to llRezObject. I also moved the rezzing point of the ball to be 2 meters from the center of the cannon, in the direction it is facing. That keeps it from exploding when it appears. If your cannon is longer than 4 meters, you will have to up that number. Here is the modified cannot script:

Code: Select all

    default
    {
        touch_start(integer cannon)
        {
            string floater = llGetInventoryName(INVENTORY_OBJECT, 0);
            vector power=<0,0,25>*llGetRot();
            llRezObject(floater,llGetPos()+<0,0,2>*llGetRot(),power,llGetRot(),1); //safety off!
        }
    }

visitor greeter and logger and other options

Posted: Mon Mar 31, 2014 4:06 pm
by Constance Peregrine
I just saw this on the OSG forums, tested it here, and it appears to work. There are several options, one of which is an auto invite to the prims set group, but they note it may be buggy, and in my short test it seems this is true...it could be, however if another avie dropped in my region they would get the invite but I don't like asking ppl to do such things, so for those who do, do it, if you like-))

It can also give a notecard, a landmark, and your own customized greeting...all of which are modifiable or you can just choose not to use some.

Read the comments in the script closely and seek someone's advice [not me, oh no, not me] if you run into issues or have questions.

Code: Select all

// BASIC REGION GREETER SCRIPT - OSSL
// by Mata Hari/Aine Caoimhe March 2014
//
// This is written specifically for Posh and Doro but can easily be adapted/customized for other purposes. It will:
//  - Greet someone when they first enter the region and (optionally) give them a "welcome notecard". Only that avi will see the message (uses llRegionSayTo(UUID) to send)
//    the message. The notecard is only given on the very first recorded visit to the sim by that avi. After that, they'll be greeted with a welcome back message instead
//  - Log (in a notecard) a complete list of the avatars who have visited the sim and the date (and optionally time) of their most recent arrival
//  - Optionally invite a first-time visitor to join a specified Group.
//  - When the owner touches the prim that contains this script she/he will be given a notecard that lists everyone who has visited the region and the date (and optionally time)
//  of their mostrecent visit.
//
// NOTES:
//  - The name that will display as the sender in messages is the name of the prim that contains this script so give the prim a "friendly" meaningful name.
//  - The visitor log is sorted in the order of most recent visit to oldest, so the people at the top of the list are the latest ones to arrive in the region
//    even if thier first visit was a long time ago.
//  - Date (and time if you use that option) is based on the UTC time zone so it's roughly Greenwich Mean Time except doesn't have daylight savings time applied to it.
//
// REQUIRED: The following OSSL script functions must be enabled for the script-owner:
//      - osGetAvatarList       -- used to detect who is in the region
//      - osKey2Name            -- used to correctly retrieve owner's name
//      - osGetNotecard         -- used to retrive visitor log data
//      - osMakeNotecard        -- used to store visitor log data
//      - osIsNpc               -- used to check whether a detected agent in the region is "real" or an NPC so we don't message NPCs or try to give them notecards :p
//      - osInviteToGroup       -- only needed if you enable the invite to group flag in the USER SETTINGS section
//
// USER SETTINGS:
// set the following variable to whatever values suit your needs
//
string visitorLogNotecard="visitor log for Miney Kitely region";
// visitorLogNotecard is the name to use for the notecard that stores the information about avatars who have visited the region. If the notecard doesn't exist
// it will be created automatically for you. New visitors are automatically added to the notecard to keep a running log of all the people who have ever come
// to your region. If you delete this notecard it's like resetting your log and all avatars who visit the region will be greeted again as though it's their
// first visit so don't deleted it unless you want that to happen. The script reads the names from the card each time the region starts or if the script is
// restarted (that's how it knows who it has already welcomed for the first time). If you restart the script, anyone currently in the region will be welcomed
// again so I'd recommend you not do this very frequently (there really shouldn't be any need to).
//
integer includeTimes=FALSE;
// includeTimes can be set to either TRUE or FALSE (must be capital letters). If set to true, the notecard will contain both date and time of their most recent visit
// but if set to FALSE it will only show the date (I find it easier to read with just the date).
//
string welcomeFirstTimeMessage = "Welcome, INSERT_NAME. Thank you for visiting my region in Kitely";
// welcomeFirstTimeMessage is only said to the avatar the very FIRST time they visit the region (or if you've deleted the visitor log). Must be enclosed in quotes.
// if you include the string INSERT_NAME in the message, it will be replaced with the name of the avatar. In the message I added as default, if I visited
// the region it would say "Welcome, Mata Hari. Thank you for visiting my region in OSG" to me the first time I went there.
// Note: if you set the script to invite first-time visitors to join a group. make sure your welcome message encourages them to do so.
//
string welcomeBackMessage = "Welcome back to my Kitely region, INSERT_NAME. Please enjoy your stay!";
// welcomeBackMessage is the message that gets sent to the avatar on all subsequent visits (even days later). Again, the string INSERT_NAME will be replaced with the avi name
// so if I returned to the region it would say "Welcome back, Mata Hari. Please enjoy your stay!"
//
float checkTime=30.0;
// checkTime is how often (in seconds) to check whether someone new has arrived in the region. This is the longest possible time it can be between their arrival and the script 
// detecting it but will often be faster. I set a default of 30 seconds because it often takes this long for someone to arrive, rez, and start to have the sim rez around them.
// If you want the sim to feel a little more "responsive" to new arrivals try shortening it to only 10 or 15 seconds but avoid very short times (less than 5 seconds) since it
// will result in unnecessary sim resource usage to do checks this frequently.
// FYI this also has a second purpose....if an avatar that was previously welcomed to the region is no longer detected during this check it is flagged as having left so when it
// returns to the region it will be welcomed back. Sommeone who logs out and back in very quickly might not be welcomed back (and doesn't need to be).
// 
string welcomeNotecard="";
string welcomeLandmark="";
// welcomeNotecard amd welcomeLandmark are the exact names of a notecard and/or a landmark in the prim's inventory that you want given to a first-time visitor. If the string is
// empty (you leave it at "") it won't try to give anything, otherwise it will try to give that object if it can find it in the prim's inventory. If you only want to give
// a notecard, leave welcomeLandmark at "", or if you only want to give a landmark then leave welcomeNotecard at "". Default is to give nothing at all.
// Note that giving something to an avatar causes the script to stop working for 2 seconds so don't hand out stuff that isn't needed.
// 
integer inviteToGroup=TRUE;
// inviteToGroup can either be TRUE or FALSE (must be capital letters). If set to TRUE, a first-time visitor to your region will be invited to join the same group that prim is
// set to (so if you enable this, make sure the prim's group is set correctly!). I'm not 100% sure how the OSSL function checks group permissions so it's probably safest to
// make sure that you have group permissions set to allow you to invite people and to allow people to join any time (not just by invitation). It might work with different group
// permission settings though...you'd have to experiment. If set to FALSE, no group invitation is sent.
//
integer notifyOwner=TRUE;
// notifyOwner can either be TRUE or FALSE (must be capital letters). If set to TRUE, when someone arrives in the region and you are also in the region, you will be notified
// in general chat (but only you will be able to see it).
//
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
// # # # DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!! # # # 
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
list visitorLog=[];     // timestamp|name|UUID
list regionLog=[];      // UUID|pos|name

welcome(key who,string name)
{
    // called when a new key is detected in the region
    // skip if this is the UUID of an NPC
    if (osIsNpc(who)) return;
    // find the index of the visitor in the visitor log
    integer visitorIndex=llListFindList(visitorLog,[who]);
    string strToSay=welcomeBackMessage;        // welcome message we're going to send - set to welcome back as default
    if (visitorIndex==-1)
    {
        // this is a first time visitor and needs to be added to the visitor log
        if (includeTimes) visitorLog+=[llGetTimestamp()];  // user wants timestamp
        else visitorLog+=[llGetDate()];                    // user just wants data
        visitorLog+=[name,who];
        // and we want to send the first-time visitor message instead of the welcome back one
        strToSay=welcomeFirstTimeMessage;
        // don't send anything to them yet though....need to wait until we've sent the welcome message
    }
    else
    {
        // this is a repeat visitor so we need to update the timestamp instead
        if (includeTimes) llListReplaceList(visitorLog,[llGetTimestamp()],visitorIndex-2,visitorIndex-2);   // user wants timestamp
        else llListReplaceList(visitorLog,[llGetDate()],visitorIndex-2,visitorIndex-2);                     // user just wants date
    }
    // sort the list and then store it
    visitorLog=llListSort(visitorLog,3,FALSE);
    if (llGetInventoryType(visitorLogNotecard)==INVENTORY_NOTECARD)
    {
        llRemoveInventory(visitorLogNotecard);
        llSleep(0.2);   // need to delay briefly to give it time to remove the old one
    }
    // build new string to store
    string strToStore;
    integer i;
    integer l=llGetListLength(visitorLog);
    while (i<l)
    {
        strToStore+=llDumpList2String(llList2List(visitorLog,i,i+2),"|") + "\n";        // can't use tabs to store and format nicely because names could include 4 spaces which is treated as a tab
        i+=3;
    }
    //store it
    osMakeNotecard(visitorLogNotecard,strToStore);
    // now send welcome message to the avi after parsing it to replace INSERT_NAME with the name
    while (llSubStringIndex(strToSay,"INSERT_NAME")>-1)
    {
        integer ind=llSubStringIndex(strToSay,"INSERT_NAME");
        strToSay=llDeleteSubString(strToSay,ind,ind+10);
        strToSay=llInsertString(strToSay,ind,name);
    }
    llRegionSayTo(who,0,strToSay);
    // if owner wants to be notified of visitors, send message (as long as it's not the owner being greeted)
    if (notifyOwner && (who!=llGetOwner()) && (llGetAgentSize(llGetOwner())!=ZERO_VECTOR)) llRegionSayTo(llGetOwner(),0,name+" has entered the region and been greeted");
    // if this is a first-time visitor we also may need to send a notecard and/or a landmark and/or a group invite
    if (visitorIndex==-1)
    {
        if ((welcomeNotecard!="") && (llGetInventoryType(welcomeNotecard)==INVENTORY_NOTECARD)) llGiveInventory(who,welcomeNotecard);
        if ((welcomeLandmark!="") && (llGetInventoryType(welcomeLandmark)==INVENTORY_LANDMARK)) llGiveInventory(who,welcomeLandmark);
        if (inviteToGroup)
        {
            key groupKey=llList2Key(llGetObjectDetails(llGetKey(),[OBJECT_GROUP]),0);
            if (groupKey==NULL_KEY) llOwnerSay("Cannot send a group invite because there is no group set for this prim");
            else osInviteToGroup(who);
        }
    }
}
default
{
    state_entry()
    {
        // zero the running visitor log and then read the stored notecard from memory if it exists to get previous visitors
        string logData;
        visitorLog=[];
        if (llGetInventoryType(visitorLogNotecard)==INVENTORY_NOTECARD) logData=osGetNotecard(visitorLogNotecard);
        visitorLog=llParseString2List(logData,["|","\n"],[]);
        visitorLog=llListSort(visitorLog,3,FALSE);
        // zero the in-region log as well
        regionLog=[];
        // start the timer
        llSetTimerEvent(checkTime);
    }
    on_rez(integer start)
    {
        // on first rez remove any existing visitor log
        if (llGetInventoryType(visitorLogNotecard)==INVENTORY_NOTECARD) llRemoveInventory(visitorLogNotecard);
        llResetScript();
    }
    changed (integer change)
    {
        // restart if the owner changes or any time the region is restarted
        if (change & CHANGED_OWNER)
        {
            // on owner change remove any existing visitor log
            if (llGetInventoryType(visitorLogNotecard)==INVENTORY_NOTECARD) llRemoveInventory(visitorLogNotecard);
            llResetScript();
        }
        else if (change & CHANGED_REGION_START) llResetScript();
    }
    touch_start(integer num)
    {
        if (llDetectedKey(0)!=llGetOwner()) return;
        if (llGetInventoryType(visitorLogNotecard)==INVENTORY_NOTECARD)
        {
            llOwnerSay("Sending you the up to date visitor log");
            llGiveInventory(llGetOwner(),visitorLogNotecard);
        }
        else llOwnerSay("ERROR! I could not find a stored visitor log in the prim's inventory. Did you delete it by mistake?");
    }
    timer()
    {
        // update the region log to reflect who is currently in the region. OSSL function doesn't include owner so also add her/him if present
        list oldRegionLog=regionLog;
        regionLog=osGetAvatarList();
        if (llGetAgentSize(llGetOwner())!=ZERO_VECTOR) regionLog+=[llGetOwner(),<1,2,3>,osKey2Name(llGetOwner())];   // we don't do anything with position so just give it any value
        // see if anyone new is in the updated log
        integer checking;
        integer stop=llGetListLength(regionLog);
        while (checking<stop)
        {
            key who=llList2Key(regionLog,checking); // UUID of person to check against the old log
            if (llListFindList(oldRegionLog,[who])==-1) welcome(who,llList2String(regionLog,checking+2));    // not in previous log so welcome them by passing UUID and name to UDF
            checking +=3;   // stride of the regionLog list
        }
    }
}

scripts cornucopia

Posted: Fri Apr 04, 2014 7:29 am
by Constance Peregrine
Some or many of these may be SL specific, have fun checking them out tho-))

http://metaverse.mitsi.com/cgi/freescripts.plx

hypergate script

Posted: Mon Apr 28, 2014 11:35 am
by Constance Peregrine
from here: http://www.hypergridbusiness.com/2014/0 ... te-script/

Code: Select all

string URL ="http://www.hyperica.com/lookup/?cat="; 

//Cat (category) numbers:
//0: WELCOME
//3: EDUCATION   
//8: RETAIL    
//10: VENUES

string SimAddress;     //the hypergrid address
string SimName;        //the destination region name
string GridName;        //name of the destination's grid
key StatusQuery;        //stores the key for the status request

key httpkey;//This stores the key for the HTTP request we send.
string body_retrieved; // this will hold what is returned from  http request

vector LandingPoint = <128.0, 128.0, 22.0>;
vector LookAt       = <1.0,1.0,1.0>;
 
list LastFewAgents; 


LoadDestination ()      //checks the description for the destination
{
    list Description = llParseString2List(llGetObjectDesc(),[","," "],[]);
    string Category = llList2String(Description,0);
    integer CatNum = 0;
    
    if (llToUpper(Category)=="EDUCATION") CatNum=3;
    if (llToUpper(Category)=="RETAIL") CatNum=8;
    if (llToUpper(Category)=="VENUES") CatNum=10;
    
    URL = URL+(string) CatNum+"&region="+llList2String(Description,1)+"&sort=1";
    
    httpkey=llHTTPRequest(URL, [] ,"");
    llSetText("No destination set.",<1,1,1>,1);
}

CheckDestination ()     //checks if the destination is up
{
    StatusQuery = llRequestSimulatorData(SimAddress, DATA_SIM_STATUS);
}


PerformTeleport( key WhomToTeleport )
{
    integer CurrentTime = llGetUnixTime();
    integer AgentIndex = llListFindList( LastFewAgents, [ WhomToTeleport ] );      // Is the agent we're teleporting already in the list?
    if (AgentIndex != -1)                                                          // If yes, check to make sure it's been > 5 seconds
    {
        integer PreviousTime = llList2Integer( LastFewAgents, AgentIndex+1 );      // Get the last time they were teleported
        if (PreviousTime >= (CurrentTime - 30)) return;                             // Less than five seconds ago? Exit without teleporting
        LastFewAgents = llDeleteSubList( LastFewAgents, AgentIndex, AgentIndex+1); // Delete the agent from the list
    }
    LastFewAgents += [ WhomToTeleport, CurrentTime ];                              // Add the agent and current time to the list
   // llMapDestination(SimAddress, LandingPoint, LookAt);   //teleports via the map
           
    osTeleportAgent( WhomToTeleport, SimAddress, LandingPoint, LookAt );    //teleports instantly, needs OS threat level set to high
                             
}


default
{
    state_entry()
    { 
    
    LoadDestination();      //check the description for the destination
    
     }

    http_response(key id, integer status, list meta, string body)
    {
        body_retrieved = body;
        SimName = llGetSubString(body_retrieved, llSubStringIndex(body,"<!--REGION NAME-->")+18, llSubStringIndex(body, "<!--END REGION NAME-->")-1);
        GridName = llGetSubString(body_retrieved, llSubStringIndex(body,"<!--GRID NAME-->")+16, llSubStringIndex(body, "<!--END GRID NAME-->")-1);
        SimAddress = llGetSubString(body_retrieved, llSubStringIndex(body,"<!--HGURL-->")+12, llSubStringIndex(body, "<!--END HGURL-->")-1);
        llSetText("Hypergate to "+ SimName +" on "+GridName,<1,1,1>,1);

//the following section puts the destination text on the prim
        string CommandList = ""; 
        CommandList = osMovePen( CommandList, 25, 75 );
        CommandList += "FontSize 16;";
        CommandList = osDrawText( CommandList, SimName +" on "+GridName );
        osSetDynamicTextureDataBlendFace( "", "vector", CommandList, "width:256,height:256", FALSE, 2, 0, 255, 3 );
        
        CheckDestination();
        }
        
        
    dataserver(key queryId, string data) //turn gate black of destination is down
    {
        if (data=="up")  llSetColor(<1.000, 1.000, 1.000>,1);
        else llSetColor(<0.067, 0.067, 0.067>,1); 
    }

    touch_start(integer number)
        {    LoadDestination();  }

    collision(integer number)
        {    PerformTeleport( llDetectedKey( 0 ));  }

}

prim up/down

Posted: Mon May 05, 2014 5:17 pm
by Constance Peregrine

Code: Select all

// sensor variables
float sensor_interval = 2.0;    // interval between scans in seconds
float sensor_range = 10.0;        // range in meters
//movement variables
integer sky = 0;
float TOP = 4.6;
float SPEED = 2;
float target;
vector pos;
vector mpos;

default
{
 on_rez(integer start_param) {
        llResetScript();
    }

        state_entry()
    {
        pos = llGetPos();
        if(sky == 0)
        {
            target = pos.z + TOP;
        }
        else
        {
             target = pos.z - TOP;
        }
        llSetTimerEvent(sensor_interval); //Repeats the sensor.
    }
     timer()
    {
        llSensor("",NULL_KEY,AGENT,sensor_range,PI);
    }
      sensor(integer num_detected)
    {
        state moving;
    }   
    touch_end(integer n) 
    {
        state moving;
    }
      state_exit()
    {
        llSetTimerEvent(0.0);        
    }
}

state moving
{
 on_rez(integer start_param) 
    {
       llResetScript();
    }    
    state_entry()
    {
        llSetTimerEvent(1.0); 
    }
    
    timer()
    {
        mpos = llGetPos();
        if( mpos.z!=target )
        {
            if( mpos.z>target )
            {
                mpos.z = mpos.z - SPEED;
            }
            else
            {
                mpos.z = mpos.z + SPEED;
            }
        }
        
        if(  llFabs(mpos.z - target) < SPEED )
        {
            mpos.z = target;   
            llSetPos(mpos);
        
            if(sky == 0)
            {
                sky = 1;
                target = pos.z;
            }
            else
            {
                sky = 0;
                llSetTimerEvent(0.0);
                state default;
            }
        }   
        llSetPos(mpos);
    }
}


Re: Scripts Library

Posted: Mon May 05, 2014 7:00 pm
by Spiral Silverstar
Hmmmm.....well, sort of. I only want it to move one meter up and down. When I try to change parameters, it only cycles One time, and only when I click on it.... Sorry, but I know practically zilch about scripting. Also, it has a script run-time of 2.8 ms!

Re: Scripts Library

Posted: Mon May 05, 2014 8:43 pm
by Constance Peregrine
Spiral Silverstar wrote:Hmmmm.....well, sort of. I only want it to move one meter up and down. When I try to change parameters, it only cycles One time, and only when I click on it.... Sorry, but I know practically zilch about scripting. Also, it has a script run-time of 2.8 ms!
There are scripters here, but I am not one of them...but perhaps Graham's helped.

intermittent sound

Posted: Wed May 28, 2014 11:06 pm
by Constance Peregrine

Code: Select all

// Script Name: Sound_Prim_Script_-_Intermittent.lsl
// Author: Anonymous
//Intermittent sound play

// Downloaded from : http://www.free-lsl-scripts.com/cgi/freescripts.plx?ID=1156

// This program is free software; you can redistribute it and/or modify it.
// Additional Licenes may apply that prevent you from selling this code
// and these licenses may require you to publish any changes you make on request.
//
// There are literally thousands of hours of work in these scripts. Please respect
// the creators wishes and Copyright law and follow their license requirements.
//
// License information included herein must be included in any script you give out or use.
// Licenses may also be included in the script or comments by the original author, in which case
// the authors license must be followed, and  their licenses override any licenses outlined in this header.
//
// You cannot attach a license to any of these scripts to make any license more or less restrictive.
//
// All scripts by avatar Ferd Frederix, unless stated otherwise in the script, are licensed as Creative Commons By Attribution and Non-Commercial.
// Commercial use is NOT allowed - no resale of my scripts in any form.  
// This means you cannot sell my scripts but you can give them away if they are FREE.  
// Scripts by Ferd Frederix may be sold when included in a new object that actually uses these scripts. Putting my script in a prim and selling it on marketplace does not constitute a build.
// For any reuse or distribution, you must make clear to others the license terms of my works. This is done by leaving headers intact.
// See http://creativecommons.org/licenses/by-nc/3.0/ for more details and the actual license agreement.
// You must leave any author credits and any headers intact in any script you use or publish.
///////////////////////////////////////////////////////////////////////////////////////////////////
// If you don't like these restrictions and licenses, then don't use these scripts.
//////////////////////// ORIGINAL AUTHORS CODE BEGINS ////////////////////////////////////////////

// CATEGORY:Sound
// DESCRIPTION:Intermittent sound play
// ARCHIVED BY:Ferd Frederix


// Sound Prim Script - Intermittent
//
// Randomly picks a sound in contents, plays it,
// waits a random interval, repeats.
//
// Set this between 0.0 and 1.0
float LOUDNESS = 1.0;
//
// Interval in seconds to be silent.
// If you set these to be less than 10 seconds,
// they default to 10 seconds.
integer SHORTEST = 10;
integer LONGEST = 40;
//
////////////////////////////////////////////////
default
{

state_entry()
{
    if (SHORTEST < 10 )     SHORTEST = 10;
    if (LONGEST < 10 )      LONGEST = 10;
    if (SHORTEST > LONGEST) SHORTEST = LONGEST;

    llSleep( 1.0 );    
    state noisy;
}

on_rez(integer start_param)
{
    llSleep( 1.0 );
    state noisy;
}

}
////////////////////////////////////////////////
state noisy
{

state_entry()
{
    integer sounds = llGetInventoryNumber(INVENTORY_SOUND);

    if ( sounds <= 0 ) state default;

    string soundname = llGetInventoryName( INVENTORY_SOUND, llFloor(llFrand(sounds)) );
    if ( soundname != "" )
    {
        llPlaySound( soundname, LOUDNESS );
    }
    
    state silent;
}

on_rez(integer start_param)
{
    state default;
}

}
////////////////////////////////////////////////
state silent
{

state_entry()
{    
    llSleep( (float)(llFloor(llFrand(LONGEST - SHORTEST)) + SHORTEST) );
    state noisy;
}

on_rez(integer start_param)
{
    state default;
}

}

// END //



HG coordinates...

Posted: Tue Jun 03, 2014 11:23 pm
by Constance Peregrine
put in prim and wear and touch wherever u go....I think this is what u want Freda

Code: Select all

//WHEREAMI SCRIPT

// Hacked together on 4/15/2012 by Pathfinder Lester (http://about.me/pathfinder)
// based on code by Jeff Kelley's excellent HGBoard.
// When object is touched, it will say current Hypergrid coordinates.

    default
{
    state_entry()
    {
        llSay(0, "Script running");
    }
         touch_start(integer total_number)
    {
    vector regionCoor = llGetRegionCorner();
    regionCoor = regionCoor / 256;
    string gridX = (string)llFloor(regionCoor.x);
    string gridY = (string)llFloor(regionCoor.y);
  llSay(0, "Current Hypergrid Coordinates: " + gridX + "," + gridY);   
}
}


Re: Scripts Library

Posted: Tue Jun 03, 2014 11:58 pm
by Freda Frostbite
Thanks! I will give this a try tomorrow.