Skip to content

Commit

Permalink
Rework emergency tp and homing
Browse files Browse the repository at this point in the history
(This is a recommit.)

Per issue #875, removed "EMERGENCY_TP" setting and re-implemented all
code. Examined "HOMING_TP" code, and documented both.

Segregated code into two functions for testing and code cleanup.

Also added documentation and rename variables to be more consistent and
more functionally descriptive.

The dataserver event is still not raised with llRequestInventoryData.
  • Loading branch information
emmamei committed Jun 27, 2021
1 parent 88646d5 commit 47d75e4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 133 deletions.
55 changes: 30 additions & 25 deletions src/Avatar.lsl
Expand Up @@ -115,18 +115,17 @@ rlvTeleport(string locationData) {
vector globalLocation = getRegionLocation(locationData);
string globalPosition = locationToString(globalLocation);

//debugSay(6,"DEBUG-LANDMARK","Dolly should be teleporting now...");
//debugSay(6,"DEBUG-LANDMARK","Position = " + globalPosition);
llOwnerSay("Position = " + globalPosition);
debugSay(6,"DEBUG-LANDMARK","Dolly should be teleporting now...");
debugSay(6,"DEBUG-LANDMARK","Position = " + globalPosition);

llOwnerSay("Dolly is now teleporting.");

// Note this will be rejected if @unsit=n or @tploc=n are active
//lmRunRlvAs("TP-LANDMARK","unsit=y"); // restore restriction
//lmRunRlvAs("TP-LANDMARK","tploc=y"); // restore restriction
lmRunRlvAs("TP-LANDMARK","unsit=y"); // restore restriction
lmRunRlvAs("TP-LANDMARK","tploc=y"); // restore restriction

// Perform TP
//lmRunRlvAs("TP-LANDMARK","tpto:" + globalPosition + "=force");
lmRunRlvAs("TP-LANDMARK","tpto:" + globalPosition + "=force");

// FIXME: Determine whether this is needed or not

Expand All @@ -135,25 +134,27 @@ rlvTeleport(string locationData) {
//lmRunRlvAs("TP-LANDMARK","unsit=n"); // restore restriction
}

doTeleport(string landmark) {
/*
key doTeleport(string landmark) {
key queryLandmarkData;

if (!isLandmarkPresent(landmark)) {
debugSay(6,"DEBUG-LANDMARK","No landmark by the name of \"" + landmark + "\" is present in inventory.");
return;
return NULL_KEY;
}
*/

// This should trigger a dataserver event
queryLandmarkData = llRequestInventoryData(landmark);

/*
if (queryLandmarkData == NULL_KEY) {
llSay(DEBUG_CHANNEL,"Landmark <" + landmark + "> does not exist.");
return;
llSay(DEBUG_CHANNEL,"Landmark data request failed.");
return NULL_KEY;
}
*/
llOwnerSay("queryLandmarkData set to " + (string)queryLandmarkData);
//debugSay(6,"DEBUG-LANDMARK","queryLandmarkData set to " + (string)queryLandmarkData);
//debugSay(6,"DEBUG-LANDMARK","Teleporting dolly " + dollName + " to inventory landmark \"" + landmark + "\".");

#ifdef DEVELOPER_MODE
debugSay(6,"DEBUG-LANDMARK","queryLandmarkData set to " + (string)queryLandmarkData);
debugSay(6,"DEBUG-LANDMARK","Teleporting dolly " + dollName + " to inventory landmark \"" + landmark + "\".");
#endif
return queryLandmarkData;
}

float adjustTimer() {
Expand Down Expand Up @@ -417,7 +418,7 @@ default {

llRequestPermissions(dollID, PERMISSION_MASK);
myName = llGetScriptName();
//doTeleport("Home");
//queryLandmarkData = doTeleport("Home");
}

//----------------------------------------
Expand Down Expand Up @@ -562,7 +563,9 @@ default {
//
string landmark = (string)split[0];

doTeleport(landmark);
queryLandmarkData = doTeleport(landmark);
debugSay(6,"DEBUG-LANDMARK","queryLandmarkData now equals " + (string)queryLandmarkData);
llSetTimerEvent(20.0);
break;
}

Expand Down Expand Up @@ -727,6 +730,11 @@ default {
if (hasCarrier) keepFollow(carrierID);
else llSetTimerEvent(0.0);

if (queryLandmarkData) {
llSay(DEBUG_CHANNEL,"TP failed to occur; notify developer.");
llSetTimerEvent(0.0);
}

#ifdef DEVELOPER_MODE
if (timeReporting) {
timerMark = llGetUnixTime();
Expand All @@ -745,16 +753,13 @@ default {
//----------------------------------------
dataserver(key queryID, string queryData) {

llOwnerSay("Data server fired.");
debugSay(6,"DEBUG-LANDMARK","queryLandmarkData is equal to " + (string)queryLandmarkData);

if (queryID == queryLandmarkData) {
rlvTeleport(queryData);
llSetTimerEvent(0.0);
queryLandmarkData = NULL_KEY;
}
#ifdef DEVELOPER_MODE
else {
debugSay(6,"DEBUG-LANDMARK","queryID is not equal to queryLandmarkData - skipping");
}
#endif
}

//----------------------------------------
Expand Down
108 changes: 0 additions & 108 deletions src/testScript.lsl

This file was deleted.

0 comments on commit 47d75e4

Please sign in to comment.