„Chris.MultiNPC.lsl“ ändern

This commit is contained in:
Christopher 2021-07-31 18:59:27 +00:00
parent 5a3cb6c115
commit e27c3d233d
1 changed files with 39 additions and 1 deletions

View File

@ -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;
}