Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow skipping optional arguments #46

Closed
wants to merge 1 commit into from

Conversation

SamsTheGreatest
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented May 11, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@britzl britzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generated code. Changes should be made to the code generator template. More info about the code generator can be found here: https://github.com/heroiclabs/nakama-defold/tree/master/codegen

@SamsTheGreatest
Copy link
Contributor Author

This is generated code. Changes should be made to the code generator template. More info about the code generator can be found here: https://github.com/heroiclabs/nakama-defold/tree/master/codegen

Crazy stuff!

@britzl
Copy link
Collaborator

britzl commented May 11, 2022

What we need is to change this:

https://github.com/heroiclabs/nakama-defold/blob/master/codegen/realtime.py#L203-L204

We want to check if a value is of the correct type or nil. Example:

assert(_G.type(some_string_var) == 'string' or some_string_var == nil)

So the relevant lines of the code generator should be changed to:

	for prop in props:
		lua = lua + "	assert(_G.type(%s) == '%s' or %s == nil)\n" % (prop["name"], prop["type"], prop["name"])

@SamsTheGreatest
Copy link
Contributor Author

SamsTheGreatest commented May 11, 2022

@britzl I would guess this shall only happen for args[4:] as the first 3 are essential? And only for this specific function right... So there shall be some function checks additionaly?

@SamsTheGreatest
Copy link
Contributor Author

Oh it's in python? Thank god...

@britzl
Copy link
Collaborator

britzl commented May 11, 2022

I would guess this shall only happen for args[4:] as the first 3 are essential? And only for this specific function right...

I would assume that there are other functions which also have optional arguments. We either do it for all functions and all arguments or none at all. How can we know which arguments that are optional if the API specification doesn't state it?

@SamsTheGreatest
Copy link
Contributor Author

@britzl thats exactly what we discussed in the issue with missing docs... I guess if doing it for all of them would be a quick fix, but then if user doesnt give any parameters at all, lua will not throw any errors, only server will - could be a little more tricky to debug...

@britzl
Copy link
Collaborator

britzl commented May 11, 2022

but then if user doesnt give any parameters at all, lua will not throw any errors, only server will

Sure, but what is the likelihood of that happening? You may also give the wrong values in which case the server will also return an error.

@SamsTheGreatest
Copy link
Contributor Author

@britzl alright the argument actually makes a lot of sense. Just wish we had docs to refer to.. Lets go for the change.

@britzl
Copy link
Collaborator

britzl commented May 11, 2022

Just wish we had docs to refer to..

Keep in mind that all of the clients use a very similar API. You should be able to refer to any of the other clients if something is missing from the Defold docs.

https://heroiclabs.com/docs/nakama/concepts/multiplayer/matchmaker/

Also, while I do recognise that it is not very beginner friendly, but you can also look at the source code itself. Here's the MatchmakerAdd message and what each field means:

https://github.com/heroiclabs/nakama-common/blob/master/rtapi/realtime.proto#L365-L379

@britzl
Copy link
Collaborator

britzl commented May 12, 2022

Duplicate of #47

@britzl britzl marked this as a duplicate of #47 May 12, 2022
@britzl britzl closed this May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants