From 6d5ac839af8df81fe5511c157f0086dcaa986f34 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 29 Jul 2021 09:53:02 +0200 Subject: [PATCH] add npc commands --- Chris.MultiNPC.lsl | 66 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/Chris.MultiNPC.lsl b/Chris.MultiNPC.lsl index 311241c..ade77d7 100644 --- a/Chris.MultiNPC.lsl +++ b/Chris.MultiNPC.lsl @@ -21,7 +21,7 @@ default state_entry() { removeOldNPC(); - + m_lastTimeCheck = llGetUnixTime(); checkOSPermissions(); readAllNPCPathNC(); @@ -74,10 +74,10 @@ state running if (change & CHANGED_REGION_START) hardReset(); } - + on_rez(integer start_param) { - hardReset(); + hardReset(); } } @@ -197,6 +197,48 @@ integer script_appearance(integer slot, key npc, list command) return TRUE; } +integer script_animation(integer slot, key npc, list command) +{ + if(llGetInventoryType(llList2String(command, 1)) != INVENTORY_ANIMATION) + { + llSay(0, "Cant find animation '" + llList2String(command, 1) + "'."); + return FALSE; + } + + osNpcPlayAnimation(npc, llList2String(command, 1)); + return TRUE; +} + +integer script_StopAnimation(integer slot, key npc, list command) +{ + if(llGetInventoryType(llList2String(command, 1)) != INVENTORY_ANIMATION) + { + llSay(0, "Cant find animation '" + llList2String(command, 1) + "'."); + return FALSE; + } + + osNpcStopAnimation(npc, llList2String(command, 1)); + return TRUE; +} + +integer script_profileImage(integer slot, key npc, list command) +{ + if(llGetInventoryType(llList2String(command, 1)) != INVENTORY_TEXTURE) + { + llSay(0, "Cant find image '" + llList2String(command, 1) + "'."); + return FALSE; + } + + osNpcSetProfileImage(npc, llList2String(command, 1)); + return TRUE; +} + +integer script_profileText(integer slot, key npc, list command) +{ + osNpcSetProfileAbout(npc, llList2String(command, 1)); + return TRUE; +} + integer script_include(integer slot, key npc, list command) { if(llGetInventoryType(llList2String(command, 1) + ".path") != INVENTORY_NOTECARD) @@ -323,6 +365,22 @@ doNextScriptStep() if(script_appearance(currentNPCSlot, currentNPCKey, lineCommandData)) currentNPCSlot--; break; + case "animation": + if(!script_animation(currentNPCSlot, currentNPCKey, lineCommandData)) + llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); + break; + case "stopAnimation": + if(!script_StopAnimation(currentNPCSlot, currentNPCKey, lineCommandData)) + llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); + break; + case "profileImage": + if(!script_profileImage(currentNPCSlot, currentNPCKey, lineCommandData)) + llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); + break; + case "profileText": + if(!script_profileText(currentNPCSlot, currentNPCKey, lineCommandData)) + llSay(0, "Script execution in '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); + break; default: llSay(0, "Unknown command '" + llList2String(lineCommandData, 0) + "' in nc '"+ currentncname +"' on line '" + currentLine + "' failed."); } @@ -402,7 +460,7 @@ createNPCTempStorage() npcKeys += [currentNPCKey]; } - osSetPrivateDataValue("tmpNPCList." + llGetKey(), llList2CSV(npcKeys)); + osSetPrivateDataValue("tmpNPCList." + llGetKey(), llList2CSV(npcKeys)); } removeOldNPC()