Crafting Best/Worst Unstash

Version 2 Tintin++ Blacksmithing/Enchanting script.
3 Commands are available. The most straightforward is:
"produce"

If you have a moulding in your inventory, this will examine the moulding, unstash the appropriate ingredients from your satchel and insert them in the kiln/forge. You can specify "produce best" or "produce worst" to get the best or worst ingredients for the recipe.

WARNING: This does not currently take into account missing ingredients or gems, so these will need to be added manually. You will need to type "fire" once it has completed.

"unstash"
A lot more flexible version of the mud unstash command. This will take unstash commands in several different formats:

unstash <quality> <item>
unstash <quantity> <item>
unstash <quantity> <quality> <item>

2 new quality types have been added, "best" and "worst". These will look at your current satchel contents for whatever item you've asked for, and will unstash one or more of the highest or lowest quality you currently have available.

When no quality is specified, the command will default to "any".

Examples:

"unstash gold bar" unstashes a random gold bar
"unstash 2 gold bar" unstashes any 2 gold bars
"unstash 5 worst gold bar" unstashes the worst 5 gold bars in your satchel
"unstash 3 average gold bar" unstashes 3 average quality gold bars, if you have them

"smith"
Takes the same parameters as unstash, in the same format, but will insert the unstashed ingredient into the forge/kiln automatically once it has been taken from the satchel.

#NOP ************************************************
#NOP 3k Automatic Crafting - Balthus
#NOP Version 2.1:
#NOP Updated to cater for changes to stashlist layout
#NOP ************************************************
#VAR {lCraftQuality} {{legendary}{superior}{good}{average}{poor}{crude}{worthless}};
#VAR {lCraftQualityAll} {{best}{worst}{all}{any}${lCraftQuality}};
#alias {unstash}
{
  #REGEX {%1} {^\d+$} 
  {
    #VAR {vCraftUnstashCount} {%1};
    #FORMAT {vCraftUnstashType} {%l} {%2};
    #FORMAT {vCraftUnstashItem} {%p} {{%3 %4 %5 %6 %7 %8 %9}};
  }
  {
    #VAR {vCraftUnstashCount} {1};
    #FORMAT {vCraftUnstashType} {%l} {%1};
    #FORMAT {vCraftUnstashItem} {%p} {{%2 %3 %4 %5 %6 %7 %8}};
  };
  #LIST {lCraftQualityAll} {fnd} {$vCraftUnstashType} {vCraftUnstashTypeMatch};
  #IF {$vCraftUnstashTypeMatch < 1} 
  {
    #VAR {vCraftUnstashItem} {$vCraftUnstashType $vCraftUnstashItem};
    #VAR {vCraftUnstashType} {any};
  };
  #IF {"$vCraftUnstashType" == "best" || "$vCraftUnstashType" == "worst"}
  {
    #VAR {vItemCapitalised} {$gvNull};
    #FORALL {$vCraftUnstashItem}
    {
      #FORMAT {vCraftCapitalWord} {%n} {&0};
      #VAR {vItemCapitalised} {$vItemCapitalised $vCraftCapitalWord};
    };
    #FORMAT {vItemCapitalised} {%p} {{$vItemCapitalised}};
    #FORALL {{$vItemCapitalised}}
    {
      #CLASS {&0} {kill};
      #CLASS {&0} {open};
      #VAR {l&0List} {{0}{0}{0}{0}{0}{0}{0}};
      #VAR {v&0Count} {$vCraftUnstashCount};
      #VAR {v&0Type} {$vCraftUnstashType};
      #VAR {v&0Start} {0};
      #VAR {v&0End} {0};
      #VAR {v&0Sent} {false};
      #FORMAT {v&0LowerCase} {%l} {{&0}};
      #action {^%*&0%*%s|%s%d%s|%s%d%s|%s%d%s|%s%d%s|%s%d%s|%s%d%s|%s%d%s|%s%d%s|} 
      {
        #LIST {l&0List} {set} {1} {%%8};
        #LIST {l&0List} {set} {2} {%%11};
        #LIST {l&0List} {set} {3} {%%14};
        #LIST {l&0List} {set} {4} {%%17};
        #LIST {l&0List} {set} {5} {%%20};
        #LIST {l&0List} {set} {6} {%%23};
        #LIST {l&0List} {set} {7} {%%26};
        #IF {"${v&0Type}" == "worst"}
        {
          #VAR {v&0Start} {7};
          #VAR {v&0End} {1};
        }
        {
          #VAR {v&0Start} {1};
          #VAR {v&0End} {7};
        };
        #loop {${v&0Start} ${v&0End}}
        {
          #LOOP {1 ${l&0List}[&&0]} 
          {
            #IF {${l&0List}[&&0] > 0 && ${v&0Count} > 0}
            {
              #MATH {v&0Count} {${v&0Count} - 1};
              #VAR {v&0Sent} {true};
              #SEND {!unstash $lCraftQuality[&&0] ${v&0LowerCase}};
            }; 
          };
        };
        #CLASS {&0} {kill};
      };
      #CLASS {&0} {close};
    };
    #SEND {!stashlist $vCraftUnstashItem};
  }
  {
    #LOOP {1 $vCraftUnstashCount}
    {
      #SEND {!unstash $vCraftUnstashType $vCraftUnstashItem};
    };
  };
};
#alias {smith}
{
  #REGEX {%1} {^\d+$} 
  {
    #VAR {vCraftSmithCount} {%1};
    #FORMAT {vCraftSmithType} {%l} {%2};
    #FORMAT {vCraftSmithItem} {%p} {{%3 %4 %5 %6 %7 %8 %9}};
  }
  {
    #VAR {vCraftSmithCount} {1};
    #FORMAT {vCraftSmithType} {%l} {%1};
    #FORMAT {vCraftSmithItem} {%p} {{%2 %3 %4 %5 %6 %7 %8}};
  };
  #LIST {lCraftQualityAll} {fnd} {$vCraftSmithType} {vCraftSmithTypeMatch};
  #IF {$vCraftSmithTypeMatch < 1} 
  {
    #VAR {vCraftSmithItem} {$vCraftSmithType $vCraftSmithItem};
  };
  #VAR {$vCraftSmithItem} {$vCraftSmithCount};
  #FORALL {{$vCraftSmithItem}}
  {
    #ACTION {You pull a %w &0 from your satchel.}
    {
      #SEND {!insert &0};
      #MATH {&0} {${&0} - 1};
      #IF {${&0} < 1}
      {
        #UNVAR {&0};
        #UNACTION {You pull a %w &0 from your satchel.};
      };
    };
  };
  #UNVAR {vCraftSmithItem};
  #UNVAR {vCraftSmithCount};
  #UNVAR {vCraftSmithType};
  #UNVAR {vCraftSmithTypeMatch};
  unstash %0;
};
#alias {produce}
{
  #ACTION {^-INGREDIENTS-}
  {
    #ACTION {^%d %*$}
    {
      smith %%%1 %1 %%%2;
    };
    #ACTION {^>}
    {
      #UNACTION {^%%d %%*$};
      #UNACTION {^-INGREDIENTS-};      
    };
  };
  #SEND {!exa moulding};
  #SEND {!insert moulding};
};
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License