Skip to content

Commit

Permalink
fix requesting stop when sync script sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
RayZopf committed Apr 4, 2014
1 parent acf9156 commit 488f597
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 21 deletions.
8 changes: 5 additions & 3 deletions LSL/CameraMessageMap.lslm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
//by: Zopf Resident - Ray Zopf (Raz)
//04. Apr. 2014
//v0.1
//v0.1.1

//Files:
// CameraMessageMap.lslm
Expand Down Expand Up @@ -36,12 +36,14 @@ integer silent = FALSE; // silent startup
// Variables
key g_kOwner; // object owner
integer g_iHandle = 0;
integer g_iHandleAvi = 0;

integer g_iSyncOn = FALSE;
integer g_iSyncPerms = FALSE;

// Constants
string REQUESTSCRIPT = "RequestCameraData2.lsl";
string REQUESTSCRIPT = "RequestCameraData2.lsl";
string MSG_STOP = " has requested that you stop viewing their camera. Your camera is being returned to you.";

//Camera MESSAGE MAP
integer CH; // dialog channel
Expand All @@ -55,7 +57,7 @@ integer AVI_CH = 1010;

//###
//CameraMessageMap.lslm
//0.1 - 04Apr2014
//0.1.1 - 04Apr2014

// pragma inline
LSLFORGE_OPTIMIZER_MODUL()
Expand Down
33 changes: 25 additions & 8 deletions LSL/CameraScript.lsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// LSL script generated - patched Render.hs (0.1.3.2): LSL.CameraScript.lslp Fri Apr 4 14:56:21 Mitteleuropäische Sommerzeit 2014
// LSL script generated - patched Render.hs (0.1.3.2): LSL.CameraScript.lslp Fri Apr 4 16:12:40 Mitteleuropäische Sommerzeit 2014
///////////////////////////////////////////////////////////////////////////////////////////////////
//Camera Control
//
Expand All @@ -13,7 +13,7 @@
//modified by: Zopf Resident - Ray Zopf (Raz)
//Additions: Abillity to save cam positions, gesture support, visual feedback
//04. Apr. 2014
//v3.1.4
//v3.1.5
//

//Files:
Expand Down Expand Up @@ -58,7 +58,7 @@ However, if the object is made up of multiple prims or there is an avatar seated
//internal variables
//-----------------------------------------------
string g_sTitle = "CameraScript";
string g_sVersion = "3.1.4";
string g_sVersion = "3.1.5";
string g_sAuthors = "Dan Linden, Penny Patton, Core Taurog, Zopf";

// Constants
Expand Down Expand Up @@ -103,13 +103,16 @@ integer verbose = 1;
string g_sScriptName;
key g_kOwner;
integer g_iHandle = 0;
integer g_iHandleAvi = 0;
integer g_iSyncOn = 0;
integer g_iSyncPerms = 0;
string REQUESTSCRIPT = "RequestCameraData2.lsl";
string MSG_STOP = " has requested that you stop viewing their camera. Your camera is being returned to you.";
integer CH;
integer COMMAND_CH = 1;
integer REMOTE_CH = 2;
integer CAM_CH = 0;
integer AVI_CH = 1010;


