Hello, I’m a software engineer (primarily C++) and I’ve just started using Godot, Nakama & lua. I’m loving it so far, it’s going really well except a few things I have questions about and can’t seem to find the answer online:
-
How do I set the token expiry time? It seems really short currently and I don’t want to run a loop or check expired (and re-authenticate if so) every time I make a server call.
-
I can’t seem to ever get multiple matches happening at the same time. If I create one match then another, nakama.match_list() seems to only return one of them. Is there something I’m missing?
-
My match state doesn’t seem to be returning via match_init() (or existing at all, ever). What am I doing wrong in this case?
Here is my rpc module (related to question 2, the logger_info call is just to see what I’m getting back)
local nakama = require("nakama")
local function create_match(_, payload)
return nakama.match_create("cube_draft", {initial_state = payload})
end
local function get_match_list(_, _)
local matches = nakama.match_list()
for _, m in ipairs(matches) do
nakama.logger_info(string.format("ID: %q, Name: %q", m.match_id, m.label))
end
return nakama.json_encode(nakama.match_list())
end
nakama.register_rpc(create_match, "create_match")
nakama.register_rpc(get_match_list, "get_match_list")
And here is a snippet from my match module (related to question 3)
local nakama = require("nakama")
local cube_draft = {}
-- These should match the keys in N_Messages
local KEY_MATCH_NAME = "match_name"
local KEY_MATCH_SEED = "match_seed"
function cube_draft.match_init(context, params)
local json = nakama.json_decode(params.initial_state)
local state = {
has_started = false,
seed = json[KEY_MATCH_SEED],
presences = {},
player_indices = {},
picks = {},
review_complete = {}
}
local tick_rate = 4
local label = json[KEY_MATCH_NAME]
return state, tick_rate, label
end