diff --git a/src/includes/Functions.lsl b/src/includes/Functions.lsl new file mode 100644 index 0000000..5ad1579 --- /dev/null +++ b/src/includes/Functions.lsl @@ -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])); +} \ No newline at end of file diff --git a/src/includes/Variables.lsl b/src/includes/Variables.lsl new file mode 100644 index 0000000..f463022 --- /dev/null +++ b/src/includes/Variables.lsl @@ -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"; \ No newline at end of file diff --git a/src/includes/Version.lsl b/src/includes/Version.lsl new file mode 100644 index 0000000..e69de29 diff --git a/src/preproc/settings.lsl b/src/preproc/settings.lsl new file mode 100644 index 0000000..616a00c --- /dev/null +++ b/src/preproc/settings.lsl @@ -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" \ No newline at end of file diff --git a/src/raw/settings.lsl b/src/raw/settings.lsl new file mode 100644 index 0000000..e3158b7 --- /dev/null +++ b/src/raw/settings.lsl @@ -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"])); + } + } + } +} \ No newline at end of file