From f75d1acfee411050256b9372c5e45c5a989b36ef Mon Sep 17 00:00:00 2001 From: zontreck Date: Fri, 4 Oct 2024 23:25:39 -0700 Subject: [PATCH] feat(settings.lsl): finish settings api Signed-off-by: zontreck --- src/includes/Variables.lsl | 5 ++++- src/raw/settings.lsl | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/includes/Variables.lsl b/src/includes/Variables.lsl index dcf7f28..7a28540 100644 --- a/src/includes/Variables.lsl +++ b/src/includes/Variables.lsl @@ -1,8 +1,11 @@ integer LINK_SIGNAL_SETTINGS = 0904241; +integer LINK_SIGNAL_REBOOT = 0904242; + string OP_SETTINGS_WRITE = "settings_write"; string OP_SETTINGS_READ = "settings_read"; string OP_SETTINGS_REQUEST = "settings_req"; string OP_SETTINGS_RESPONSE = "settings_resp"; string OP_SETTINGS_RESPONSE = "settings_empty"; -string OP_SETTINGS_DELETE = "settings_del"; \ No newline at end of file +string OP_SETTINGS_DELETE = "settings_del"; +string OP_SETTINGS_RESET = "settings_reset"; \ No newline at end of file diff --git a/src/raw/settings.lsl b/src/raw/settings.lsl index c0ea3b8..f7d76b6 100644 --- a/src/raw/settings.lsl +++ b/src/raw/settings.lsl @@ -1,20 +1,48 @@ #include "Variables.lsl" #include "Functions.lsl" #include "Version.lsl" +#include "../external/AriasCreations/Common.lsl" +#include "../external/AriasCreations/Helpers.lsl" + default { + link_message(integer iSender, integer iNum, string sMsg, key kID) { + DEBUG_FUNC(true, "link_message", [iNum, sMsg, kID]); if(iNum == LINK_SIGNAL_SETTINGS) { + DEBUG_FUNC(true, "LINK_SIGNAL_SETTINGS", []); if(llJsonGetValue(sMsg, ["op"]) == OP_SETTINGS_WRITE) { WriteSetting(llJsonGetValue(sMsg, ["key"]), llJsonGetValue(sMsg, ["value"])); } 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