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…
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)
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
});