Yanfly's BattleEngineCore Escape Ratio

The default escape ratio is

0.5 * $gameParty.agility() / $gameTroop.agility()

and I wanted to change agility to luck but got an error saying luck isn't defined. Can agility be changed to luck, attack or another parameter?

There is no command to compute the parties Luck in the engine. The old command calls a built in formula which computes the entire parties agility and returns it. But there is no equivalent one for luck, you'll have to write the command yourself as a plug-in and add it in before that will work.
That's the key point, every actor has agility, luck, attack, etc. defined but they wrote a special formula to calculate the party agility (which is just the average agility i.e. sum divided by number of actors).

If you wanted to calculate the party luck the same way, you can add this code to a new plugin. Then, you could use the formula as you've written it above.
Code:
Game_Unit.prototype.luck= function() {
   //Game_Unit is the parent of Game_Party and Game_Troop
   //This means that any functions owned by Game_Unit are inherited
   //by Game_Party and Game_Troop

   var members = this.members();
   //Define a new variable called 'members'
   //This variable is local to this function
   //Fill members with all the members of the unit (party / troop, depending)
   //This is now an Array of the unit members

   if (members.length === 0) {
      return 1;
   }
   //If the unit is empty for some reason, leave the function
   //It should never happen, but this is a failsafe so the game
   //doesn't crash

   var sum = members.reduce(function(r, member) {
      return r + member.luk;
   }, 0);
   //Define a new variable called 'sum'
   //This variable is local to this function
   //reduce is a function we can use on Arrays that can easily
   //calculate a sum

   return sum / members.length;
   //The 'sum' divided by the number of unit members gives
   //us the average
   //We return this value back outside the function to whatever is
   //asking for it
};
@Aloe Guvner Wow thanks! Never wrote a plugin before. I guess this is as good a chance as ever though.
Well then, exciting! In that case, I've edited the post above to include comments in the code to help explain what it is doing.
It worked! And I have my first plugin. Man do I feel accomplished. This could be the start of a long road to something beautiful.

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-battleenginecore-escape-ratio.93571/