Bike+Tour+Script


 * //UCSL Bike Tour Script by: Ryon Bloobury//**

code // University of Cincinnati Bike Tour Script // Created by Ryon Bloobury // Distributed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License // http://creativecommons.org/licenses/by-nc-sa/3.0/

vector AXIS_FWD = <1,0,0>; rotation getRotToPointAxisAt(vector axis, vector target) { return llGetRot * llRotBetween(axis * llGetRot, target - llGetPos); }

float SPEED = 1.4; vector target; list waypoints; integer currentWaypoint; string message;

string notecardName = "Tour Waypoints v2"; key notecardQuery; integer notecardIndex;

integer nextWayPoint {   if ( currentWaypoint >= llGetListLength (waypoints) ) {       llWhisper( 0,"The Tour has come to an end"); llSleep(10); llDie; return TRUE; }   else {       target = llList2Vector (waypoints, currentWaypoint); message = llList2String (waypoints, currentWaypoint + 1); currentWaypoint += 2; return FALSE; } }

default {   state_entry {      llSleep(15); llWhisper(0, "Loading Waypoints....."); notecardIndex = 0; notecardQuery = llGetNotecardLine (notecardName, notecardIndex++ );

}

dataserver ( key query_id, string data) {       if ( notecardQuery == query_id) {           if (data == EOF) {           llWhisper (0, "Data is loaded, and we're off!"); state waiting; }

else if (llStringTrim(data, STRING_TRIM) == "") {               llOwnerSay("Empty line, requesting new."); notecardQuery = llGetNotecardLine(notecardName, notecardIndex++); }

else {               list temp = llCSV2List (data);

vector vec = (vector) llList2String(temp,0); if (vec != ZERO_VECTOR) {                   string str = llList2String(temp,1); waypoints+=[vec,str]; notecardQuery = llGetNotecardLine(notecardName, notecardIndex++); }           }        }    } }

state running {   state_entry {

currentWaypoint = 0; nextWayPoint ; llSetTimerEvent (0.1); }

timer {               llRotLookAt(getRotToPointAxisAt(AXIS_FWD,target),1,1); vector pos = llGetPos ; integer match = 0; if(llAvatarOnSitTarget == NULL_KEY) {                   llSleep(10); llDie; }

if( llFabs (pos.x - target.x) < SPEED ) {                   pos.x = target.x;                    match++; }               else {                   if ( pos.x > target.x)                    pos.x -= SPEED; else pos.x += SPEED; }

if ( llFabs( pos.y - target.y) < SPEED) {               pos.y = target.y;                match++; }           else {               if( pos.y > target.y)                pos.y -= SPEED; else pos.y += SPEED; }

if( llFabs(pos.z - target.z) < SPEED ) {               pos.z = target.z;                match++; }           else {               if( pos.z > target.z)                pos.z-= SPEED; else pos.z+= SPEED; }

llSetPos(pos);

if( match==3) {                 string hold = message; llWhisper(0,hold); vector pos2 = llGetPos; if ((pos2 == <109,97,22.8>) || (pos2 == <82,97,22.9>) || (pos2 == <56,98,22.8>) || (pos2 == <25.3,89,22.8>) || (pos2 == <4.9,81,23>) || (pos2 == <14,28.9,23>) || (pos2 == <45,34.1,22.9>) || (pos2 == <46,49,22.8>) || (pos2 == <60,50,22.9>) || (pos2 == <60.1,30,23.1>) || (pos2 == <74,30.1,23>) || (pos2 == <79,50,23>) || (pos2 == <95,117,23>) || (pos2 == <94.9,130,25>) || (pos2 == <96,166,25>) || (pos2 == <95.9,198,24.9>) || (pos2 == <165,204,25>) || (pos2 == <186,160.1,27.2>) || (pos2 == <211,160,27>) || (pos2 == <198,167,27.1>) || (pos2 == <171.1,134,26.9>) || (pos2 == <171.1,162,27.1>) || (pos2 == <172,149,27>)|| (pos2 == <129,98,22.9>) || (pos2 == <120,206,24.9>)) {              llWhisper(-205, "trigger"); llOwnerSay("triggering"); llSleep(10); }                if ( nextWayPoint  ) {                state waiting;

}

}

}

}

state waiting {       state_entry {           llWhisper(0,"Bike is waiting.");

state countdown;

}   }

state countdown {       state_entry {

llWhisper(0,"Welcome to the UCSL Bicycle Tour! Bike will launch in 10 seconds. Please right click take your seat!"); llSleep(10);

if( llAvatarOnSitTarget) {              llSetTimerEvent(10); }           else{

llDie; // state waiting; }       }

timer {           state running; }   }

code