Skip to content

Commit

Permalink
add global_verbosity to solve a issue where messages were not able to…
Browse files Browse the repository at this point in the history
… be disabled previously
  • Loading branch information
zontreck committed Feb 25, 2021
1 parent efd8c01 commit e9fdf65
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 52 deletions.
7 changes: 6 additions & 1 deletion src/collar/oc_addons.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ DoListeners(){
g_lActiveListeners+=[llListen(API_CHANNEL, "","",""), llListen(GENERAL_API_CHANNEL, "", "", "scan")];
}


integer g_iVerbosityLevel = 1;
integer CMD_ZERO = 0;
integer CMD_OWNER = 500;
integer CMD_TRUSTED = 501;
Expand Down Expand Up @@ -287,6 +287,9 @@ state active

listen(integer c, string n,key i,string m){
if(c==API_CHANNEL){
if(g_iVerbosityLevel>=3){
llOwnerSay("Addons Packet\n\n"+m);
}
//llWhisper(0, m);
// All addons as of 8.0.00004 must include a ping and pong. This lets the collar know an addon is alive and not to automatically remove it.
// Addon key will be placed in a temporary list that will be cleared once the timer checks over all the information.
Expand Down Expand Up @@ -464,6 +467,8 @@ state active
} else if(sVar == "addons"){
g_iAddons = (integer)sVal;
DoListeners();
} else if(sVar == "verbosity"){
g_iVerbosityLevel=(integer)sVal;
}
}else if(sToken == "auth"){
if(sVar == "owner"){
Expand Down
13 changes: 13 additions & 0 deletions src/collar/oc_core.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ integer g_iAmNewer=FALSE;
integer g_iChannel=1;
string g_sPrefix;

integer g_iVerbosityLevel=1;

integer g_iNotifyInfo=FALSE;

Expand Down Expand Up @@ -268,6 +269,11 @@ UserCommand(integer iNum, string sStr, key kID) {
llMessageLinked(LINK_SET, NOTIFY, "1secondlife:///app/agent/"+(string)kID+"/about is attempting to weld the collar. Consent is required", kID);
Dialog(g_kWearer, "[WELD CONSENT REQUIRED]\n\nsecondlife:///app/agent/"+(string)kID+"/about wants to weld your collar. If you agree, you may not be able to unweld it without the use of a plugin or a addon designed to break the weld. If you disagree with this action, press no.", ["Yes", "No"], [], 0, iNum, "weld~consent");
} else llMessageLinked(LINK_SET,NOTIFY,"0%NOACCESS% to welding", kID);
} else if(llToLower(sChangetype)=="verbosity"){
if(iNum == CMD_WEARER || kID == g_kWearer)
llMessageLinked(LINK_SET, LM_SETTING_SAVE, "global_verbosity="+sChangevalue, "");
else
llMessageLinked(LINK_SET, NOTIFY, "%NOACCESS% to changing verbosity levels", kID);
} else if(llToLower(sChangetype) == "info"){
if(iNum >= CMD_OWNER && iNum <= CMD_EVERYONE){
g_iNotifyInfo = TRUE;
Expand Down Expand Up @@ -451,6 +457,11 @@ state active
llMessageLinked(LINK_SET, 0, "menu", llDetectedKey(0)); // Temporary until API v8's implementation is done, use v7 in the meantime
}
link_message(integer iSender,integer iNum,string sStr,key kID){

if(g_iVerbosityLevel>=2){
llOwnerSay("Link Message\n["+llDumpList2String(["iSender = "+(string)iSender, "iNum = "+(string)iNum, "sStr = "+sStr, "kID = "+(string)kID], ", ")+"]");
}

if(iNum >= CMD_OWNER && iNum <= CMD_EVERYONE) UserCommand(iNum, sStr, kID);
else if(iNum == MENUNAME_RESPONSE){
list lPara = llParseString2List(sStr, ["|"],[]);
Expand Down Expand Up @@ -728,6 +739,8 @@ state active
g_iWearerAddonLimited=(integer)sVal;
} else if(sVar == "addons"){
g_iAddons = (integer)sVal;
} else if(sVar=="verbosity"){
g_iVerbosityLevel=(integer)sVal;
}
} else if(sToken == "auth"){
if(sVar == "group"){
Expand Down
24 changes: 12 additions & 12 deletions src/collar/oc_dialog.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ integer DIALOG_RENDER = -9003;
//integer TIMEOUT_FIRED = 30499;



integer g_iVerbosityLevel=1;

integer g_iPagesize = 12;
string MORE = "";
Expand Down Expand Up @@ -85,6 +85,7 @@ string SubstituteVars(string sMsg) {
return sMsg;
}
Notify(key kID, string sMsg, integer iAlsoNotifyWearer) {
if(g_iVerbosityLevel<1)return;
if ((key)kID){
sMsg = SubstituteVars(sMsg);
string sObjectName = llGetObjectName();
Expand Down Expand Up @@ -130,6 +131,7 @@ integer IsLikelyAvatar(key kID){
}

Say(string sMsg, integer iWhisper) {
if(g_iVerbosityLevel<1)return;
sMsg = SubstituteVars(sMsg);
string sObjectName = llGetObjectName();
llSetObjectName("");
Expand Down Expand Up @@ -504,6 +506,11 @@ state active
}

listen(integer iChan, string sName, key kID, string sMessage) {
if(g_iVerbosityLevel>=3){
llOwnerSay("Dialog Response\n\n[iChan = "+(string)iChan+", sName = "+sName+", kID = "+(string)kID+", sMessage = "+sMessage+"]");
}


integer iMenuIndex = llListFindList(g_lMenus, [iChan]);
if (~iMenuIndex) {
key kMenuID = llList2Key(g_lMenus, iMenuIndex + 1);
Expand Down Expand Up @@ -693,18 +700,11 @@ state active
for(iPos=0;iPos<iEnd;iPos++){
ClearUser((key)llList2String(lBlock, iPos));
}
} else if(sToken == g_sGlobalToken+"verbosity"){
g_iVerbosityLevel=(integer)sValue;
}
}else if(iNum == LM_SETTING_EMPTY){

//integer ind = llListFindList(g_lSettingsReqs, [sStr]);
//if(ind!=-1)g_lSettingsReqs = llDeleteSubList(g_lSettingsReqs, ind,ind);

} else if(iNum == LM_SETTING_DELETE){
//integer ind = llListFindList(g_lSettingsReqs, [sStr]);
//if(ind!=-1)g_lSettingsReqs = llDeleteSubList(g_lSettingsReqs, ind,ind);

} else if (iNum == NOTIFY) Notify(kID,llGetSubString(sStr,1,-1),(integer)llGetSubString(sStr,0,0));
else if (iNum == SAY) Say(llGetSubString(sStr,1,-1),(integer)llGetSubString(sStr,0,0));
} else if (iNum == NOTIFY ) Notify(kID,llGetSubString(sStr,1,-1),(integer)llGetSubString(sStr,0,0));
else if (iNum == SAY ) Say(llGetSubString(sStr,1,-1),(integer)llGetSubString(sStr,0,0));
else if (iNum==NOTIFY_OWNERS) NotifyOwners(sStr,(string)kID);
else if (iNum == REBOOT && sStr == "reboot") llResetScript();

Expand Down
95 changes: 56 additions & 39 deletions src/collar/oc_states.lsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

/*
This file is a part of OpenCollar.
Copyright ©2020
Expand All @@ -10,8 +10,8 @@ Aria (Tashia Redrose)
*August 2020 - Created oc_states
- Due to significant issues with original implementation, States has been turned into a anti-crash script instead of a script state manager.
- Repurpose oc_states to be anti-crash and a interactive settings editor.
et al.
Licensed under the GPLv2. See LICENSE for full details.
https://github.com/OpenCollarTeam/OpenCollar
Expand All @@ -35,6 +35,8 @@ integer TIMEOUT_READY = 30497;
integer TIMEOUT_REGISTER = 30498;
integer TIMEOUT_FIRED = 30499;

integer g_iVerbosityLevel = 1;

/*list StrideOfList(list src, integer stride, integer start, integer end)
{
list l = [];
Expand Down Expand Up @@ -67,7 +69,7 @@ SettingsMenu(integer stridePos, key kAv, integer iAuth)
integer end = llGetListLength(g_lSettings);
for(i=0;i<end;i+=3){
if(llListFindList(lBtns,[llList2String(g_lSettings,i)])==-1)lBtns+=llList2String(g_lSettings,i);
}
}
sText+="\nCurrently viewing Tokens";
} else if(stridePos==1){
integer i=0;
Expand Down Expand Up @@ -99,10 +101,10 @@ SettingsMenu(integer stridePos, key kAv, integer iAuth)
sText += "\n\nPlease enter the variable name for '"+g_sTokenView;
lBtns=[];
}

g_iLastStride=stridePos;
Dialog(kAv, sText,lBtns, setor((lBtns!=[]), ["+ NEW", UPMENU], []), 0, iAuth, "settings~edit~"+(string)stridePos);

}

list setor(integer test, list a, list b){
Expand Down Expand Up @@ -175,7 +177,7 @@ default
state_entry()
{
if(llGetStartParameter() != 0) state inUpdate;

g_lAlive=[];
g_iPasses=-1;
g_iExpectAlive=1;
Expand All @@ -184,38 +186,42 @@ default
llMessageLinked(LINK_SET, REBOOT,"reboot", "");
llSleep(5);
//llMessageLinked(LINK_SET, 0, "initialize", "");
llOwnerSay("Collar is preparing to startup, please be patient.");
if(g_iVerbosityLevel>=1)
llOwnerSay("Collar is preparing to startup, please be patient.");
}


on_rez(integer iRez){
llSleep(10);
llResetScript();
}

timer(){

if(g_iExpectAlive){
if(llGetTime()>=5 && g_iPasses<3){
llMessageLinked(LINK_SET,READY, "","");
llResetTime();
//llSay(0, "PASS COUNT: "+(string)g_iPasses);
g_iPasses++;
} else if(llGetTime()>=7.5 && g_iPasses>=3){
llOwnerSay("Scripts ready: "+(string)llGetListLength(g_lAlive));
if(g_iVerbosityLevel>=2)
llOwnerSay("Scripts ready: "+(string)llGetListLength(g_lAlive));
llMessageLinked(LINK_SET,STARTUP,llDumpList2String(g_lAlive,","),"");
g_iExpectAlive=0;
g_lAlive=[];
g_iPasses=0;
llSleep(10);
llMessageLinked(LINK_SET,NOTIFY,"0Startup in progress... be patient", llGetOwner());

if(g_iVerbosityLevel >=1)
llMessageLinked(LINK_SET,NOTIFY,"0Startup in progress... be patient", llGetOwner());
//llMessageLinked(LINK_SET,LM_SETTING_REQUEST,"ALL","");
llMessageLinked(LINK_SET,0,"initialize","");
}

return;
}

if(!g_iWaitMenu && llGetListLength(g_lTimers) == 0)
llSetTimerEvent(15);
// Check all script states, then check list of managed scripts
Expand All @@ -231,19 +237,20 @@ default
llSetScriptState(scriptName,TRUE);
llSleep(1);
iModified=TRUE;

llMessageLinked(LINK_SET, NOTIFY, "0"+scriptName+" has been reset. If the script stack heaped, please file a bug report on our github.", llGetOwner());

if(g_iVerbosityLevel >=1)
llMessageLinked(LINK_SET, NOTIFY, "0"+scriptName+" has been reset. If the script stack heaped, please file a bug report on our github.", llGetOwner());
}
}

if(iModified) llMessageLinked(LINK_SET, LM_SETTING_REQUEST, "ALL","");

if(!g_iLoading && g_iWaitMenu){
g_iWaitMenu=FALSE;
SettingsMenu(0,g_kMenuUser,g_iLastAuth);
}


// proceed
i=0;
end = llGetListLength(g_lTimers);
Expand All @@ -253,22 +260,22 @@ default
integer diff = llList2Integer(g_lTimers,i+2);
if((now-start)>=diff){
string signal = llList2String(g_lTimers,i);

g_lTimers = llDeleteSubList(g_lTimers, i,i+2);
i=0;
end=llGetListLength(g_lTimers);
llMessageLinked(LINK_SET, TIMEOUT_FIRED, signal, "");

}
}

//llWhisper(0, "oc_states max used over time: "+(string)llGetSPMaxMemory());
}


link_message(integer iSender, integer iNum, string sStr, key kID){
if(iNum == REBOOT && sStr == "reboot --f")llResetScript();

if(iNum>=CMD_OWNER && iNum <= CMD_EVERYONE){
if(sStr == "fix"){
g_iExpectAlive=1;
Expand All @@ -277,7 +284,7 @@ default
g_lAlive=[];
g_iLoading=FALSE;
g_lSettings=[];

llMessageLinked(LINK_SET, LM_SETTING_REQUEST, "ALL", "");
}
if(llToLower(sStr)=="settings edit"){
Expand All @@ -304,7 +311,7 @@ default
string sMsg = llList2String(lMenuParams,1);
integer iAuth = llList2Integer(lMenuParams,3);
integer iRemenu=FALSE;

if(sMenu == "Menu~Main"){
if(sMsg == UPMENU){
iRemenu=FALSE;
Expand Down Expand Up @@ -333,10 +340,10 @@ default
SettingsMenu(9, kAv, iAuth);
return;
}

g_sVariableView=sMsg;
SettingsMenu(2, kAv,iAuth);

} else if(sMenu == "settings~edit~2"){
if(sMsg == UPMENU){
SettingsMenu(1,kAv,iAuth);
Expand Down Expand Up @@ -379,25 +386,35 @@ default
} else if(sMenu == "settings~edit~9"){
g_sVariableView=sMsg;
g_lSettings += [g_sTokenView,g_sVariableView,"not set"];

SettingsMenu(3, kAv,iAuth);
}

}

} else if (iNum == DIALOG_TIMEOUT) {
integer iMenuIndex = llListFindList(g_lMenuIDs, [kID]);
g_lMenuIDs = llDeleteSubList(g_lMenuIDs, iMenuIndex - 1, iMenuIndex +3); //remove stride from g_lMenuIDs
}else if(iNum == LM_SETTING_RESPONSE){
// Detect here the Settings
list lSettings = llParseString2List(sStr, ["_","="],[]);
string sToken = llList2String(lSettings,0);
string sVar = llList2String(lSettings,1);
string sVal = llList2String(lSettings, 2);
if(sToken == "global"){
if(sVar == "verbosity"){
g_iVerbosityLevel = (integer)sVal;
}
}


if(sStr == "settings=sent"){
g_iLoading=FALSE;
return;
}
list lSettings = llParseString2List(sStr, ["_","="],[]);

if(g_iLoading && llListFindList(g_lSettings, [llList2String(lSettings,0), llList2String(lSettings,1), llList2String(lSettings,2)]) == -1 )g_lSettings+=[llList2String(lSettings,0), llList2String(lSettings,1), llList2String(lSettings,2)];


if(g_iLoading && llListFindList(g_lSettings, [sToken, sVar, sVal]) == -1 )g_lSettings+=[sToken, sVar, sVal];

} else if(iNum == 0){
if(sStr == "initialize"){
llMessageLinked(LINK_SET, TIMEOUT_READY, "","");
Expand Down

0 comments on commit e9fdf65

Please sign in to comment.