From e27c3d233da91933e3e0b84d5c4b4f2f0568b997 Mon Sep 17 00:00:00 2001 From: Christopher Date: Sat, 31 Jul 2021 18:59:27 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=9EChris.MultiNPC.lsl=E2=80=9C=20=C3=A4nd?= =?UTF-8?q?ern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Chris.MultiNPC.lsl | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Chris.MultiNPC.lsl b/Chris.MultiNPC.lsl index 6ed244d..bbcaebf 100644 --- a/Chris.MultiNPC.lsl +++ b/Chris.MultiNPC.lsl @@ -89,6 +89,24 @@ hardReset(string message) llResetScript(); } +integer getGoToLine(integer slot, string target) +{ + integer currentLine = 0; + + string currentPath = getDataEntryFromDataList(m_npcdata, "npc." + slot + ".path"); + list pathLineData = llParseString2List(currentPath, [";"], []); + + for (currentLine = 0; currentLine < llGetListLength(pathLineData); currentLine++) + { + string line = llList2String(pathLineData, currentLine); + + if(line == target) + return currentLine; + } + + return 0; +} + //Script Engine doNextScriptStep() { @@ -144,6 +162,13 @@ doNextScriptStep() m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + currentNPCSlot + ".line", currentLine); + if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == ":") + { + currentNPCSlot--; + continue; + } + + if(llGetSubString(llList2String(lineCommandData, 0), 0, 0) == "%") { string storageKey = llMD5String(llList2String(lineCommandData, 0), 0); @@ -359,7 +384,20 @@ integer script_touch(integer slot, key npc, list command) integer script_goto(integer slot, key npc, list command) { - m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot + ".line", (integer)llList2String(command, 1) - 1); + integer targetLine = (integer)llList2String(command, 1); + + if(targetLine == 0) + { + targetLine = getGoToLine(slot, ":" + llList2String(command, 1)); + } + + if(targetLine == 0) + { + llSay(0, "Cant find the GoTo Target '" + llList2String(command, 1) + "'."); + return FALSE; + } + + m_npcdata = setDataEntryInDataList(m_npcdata, "npc." + slot + ".line", targetLine - 1); return TRUE; }