//===============================================
Expand All @@ -126,7 +129,10 @@ defCam(){
initExtension(integer conf){
llOwnerSay(g_sTitle + " (" + g_sVersion + ") written/enhanced by " + g_sAuthors);
llListenRemove(g_iHandle);
llListenRemove(g_iHandleAvi);
g_iHandle = llListen(CH,"",g_kOwner,"");
g_iHandleAvi = llListen(AVI_CH,"","","");
llListenControl(g_iHandleAvi,0);
llOwnerSay("Camera Control HUD listens on channel: " + (string)CH + "\n");
if (verbose) {

Expand Down Expand Up @@ -180,6 +186,7 @@ toggleSyncCtrl(){
if (g_iSyncPerms) {
llOwnerSay("releasing cam");
llMessageLinked(1,COMMAND_CH,"stop",g_kOwner);
llListenControl(g_iHandleAvi,0);
}
else {
llOwnerSay("requesting cam");
Expand Down Expand Up @@ -282,10 +289,12 @@ toggleSync(){
llSetScriptState(REQUESTSCRIPT,1);
setButtonCol(3);
llOwnerSay("sync active");
llListenControl(g_iHandleAvi,0);
llClearCameraParams();
llSleep(0.1);
}
else {
llListenControl(g_iHandleAvi,1);
llSetScriptState(REQUESTSCRIPT,0);
llOwnerSay("sync not active");
setButtonCol(2);
Expand Down Expand Up @@ -467,7 +476,7 @@ default {
g_kOwner = llGetOwner();
g_sScriptName = llGetScriptName();
integer rc = 0;
rc = llSetMemoryLimit(56000);
rc = llSetMemoryLimit(58000);
if (verbose && !rc) {
llOwnerSay("(v) " + g_sTitle + "/" + g_sScriptName + " - could not set memory limit");
}
Expand Down Expand Up @@ -641,27 +650,31 @@ default {
string status = "off";
if (verbose) status = "on";
message = llToLower(message);
if (AVI_CH == channel && "stop" == message) {
llOwnerSay("Avatar" + MSG_STOP);
toggleSyncCtrl();
return;
}
if ("---" == message || "close" == message) {
return;
}
else if ("verbose" == message) {
verbose = !verbose;
if (verbose) llOwnerSay("Verbose messages turned ON");
else llOwnerSay("Verbose messages turned OFF");
return;
}
else if ("help" == message) {
infoLines();
}
else if ("off" == message) {
g_iOn = 1;
toggleCamCtrl();
return;
}
else if ("delete" == message) {
g_iNr = 3;
setButtonCol(-1);
llSleep(0.2);
setButtonCol(1);
resetCamPos();
return;
}
perm = llGetPermissions();
if (!(perm & 3072)) {
Expand All @@ -682,6 +695,10 @@ default {
else if ("...back" == message) {
llDialog(id,MSG_VER + g_sVersion + MSG_DIALOG + status,MENU_MAIN,CH);
}
else if ("off" == message) {
g_iOn = 1;
toggleCamCtrl();
}
else if ("distance" == message) {
if (g_iSyncOn) setSyncCol();
if (g_iFar) {
Expand Down
26 changes: 20 additions & 6 deletions LSL/CameraScript.lslp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//modified by: Zopf Resident - Ray Zopf (Raz)
//Additions: Abillity to save cam positions, gesture support, visual feedback
//04. Apr. 2014
//v3.1.4
//v3.1.5
//

//Files:
Expand Down Expand Up @@ -57,7 +57,7 @@ However, if the object is made up of multiple prims or there is an avatar seated
//internal variables
//-----------------------------------------------
string g_sTitle = "CameraScript"; // title
string g_sVersion = "3.1.4"; // version
string g_sVersion = "3.1.5"; // version
string g_sAuthors = "Dan Linden, Penny Patton, Core Taurog, Zopf";

// Constants
Expand Down Expand Up @@ -160,7 +160,10 @@ initExtension(integer conf)
setupListen()
{
llListenRemove(g_iHandle);
llListenRemove(g_iHandleAvi);
g_iHandle = llListen(CH, "", g_kOwner, ""); // listen for dialog answers
g_iHandleAvi = llListen(AVI_CH, "", "", "");
llListenControl(g_iHandleAvi, FALSE);
llOwnerSay("Camera Control HUD listens on channel: "+(string)CH+"\n");
}

Expand Down Expand Up @@ -207,11 +210,12 @@ toggleCamCtrl()
toggleSyncCtrl()
{
llSetTimerEvent(150);
llSetScriptState(REQUESTSCRIPT, 1);
llSetScriptState(REQUESTSCRIPT, TRUE);

if (g_iSyncPerms) {
llOwnerSay("releasing cam");
llMessageLinked(LINK_ROOT, COMMAND_CH, "stop", g_kOwner);
llListenControl(g_iHandleAvi, FALSE);
} else {
llOwnerSay("requesting cam");
llSleep(1.5);
Expand Down Expand Up @@ -600,9 +604,11 @@ toggleSync()
llSetScriptState(REQUESTSCRIPT, TRUE);
setButtonCol(3);
llOwnerSay("sync active");
llListenControl(g_iHandleAvi, FALSE);
llClearCameraParams(); // reset camera to default
llSleep(0.1);
} else {
llListenControl(g_iHandleAvi, TRUE);
llSetScriptState(REQUESTSCRIPT, FALSE);
llOwnerSay("sync not active");
setButtonCol(2);
Expand Down Expand Up @@ -770,7 +776,7 @@ default
g_kOwner = llGetOwner();
g_sScriptName = llGetScriptName();

MemRestrict(56000, FALSE);
MemRestrict(58000, FALSE);
if (debug) Debug("state_entry", TRUE, TRUE);

llSleep(1);
Expand Down Expand Up @@ -922,19 +928,26 @@ default
if (verbose) status = "on";

message = llToLower(message);
if (AVI_CH == channel && "stop" == message) {
llOwnerSay("Avatar" + MSG_STOP);
toggleSyncCtrl();
return;
}

if ("---" == message || "close" == message) { return; }
else if ("verbose" == message) {
verbose = !verbose;
if (verbose) llOwnerSay("Verbose messages turned ON");
else llOwnerSay("Verbose messages turned OFF");
} else if ("help" == message) { infoLines(); }
else if ("off" == message) { g_iOn = TRUE; toggleCamCtrl(); }
return;
} else if ("help" == message) { infoLines(); return; }
else if ("delete" == message) {
g_iNr = 3;
setButtonCol(-1);
llSleep(0.2);
setButtonCol(TRUE);
resetCamPos();
return;
}

perm =llGetPermissions();
Expand All @@ -955,6 +968,7 @@ default
"Me", "Worm", "Drop",
"Spin", "Spaz", "---", "DEFAULT","Center", "STANDARD"], CH); // present submenu on request
} else if ("...back" == message) { llDialog(id, MSG_VER + g_sVersion + MSG_DIALOG + status, MENU_MAIN, CH); } // present main menu on request to go back
else if ("off" == message) { g_iOn = TRUE; toggleCamCtrl(); }
else if ("distance" == message) { if (g_iSyncOn) setSyncCol(); toggleDist(); }
else if ("on" == message) {
if (!g_iOn) {
Expand Down
7 changes: 4 additions & 3 deletions LSL/RequestCameraData2.lsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// LSL script generated - patched Render.hs (0.1.3.2): LSL.RequestCameraData2.lslp Fri Apr 4 15:23:11 Mitteleuropäische Sommerzeit 2014
// LSL script generated - patched Render.hs (0.1.3.2): LSL.RequestCameraData2.lslp Fri Apr 4 15:58:08 Mitteleuropäische Sommerzeit 2014
///////////////////////////////////////////////////////////////////////////////////////////////////
//Sync Control
//
Expand Down Expand Up @@ -60,6 +60,7 @@ integer silent = 0;
key g_kOwner;
integer g_iHandle = 0;
integer g_iSyncPerms = 0;
string MSG_STOP = " has requested that you stop viewing their camera. Your camera is being returned to you.";
integer CH;
integer COMMAND_CH = 1;
integer REMOTE_CH = 2;
Expand Down Expand Up @@ -108,7 +109,7 @@ default {
str = llToLower(str);
if ("stop" == str) {
if (id == target) {
llOwnerSay(targetFirstName + " has requested that you stop viewing their camera. Your camera is being returned to you.");
llOwnerSay(targetFirstName + MSG_STOP);
llInstantMessage(target,"At your request, " + ownerFirstName + " has stopped viewing your camera and permissions have been revoked.");
llSetLinkPrimitiveParamsFast(5,[26,"",ZERO_VECTOR,0]);
}
Expand All @@ -130,7 +131,7 @@ default {
listen(integer channel,string name,key id,string message) {
if (AVI_CH == channel && "stop" == llToLower(message)) {
if (id == target) {
llOwnerSay(targetFirstName + " has requested that you stop viewing their camera. Your camera is being returned to you.");
llOwnerSay(targetFirstName + MSG_STOP);
llInstantMessage(target,"At your request, " + ownerFirstName + " has stopped viewing your camera and permissions have been revoked.");
llSetLinkPrimitiveParamsFast(5,[26,"",ZERO_VECTOR,0]);
}
Expand Down
2 changes: 1 addition & 1 deletion LSL/RequestCameraData2.lslp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ toggleSyncCtrl(key id)
{
if(id == target)
{
llOwnerSay(targetFirstName + " has requested that you stop viewing their camera. Your camera is being returned to you.");
llOwnerSay(targetFirstName + MSG_STOP);
llInstantMessage(target, "At your request, " + ownerFirstName + " has stopped viewing your camera and permissions have been revoked.");
llSetLinkPrimitiveParamsFast(5, [PRIM_TEXT, "", ZERO_VECTOR, 0]);
} else {
Expand Down

0 comments on commit 488f597

Please sign in to comment.