Multiple match handlers

Hi,

How do I create multiple match handlers ?

Each has a module name, that works.

But then, when I try to initialize initializer.registerMatch(moduleName) :

-If matchInit and all the others appears twice, VS Code throws me an error saying that I can’t redeclare these block scoped variables.

If I try to change their names like moduleNameMatchInit for instance, VS Code throws me an error saying that moduleNameMatchInit does not exist in type MatchHandler…

Can you please provide code examples? It’s not possible to figure out what the issue is…

So, in the main.ts we have the two initializers :

  initializer.registerMatch(moduleNamePairImpairVsBot, {
        matchInit,
        matchJoinAttempt,
        matchJoin,
        matchLeave,
        matchLoop,
        matchTerminate,
        matchSignal,
    });

    initializer.registerMatch(moduleNamePairImpairPvP, {
        PairImpairPvPMatchInit,
        PairImpairPvPMatchJoinAttempt,
        PairImpairPvPMatchJoin,
        PairImpairPvPMatchLoop,
        PairImpairPvPMatchLeave,
        PairImpairPvPMatchTerminate,
        PairImpairPvPMatchSignal
    });

Like this it throws me the following error :

Argument of type ‘{ PairImpairPvPMatchInit: nkruntime.MatchInitFunction; PairImpairPvPMatchJoinAttempt: nkruntime.MatchJoinAttemptFunction; PairImpairPvPMatchJoin: nkruntime.MatchJoinFunction; PairImpairPvPMatchLoop: nkruntime.MatchLoopFunction; PairImpairPvPMatchLeave: nkruntime.MatchLeaveFunction; PairImpairPvPMatchTerminate: nkrun…’ is not assignable to parameter of type ‘MatchHandler’.
Object literal may only specify known properties, and ‘PairImpairPvPMatchInit’ does not exist in type ‘MatchHandler’.

If I try to change the names of the variables of the second initializer to get them back to the default ones, it says the following for each :

‘matchJoinAttempt’ was also declared here. (indicating the matchJoinAttempt of the first module, it does it with every other variable, matchInit, matchLoop etc)

Hi again,
Any update on this ? As I’m close to a client’s deadline, thanks

This is a simple Javascript issue that you have in your code:

initializer.registerMatch(moduleNamePairImpairVsBot, {
        matchInit: matchInit,
        matchJoinAttempt: matchJoinAttempt,
        matchJoin: matchJoin,
        matchLeave: matchLeave,
        matchLoop: matchLoop,
        matchTerminate: matchTerminate,
        matchSignal, // <-- using a JS shortcut as the field name matches the variable name
    });

    initializer.registerMatch(moduleNamePairImpairPvP, {
        matchInit: PairImpairPvPMatchInit, // <-- field name doesn't match the variable name, therefore we must specify field name
        matchJoinAttempt: PairImpairPvPMatchJoinAttempt,
        matchJoin: PairImpairPvPMatchJoin,
        matchLoop: PairImpairPvPMatchLoop,
        matchLeave: PairImpairPvPMatchLeave,
        matchTerminate: PairImpairPvPMatchTerminate,
        matchSignal: PairImpairPvPMatchSignal
    });

Thanks it worked.