refactor(settings): utilize callbacks to resolve todo item

Signed-off-by: zontreck <tarapiccari@gmail.com>
This commit is contained in:
zontreck 2024-10-05 00:33:09 -07:00
parent 5a333f262f
commit 451530b054

View file

@ -43,8 +43,7 @@ NoSetting(string sKey) {
default default
{ {
state_entry() { state_entry() {
llSetTimerEvent(5); // TODO: Change this to schedule with the TaskScheduler module for a callback LM(LINK_SIGNAL_CALLBACKS, OP_CALLBACK_CHK_STATUS, EMPTY_JSON);
// After expiration of timer, send all settings
} }
changed(integer iChange) { changed(integer iChange) {
@ -54,12 +53,6 @@ default
} }
} }
timer() {
llSetTimerEvent(0);
reqAllSettings();
}
link_message(integer iSender, integer iNum, string sMsg, key kID) link_message(integer iSender, integer iNum, string sMsg, key kID)
{ {
DEBUG_FUNC(true, "link_message", [iNum, sMsg, kID]); DEBUG_FUNC(true, "link_message", [iNum, sMsg, kID]);
@ -84,6 +77,23 @@ default
DEBUG_FUNC(true, "LINK_SIGNAL_REBOOT", []); DEBUG_FUNC(true, "LINK_SIGNAL_REBOOT", []);
DEBUG_FUNC(false, "LINK_SIGNAL_REBOOT", []); DEBUG_FUNC(false, "LINK_SIGNAL_REBOOT", []);
llResetScript(); llResetScript();
} else if(iNum == LINK_SIGNAL_CALLBACKS) {
string sOp = llJsonGetValue(sMsg, ["op"]);
switch(sOp) {
case OP_CALLBACK_READY: {
// Schedule callback to load all settings
ScheduleCallback("settings_start", 10, llGetScriptName());
break;
}
case OP_CALLBACK: {
if(llJsonGetValue(sMsg, ["target"]) == llGetScriptName()) {
if(llJsonGetValue(sMsg, ["id"]) == "settings_start") {
reqAllSettings();
}
}
break;
}
}
} }
DEBUG_FUNC(false, "link_message", []); DEBUG_FUNC(false, "link_message", []);
} }