-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
There was a problem hiding this 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
Crazy stuff! |
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"]) |
@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? |
Oh it's in python? Thank god... |
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? |
@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... |
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. |
@britzl alright the argument actually makes a lot of sense. Just wish we had docs to refer to.. Lets go for the change. |
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 |
Duplicate of #47 |
No description provided.