feat(settings.lsl): finish settings api

Signed-off-by: zontreck <tarapiccari@gmail.com>
This commit is contained in:
zontreck 2024-10-04 23:25:39 -07:00
parent 37895e05ad
commit f75d1acfee
2 changed files with 34 additions and 3 deletions

View file

@ -1,8 +1,11 @@
integer LINK_SIGNAL_SETTINGS = 0904241; integer LINK_SIGNAL_SETTINGS = 0904241;
integer LINK_SIGNAL_REBOOT = 0904242;
string OP_SETTINGS_WRITE = "settings_write"; string OP_SETTINGS_WRITE = "settings_write";
string OP_SETTINGS_READ = "settings_read"; string OP_SETTINGS_READ = "settings_read";
string OP_SETTINGS_REQUEST = "settings_req"; string OP_SETTINGS_REQUEST = "settings_req";
string OP_SETTINGS_RESPONSE = "settings_resp"; string OP_SETTINGS_RESPONSE = "settings_resp";
string OP_SETTINGS_RESPONSE = "settings_empty"; string OP_SETTINGS_RESPONSE = "settings_empty";
string OP_SETTINGS_DELETE = "settings_del"; string OP_SETTINGS_DELETE = "settings_del";
string OP_SETTINGS_RESET = "settings_reset";

View file

@ -1,20 +1,48 @@
#include "Variables.lsl" #include "Variables.lsl"
#include "Functions.lsl" #include "Functions.lsl"
#include "Version.lsl" #include "Version.lsl"
#include "../external/AriasCreations/Common.lsl"
#include "../external/AriasCreations/Helpers.lsl"
default default
{ {
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]);
if(iNum == LINK_SIGNAL_SETTINGS) { if(iNum == LINK_SIGNAL_SETTINGS) {
DEBUG_FUNC(true, "LINK_SIGNAL_SETTINGS", []);
if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_WRITE) { if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_WRITE) {
WriteSetting(llJsonGetValue(sMsg, ["key"]), llJsonGetValue(sMsg, ["value"])); WriteSetting(llJsonGetValue(sMsg, ["key"]), llJsonGetValue(sMsg, ["value"]));
} else if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_READ) { } else if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_READ) {
ReadSetting(llJsonGetValue(sMsg, ["key"])); string sKey = llJsonGetValue(sMsg, ["key"]);
if(sKey == "ALL") {
DEBUG_FUNC(true, "req_all_settings", []);
// List Found Keys
list lKeys = llLinksetDataFindKeys("nusetting.", 0, 0);
integer i = 0;
integer end = llGetListLength(lKeys);
for(i=0;i<end; i++) {
sKey = llList2String(lKeys, i);
ReadSetting(llGetSubString(sKey, 9, -1));
}
DEBUG_FUNC(false, "req_all_settings", []);
}
ReadSetting(sKey);
} else if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_DELETE) { } else if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_DELETE) {
llLinksetDataDelete(llJsonGetValue(sMsg, ["key"])); llLinksetDataDelete("nusetting." + llJsonGetValue(sMsg, ["key"]));
NoSetting(llJsonGetValue(sMsg, ["key"])); NoSetting(llJsonGetValue(sMsg, ["key"]));
} else if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_RESET) {
llLinksetDataDeleteFound("nusetting.", "");
} }
DEBUG_FUNC(false, "LINK_SIGNAL_SETTINGS", []);
} else if(iNum == LINK_SIGNAL_REBOOT) {
DEBUG_FUNC(true, "LINK_SIGNAL_REBOOT", []);
DEBUG_FUNC(false, "LINK_SIGNAL_REBOOT", []);
llResetScript();
} }
DEBUG_FUNC(false, "link_message", []);
} }
} }