Love2D with Nakama

Hello,

I’m trying do use Nakama with Love2D game engine.
I read the Lua Client docs but I’m kind of stuck.

I use the last Nakama Server but I got a Unable to login and no new device is visible on my Nakama Console.

local function device_login(client)
	local body = nakama.create_api_account_device(love2d.uuid())
	local result = nakama.authenticate_device(client, body, true)
    if result then
        if result.token then
            nakama.set_bearer_token(client, result.token)
            return true
        end
    end
	print("Unable to login")
	return false
end

--CORE FUNCTION
function love.load()
    --load nakama
	local config = {
        host = "127.0.0.1",
        port = 7350,
        use_ssl = false,
        username = "defaultkey",
        password = "",
        engine = love2d,
        timeout = 10,
	}
	local client = nakama.create_client(config)

    nakama.sync(function()
        device_login(client)
    end)

EDIT! The current output of the authenticate_device is equal to nil and I still don’t get where to correct this

Hi @shioridotdev welcome to the forum.

Please can you check that you’re getting a valid value for body which you’re passing to the authenticate_device function.

Thanks for the reply,

For the output of the body before passing it to the authenticate_device it’s

{ ["id"] = 5c251fc8-5643-4403-c433-04ed336b0dff,}

Here is another output
As I continue the debugging, seems like I got a little issue with coroutine.

Without coroutine

init()
authenticate_device() with callback
HTTP    POST    http://127.0.0.1:7350/v2/account/authenticate/device?create=true&username=shioridotdev
DATA    {"id":"dd5cb811-8c7c-4f83-cfbc-04ed336b0dff"}
Unable to login

With coroutine

init()
authenticate_device() with coroutine
HTTP    POST    http://127.0.0.1:7350/v2/account/authenticate/device?create=true
DATA    {"id":"b417483f-bad6-44e9-c413-04ed336b0dff"}

EDIT:
My program doesn’t go inside the fn function in async.lua arround line 12

	fn(function(...)
		results = { ... }
		if state == "YIELDED" then
			local ok, err = coroutine.resume(co)
			if not ok then print(err) end
		else
			state = "DONE"
		end
	end, ...)
	if state == "RUNNING" then
		state = "YIELDED"
		coroutine.yield()
		state = "DONE"		-- not really needed
	end

EDIT 2 : I set up a github repo to checkout the whole code if necessary
nakama-love2d repository

Hello there !

Still in need of some hint.
Trying to work around it but still same issue.

@shioridotdev I’m a bit lost on where you’re stuck. Would you be able to summarize it again?

Hello,

Thanks for your answer, I’m sorry for being late in the respond and sorry if my first post was not too clear, I will try to translate better my issue in English, feel free to ask me again if I didn’t write it properly again.

What I’m trying to do:
Setting up a client base on Love2D game engine (LUA language) and make it workable with Nakama Server.

What is currently working:
Client start properly and the log are those next few lines

init()
authenticate_device() with coroutine
HTTP    POST    http://127.0.0.1:7350/v2/account/authenticate/device?create=true
DATA    {"id":"b417483f-bad6-44e9-c413-04ed336b0dff"}

What is not working:
No new user/device are register in the Nakama Server

How to reproduce it
I set up a GIT repository that you can use to see the whole code.
nakama-love2d repository

Version use
Love2d v11.3
Nakama v3.9.0

Hello,

I’m coming back on this thread to get some update about my issue that is still
ongoing.

Currently looking for where it come from.

If anyone got some hint on it I’m listening.

Thanks for your time.

Hi @shioridotdev

do you get any errors in the server when trying to authenticate?

Hello @ftkg

The only last docker log I have is the startup message:

{"level":"info","ts":"2022-02-28T08:04:08.298Z","caller":"main.go:175","msg":"Startup done"}

Thanks for your qucik reply

@shioridotdev Can you capture the error that comes back from authenticate_device() and print it out? You can do that using the pcall() function.

Hello,

Can you guide me for using the pcall function?
When trying to use it I got this as output:

false   attempt to call a table value

Also on my previous message you got the github page for the project if you got time to look on it.

Thanks

See some examples here: nakama-project-template/daily_rewards.lua at master · heroiclabs/nakama-project-template · GitHub

Thanks for the reply, will look on it and get back here for the log.

Hello,

Just a fallback on the current issue.
I can’t seems to found any error output on the nakama log.

Hello,

Sorry to push again this post but I still don’t found any solution to my issue.

Thanks a lot for your time

Can you post your new code with the pcall() function?