Closed SamsTheGreatest closed 2 years ago
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 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?
@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...
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.
@britzl alright the argument actually makes a lot of sense. Just wish we had docs to refer to.. Lets go for the change.
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
Duplicate of https://github.com/heroiclabs/nakama-defold/pull/47
All committers have signed the CLA.