Physics Watcher Script

Expired

// Sometimes when crossing sim borders, physics will spontaneously be removed from a vehicle.
// This script re-enables physics if that happens.

integer active = TRUE;

default {
    state_entry() {
        //llListen(0, "", NULL_KEY, "brake");
        //llListen(0, "", NULL_KEY, "b");
        llSetTimerEvent(1.0);
    }

    timer() {
        if (active) {
            if (llAvatarOnSitTarget() == llGetOwner()) {
                if (!llGetStatus(STATUS_PHYSICS)) {
                    llSleep(1.0);
                    llSetStatus(STATUS_PHYSICS, TRUE);
                }
            } else {
                active = FALSE;
                llSetTimerEvent(0.0);
            }
        } else {
            llSetTimerEvent(0.0);
            llSetStatus(STATUS_PHYSICS, FALSE);
        }
    }
    
    listen(integer channel, string name, key id, string message) {
        string myMessage = llToLower(message);
        if (id == llGetOwner()) {
            if (myMessage == "b" || myMessage == "brake") {
                if (active) {
                    active = FALSE;
                    llWhisper(0, "Emergency brake engaged! Say 'b' in chat to resume flight.");
                } else {
                    active = TRUE;
                    llSetTimerEvent(1.0);
                    llWhisper(0, "Emergency brake disengaged.");
                }
            }
        }
    }
    
    link_message(integer sender, integer num, string message, key id) {
        if (message == "throttle" || message == "engines on") {
            if (message == "throttle" && active == FALSE) {
                llWhisper(0, "Emergency brake disengaged.");
            }
            active = TRUE;
            llSetTimerEvent(1.0);
        }
    }
}

 

Mouse

Expired

vector last_vel;
vector last_pos;
integer STAYING = 1;
integer FOLLOWING = 2;
integer mouse_state = FOLLOWING;
integer total = 0;

play_sound()
{
    integer num = llGetInventoryNumber(INVENTORY_SOUND);
    integer rand = (integer)(llFrand(num));
    llTriggerSound(llGetInventoryName(INVENTORY_SOUND, rand), 1.0);
}

default
{
    on_rez(integer p)
    {
        llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
        llSetStatus(STATUS_DIE_AT_EDGE | STATUS_PHYSICS, TRUE);
        llSensorRepeat("", llGetOwner(), AGENT, 50.0, PI, 5.0);
        llListen(0, "", llGetOwner(), "");
        llSetTimerEvent(1.0);
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if (message == "stay")
        {
            mouse_state = STAYING;
        }
        else if (message == "follow")
        {
            mouse_state = FOLLOWING;
        }
    }

    sensor(integer total_number)
    {
        llSetTimerEvent(1.0);
        last_vel = llDetectedVel(0);
        last_pos = llDetectedPos(0);
        vector direction = last_pos - llGetPos();
        float distance = llVecMag(direction);
        direction = llVecNorm(direction);
        float frot = llFrand(TWO_PI);
        rotation rot = llEuler2Rot(<0,0,frot>);
        llRotLookAt(rot, 0.1, 0.1);
        if (llVecMag(last_vel) <0.25)
        {
            last_vel = direction;
        }
        else
        {
            last_vel = llVecNorm(last_vel);
            last_vel.z += 1.0;   
        }
        if (distance > 10.0)
        {
            direction += last_vel;
            direction.z += 3.0;
        }
        else if (distance > 2.0)
        {
            direction.z += 1.0;
            direction *= 0.75;
        }
        else
        {
            direction = <0,0,1>;
        }
        if (mouse_state == FOLLOWING)
            llApplyImpulse(direction*0.1, FALSE);
        else
            llApplyImpulse(<0,0,0.1>, FALSE);
    }
    
    timer()
    {
        if (total > 10)
        {
            while (llEdgeOfWorld(llGetPos(), last_vel))
            {
                last_vel = ;
            }
            float frot = llFrand(TWO_PI);
            rotation rot = llEuler2Rot(<0,0,frot>);
            llRotLookAt(rot, 0.1, 0.1);
            if (mouse_state == FOLLOWING)
                llApplyImpulse(last_vel*0.1, FALSE);
            else
                llApplyImpulse(<0,0,0.1>, FALSE);
            total = 0;
        }
        else
        {
            total += 1;
            if (llFrand(1.0) > 0.75)
            {
                play_sound();
            }
        }
    }
}

 

Xavier's Gun Control

Expired

// Xavier#s Gun Control Script
// : Master Computer Relay on 2167811067 ( send / receive )
// : Updates guns Friends list on 2167812300 ( transmit list)
// : Receives Gun reply#s on 2166617540 / Set ON/OFF / Confirm list, Confirmed On / Off)

