-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Vector2/3/4 cannot be converted into JSON #1931
Comments
to keep backward compatibility, this kind of change require toJSON and fromJSON accept another argument ( which in general extend what can be converted ), i'm sure some servers already storing some kind of coords in json like above. |
Another argument? I think everything needs to be done is to change a little |
or, use metatables for this purpose, __tojson and __fromjson keys would be responsible for conversion |
Just changing
|
Just use toJSON({0,0,0}). And with this you can even unpack it and set the position of an element with setElementPosition(element, unpack(fromJSON(pos))). I don't think it's necessary to use Vector3 in this case. |
I think that only Btw. we can use this: Vector3(fromJSON(something)) and it works. Btw. it's not even mentioned on wiki that developers can use table as parametr for Vector3.create method (aka constructor). |
I don't know how |
Describe the bug
I decided do create some simple system where there are some positions saved into DB. Ok so at the 'save this thing into database' line of code I tried to create JSON from Vector3 and get an error that it cannot be done because it's userdata.
To reproduce
Expected behaviour
There should be JSON from Vector3
Version
Additional context
Meybe matrix should be JSON formattable also?
The text was updated successfully, but these errors were encountered: