Update Missing-anim-finder.lsl

This commit is contained in:
codeviolet 2018-02-15 16:58:54 +11:00 committed by Sei-Lisa
parent 94309edba5
commit 103d9611d9

View file

@ -17,9 +17,11 @@
string notecard_basename = "AVpos";
integer variable1;
key notecard_query;
list ALL_USED_ANIMATIONS;
list ALL_USED_ANIMS;
list UNUSED_ANIMS;
integer NOT_FOUND_COUNT;
integer IS_VARIABLE_SPEED_SUBMENU;
list VARIABLE_SPEED_ANIMS;
Owner_Say(string say)
{
@ -64,19 +66,30 @@ default
{
if (data == EOF)
{
if(NOT_FOUND_COUNT>0){
if(!NOT_FOUND_COUNT){
Owner_Say("All animations referenced in the notecard were accounted for.");
}
else{
Owner_Say("Anims were used in the notecard but not found in inventory!");
}
integer i;
for (i = 0; i < llGetInventoryNumber(INVENTORY_ANIMATION); i++)
{
integer isVariableSpeed;
string anim_basename = llGetInventoryName(INVENTORY_ANIMATION, i);
if(llListFindList(["+","-"], [llGetSubString(anim_basename,-1,-1)]) != -1)
{
isVariableSpeed=TRUE;
anim_basename = llGetSubString(anim_basename,0,-2);
}
if (llListFindList(ALL_USED_ANIMATIONS, [anim_basename]) == -1 && llListFindList(["AVhipfix"], [llGetInventoryName(INVENTORY_ANIMATION, i)]) == -1)
integer index = llListFindList(ALL_USED_ANIMS, [anim_basename]);
if(index != -1 && isVariableSpeed == TRUE && llList2Integer(VARIABLE_SPEED_ANIMS,index) == FALSE){
Owner_Say("Variable-Speed Animation '" + llGetInventoryName(INVENTORY_ANIMATION, i) + "' found in inventory but the associated submenu(s) are not set as Variable-Speed submenu(s)!");
UNUSED_ANIMS += llGetInventoryName(INVENTORY_ANIMATION, i);
}
else if (index == -1 && llListFindList(["AVhipfix"], [llGetInventoryName(INVENTORY_ANIMATION, i)]) == -1)
{
Owner_Say("Animation '" + llGetInventoryName(INVENTORY_ANIMATION, i) + "' found in inventory but not used in notecard!");
UNUSED_ANIMS += llGetInventoryName(INVENTORY_ANIMATION, i);
@ -84,7 +97,7 @@ default
}
if (llGetListLength(UNUSED_ANIMS))
{
llDialog(llGetOwner(), "\n" + (string)llGetListLength(UNUSED_ANIMS) + " unused anims were found. Do you want to delete them?\n\nMake sure you take a backup of your work first!", ["YES", "NO"], -268534);
llDialog(llGetOwner(), "\n" + (string)llGetListLength(UNUSED_ANIMS) + " unused (surplus) anims were found. Do you want to delete them?\n\nMake sure you take a backup of your work first!", ["YES", "NO"], -268534);
llListen(-268534, "", llGetOwner(), "");
llSetTimerEvent(60);
}
@ -111,7 +124,36 @@ default
NOT_FOUND_COUNT += 1;
Owner_Say("Animation '" + llList2String(anims, i) + "' not found in inventory!");
}
ALL_USED_ANIMATIONS += llList2String(anims, i);
if(IS_VARIABLE_SPEED_SUBMENU)
{
if (llGetInventoryType(llList2String(anims, i)+"+") != INVENTORY_ANIMATION)
{
Owner_Say("Variable-Speed Animation '" + llList2String(anims, i) + "+' not found in inventory!");
}
if (llGetInventoryType(llList2String(anims, i)+"-") != INVENTORY_ANIMATION)
{
Owner_Say("Variable-Speed Animation '" + llList2String(anims, i) + "-' not found in inventory!");
}
}
integer index = llListFindList(ALL_USED_ANIMS,[llList2String(anims, i)]);
if(index == -1){ //only add to the list if the anim has not appeared before
ALL_USED_ANIMS += llList2String(anims, i);
VARIABLE_SPEED_ANIMS += IS_VARIABLE_SPEED_SUBMENU;
}
else if(IS_VARIABLE_SPEED_SUBMENU == TRUE){
// prevent variable-Speed anims from being incorrectly tagged as surplus in cases where: they are included in multiple submenus/sitters and where only in some places the submenus aren't set as Variable-Speed submenus.
// ensure it stays TRUE if ANY of the submenus that the anim is used in are set as Variable-Speed submenus.
VARIABLE_SPEED_ANIMS=llListReplaceList(VARIABLE_SPEED_ANIMS,[TRUE],index,index);
}
}
}
else if (command == "MENU" || command == "SITTER")
{
IS_VARIABLE_SPEED_SUBMENU=FALSE;
if(command == "MENU" && llList2String(parts,-1) == "V")
{
IS_VARIABLE_SPEED_SUBMENU=TRUE;
}
}
notecard_query = llGetNotecardLine(notecard_basename, ++variable1);