feat(settings.lsl): begin implementation of settings module

This commit is contained in:
zontreck 2024-10-04 03:19:54 -07:00
parent d141d5412f
commit c34283eb35
5 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,24 @@
LM(integer iSignal, string sOp, string sJsonArgs) {
string sJson = llJsonSetValue(sJsonArgs, ["op"], sOp);
llMessageLinked(LINK_SET, iSignal, llJsonSetValue(sJson, ["script"], llGetScriptName()), "");
}
WriteSetting(string sKey, string sValue) {
llLinksetDataWrite(sKey, sValue);
SendSetting(sKey, sValue);
}
ReadSetting(string sKey) {
string sVal = llLinksetDataRead(sKey);
if(sVal == "") {
NoSetting(sKey);
}else SendSetting(sKey, sVal);
}
SendSetting(string sKey, string sVal) {
LM(LINK_SIGNAL_SETTINGS, OP_SETTINGS_RESPONSE, llList2Json(JSON_OBJECT, ["key", sKey, "value", sVal]));
}
NoSetting(string sKey) {
LM(LINK_SIGNAL_SETTINGS, OP_SETTINGS_EMPTY, llList2Json(JSON_OBJECT, ["key", sKey]));
}

View file

@ -0,0 +1,7 @@
integer LINK_SIGNAL_SETTINGS = 0904241;
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";

0
src/includes/Version.lsl Normal file
View file

12
src/preproc/settings.lsl Normal file
View file

@ -0,0 +1,12 @@
/*
This file is a part of NuSystem (https://git.zontreck.com/AriasCreations/NuSystem)
NuSystem is licensed under the GPL.
Please see the Git Source Tree for structured information on changes to indivudual files
Initial Author: Aria (aria@zontreck.com)
*/
#include "../raw/settings.lsl"

17
src/raw/settings.lsl Normal file
View file

@ -0,0 +1,17 @@
#include "Variables.lsl"
#include "Functions.lsl"
#include "Version.lsl"
default
{
link_message(integer iSender, integer iNum, string sMsg, key kID)
{
if(iNum == 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"]));
}
}
}
}