# Different modules for different games

**URL:** <https://forum.heroiclabs.com/t/different-modules-for-different-games/1103>\
**Category:** Local Setup\
**Created:** [November 3, 2020, 7:02pm UTC](https://forum.heroiclabs.com/t/different-modules-for-different-games/1103 "2020-11-03T19:02:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Korama](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Korama](https://forum.heroiclabs.com/u/Korama)\
**Post date:** [November 3, 2020, 7:02pm UTC](https://forum.heroiclabs.com/t/different-modules-for-different-games/1103/1 "2020-11-03T19:02:36Z")

</div>

Hi again Heroic Labs,

Loving Nakama so far, but I have one small question; I was wondering if it’s possible to load different authoritative multiplayer server modules through the lua function makematch()\*? For instance, a platform with minigames (each with custom game logic/modules), all available through the matchmaker.

Thank you!

\*Found here [https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/](https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/)

> local nk = require(“nakama”)
> 
> local function makematch(context, matched\_users)  
> – print matched users  
> for \_, user in ipairs(matched\_users) do  
> local presence = user.presence  
> nk.logger\_info((“Matched user ‘%s’ named ‘%s’”):format(presence.user\_id, presence.username))  
> for k, v in pairs(user.properties) do  
> nk.logger\_info((“Matched on ‘%s’ value ‘%s’”):format(k, v))  
> end  
> end
> 
> local modulename = “pingpong”  
> local setupstate = { invited = matched\_users }  
> local matchid = nk.match\_create(modulename, setupstate)  
> return matchid  
> end  
> nk.register\_matchmaker\_matched(makematch)

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [November 3, 2020, 10:26pm UTC](https://forum.heroiclabs.com/t/different-modules-for-different-games/1103/2 "2020-11-03T22:26:41Z")

</div>

@Korama Sure, the multiplayer engine in designed to let you register different match handlers with different names which can be created with the `MatchCreate` server runtime function. You can register different match handlers with code like you have above:

```lua
-- minigame1.lua
local nk = require("nakama")

return {
    -- implement all the match lifecycle functions
}

```

```lua
-- minigame2.lua
local nk = require("nakama")

return {
    -- implement all the match lifecycle functions
}

```

Then you’d create a match from one of the mini games with:

```lua
local matchid = nk.match_create("minigame1", { some = "initial input" })
-- OR
local matchid = nk.match_create("minigame2", { some = "initial input" })

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Korama](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Korama](https://forum.heroiclabs.com/u/Korama)\
**Post date:** [November 3, 2020, 10:49pm UTC](https://forum.heroiclabs.com/t/different-modules-for-different-games/1103/3 "2020-11-03T22:49:36Z")

</div>

Thanks @novabyte, that does help - but what I’m wondering is if there’s any way the _makematch_ function above can discriminate between different matchmaker queries, and thus load different multiplayer modules depending on what those queries are. C’est possible?

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [November 3, 2020, 10:57pm UTC](https://forum.heroiclabs.com/t/different-modules-for-different-games/1103/4 "2020-11-03T22:57:41Z")

</div>

@Korama Yep, just look at the data properties passed in for the `"matched_users"`. For the match maker to return a match which fits what the players looked for each player would have needed to pass in the match type they’re interested in.

For example with a search query in the matchmaker like: `"+properties.match_type:minigame1"` the player has said they’re only interested to match against players who exact searched on the `"minigame1"`. Their data properties passed into the matchmaker would have looked like:

```auto
var query = "+properties.match_type:minigame1";
var stringProps = new Dictionary<string, string>() {
  {"match_type", "minigame1"}
};
var numericProps = new Dictionary<string, int>() {};
var matchmakerTicket = await socket.AddMatchmakerAsync(query, 2, 4, stringProps, numericProps);

```

You can extract these properties which each player matched by the matchmaker within the `"matched_users"` LTable in the Lua code above.

---

<div class="post-metadata">

**Author:** ![Korama](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Korama](https://forum.heroiclabs.com/u/Korama)\
**Post date:** [November 3, 2020, 11:04pm UTC](https://forum.heroiclabs.com/t/different-modules-for-different-games/1103/5 "2020-11-03T23:04:51Z")

</div>

Perfect that’s exactly it! Thank you so much ❤