// Init Lists
list Ops = ["Charlie Omega"];
list kos;

integer guns_on = FALSE;

integer talk_channel = 0;

// Function to Talk
talk(integer atchan, string saydis)
{
  if (talk_channel == 0)
  {
  llSay(talk_channel,saydis);
  }
  else
  {
  llShout(talk_channel,saydis);
  }

}   

// Functions to check Ops list
integer isNameOnList( string name, list test )
{
    list single_name_list;
    single_name_list += name;
    
    return (-1 != llListFindList( test, single_name_list ) );
}

// Function Display List Data
display(string test)
{ 
    string textstring = "";
            
    if (test == "OPS")
    {
        textstring = llList2CSV(Ops);
        
      }
    
    if (test == "kos")
    {
        textstring = llList2CSV(kos);
       }
    
    if ( textstring == "" )
    {        
     talk( talk_channel, test + " - Returned no Data");   
    }
    else
    {
         talk( talk_channel, textstring); 
    }
                  
}

// Function Add to Friends List
addlist(string name)
{
   kos += name;
       
}

// Function Kill from kos list
offlist(string name)
{
    
    list single_name_list;
    single_name_list += name;
    
   integer nameat = llListFindList(kos, single_name_list );
   if (nameat > -1)
   {
    kos = llDeleteSubList(kos, nameat,nameat );
   }
   else
   {
            talk( talk_channel, name + " - Invalid Data");
    }   
}

// Function to shout to all Guns
tellgun(string commands)
{

if (commands == "ON" )
{
llShout(2166617540,"GON");
guns_on = TRUE;
}

if (commands == "OFF" )
{
llShout(2166617540,"GOFF");
guns_on = FALSE;
}
    
if (commands == "UPDATE" )
{
string textstring = llList2CSV(kos);
llShout(2167812300, textstring);
}    


} 


status()
{

string report;

if (guns_on == TRUE)
{
    report = " Status - Online"; 
    
}   
else
{
     report = " Status - Offline"; 
} 

talk(talk_channel, report);
    
}


help()
{
    talk(talk_channel,"__________________________________");
    talk(talk_channel,"|                                                                  |");
    talk(talk_channel,"| Combat Computer Options                        |");
    talk(talk_channel,"|--------------------------------------------|");
    talk(talk_channel,"| ADD  - add to kill list                 |");
    talk(talk_channel,"| REMOVE  - remove from kill list |");
    talk(talk_channel,"| LIST ( ops / koss ) - display list                |");
    talk(talk_channel,"| GUNS ( on / off ) - turn guns on / off         |");
    talk(talk_channel,"| GUNS Update - copy friends list to guns   |");    
    talk(talk_channel,"| STATUS - Display current system status    |");
    talk(talk_channel,"|_________________________________|");  
}

default
{
    state_entry()
    {
       llListen(0, "", "", ""); // Local Reception
       llListen(2167811067, "", "", ""); // Relay Reception    
       llListen(2166617540, "", "", ""); // Gun Transmission Reception
    }

        listen(integer channel, string name, key id, string message)
        {

            talk_channel = channel;

            string temp_message = llToUpper(message);
            integer strlong = llStringLength(message);
            
           if( isNameOnList(name,Ops)==TRUE | channel == 2167811067 )
           {
           
               if(llGetSubString(temp_message, 0, 3)=="LIST")
               {
                string test = llGetSubString(temp_message, 5, strlong);
                display(test);
               }
                
               if(llGetSubString(temp_message, 0, 2)=="ADD")
               {
                string test = llGetSubString(message, 4, strlong);
                addlist(test);
                     }                

               if(llGetSubString(temp_message, 0, 5)=="REMOVE")
               {
                string test = llGetSubString(message, 5, strlong);
                offlist(test);
                           }    
                
                 if(llGetSubString(temp_message, 0, 3)=="GUNS")
               {
                string test = llGetSubString(temp_message, 5, strlong);
                tellgun(test);
                           }
                if(llGetSubString(temp_message, 0, 7)=="COMMANDS")
               {
                string test = llGetSubString(temp_message, 5, strlong);
                help();
                
                           }                                     
                if(llGetSubString(temp_message, 0, 5)=="STATUS")
               {
                string test = llGetSubString(temp_message, 5, strlong);
                status();
                
                           } 
                
            } // end commands reception
            
            if (channel == 2166617540)
            {
                llSay(0, name + " - " + message);
                llShout(2167811067, name + " - " + message);
            }
    
        }

}