diff --git a/src/includes/Functions.lsl b/src/includes/Functions.lsl index 16faa6f..895f80c 100644 --- a/src/includes/Functions.lsl +++ b/src/includes/Functions.lsl @@ -76,4 +76,14 @@ integer VersionNumberCompare(string sInput, string sCompare) } /* END VERSION CODE -*/ \ No newline at end of file +*/ + + +string getDefaultPrefix() { + string ret = ""; + string ownerName = llGetUsername(llGetOwner()); + + ret = llToLower(llGetSubString(ownerName, 0, 1)); + + return ret; +} \ No newline at end of file diff --git a/src/includes/Variables.lsl b/src/includes/Variables.lsl index f58cb86..23528d9 100644 --- a/src/includes/Variables.lsl +++ b/src/includes/Variables.lsl @@ -66,6 +66,8 @@ key g_kSession; string g_sBOM; integer g_iLocked; +integer g_iListenZero; +string g_sPrefix; string UPDATER_SHIM = "NuUpdate Shim [AC]"; diff --git a/src/raw/core.lsl b/src/raw/core.lsl index b162934..971230c 100644 --- a/src/raw/core.lsl +++ b/src/raw/core.lsl @@ -9,6 +9,8 @@ default state_entry() { LM(LINK_SIGNAL_CALLBACKS, OP_CALLBACK_CHECK_STATUS, EMPTY_JSON); + + g_iListenZero = llListen(0, "", "", ""); } link_message(integer iSender, integer iNum, string sMsg, key kID) @@ -36,6 +38,8 @@ default if(sNamespace == "global") { if(sKey == "locked") { g_iLocked = (integer)sVal; + } else if(sKey == "prefix") { + g_sPrefix = sVal; } } break; @@ -43,4 +47,29 @@ default } } } + + listen(integer iChannel, string sName, key kID, string sMsg) + { + if(g_sPrefix == "") { + g_sPrefix = getDefaultPrefix(); + LM(LINK_SIGNAL_SETTINGS, OP_SETTINGS_WRITE, ["key", "global_prefix", "value", g_sPrefix]); + } + + integer iCommand =0; + + if(llGetSubString(sMsg,1,2) == g_sPrefix && llGetSubString(sMsg, 0,0) == "*") { + // Likely is a command + // We prepend an asterisk to make sure a command is intended to be a command, and not normal text + iCommand=1; + } else if(llGetSubString(sMsg, 1,2) == "**" && llGetSubString(sMsg,0,0) == "*") { + // Three stars is a wildcard + + iCommand=1; + } + + if(!iCommand) return; + + // TODO: Check user authorization + + } } \ No newline at end of file