-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat(scripting/v8): support unpacking Lua vectors #3019
base: master
Are you sure you want to change the base?
Conversation
It will break my scripts and i don't think of any way to fix the breaking, my use case is : JS script receive data in any form or types from Lua (db documents) and use the current extension type 20, 21, 22 in the variable to check if the variable was a vector in Lua. |
Refusing to support vectors because of backwards compatibility is stupid.
Not having support for arrays or objects with xyz properties, strictly expecting vectors only, seems like a bad idea. |
I would find this very useful, could it be put behind a newer manifest version so existing scripts don't break? |
I approve that point and i am open to changes but these changes will break my use cases, simply because there will be no way to identify a Lua vector from a 2, 3, 4 numbers array. |
I'm being nosey but i'd tend to agree that sounds like the kind of thing that would be best put behind a new manifest version beyond cerulean |
As if we'll ever get a manifest version again. Edit since you reacted with a confused emoji. It's been close to 5 years since cerulean became available, and there have been dozens of things that should have been added but weren't because "breaking" but somehow versioning was never an option. With the new team having pushed a number of far more breaking changes without any sort of backwards-compatibility, why would it happen here? This update is also dependant on another somewhat breaking change to msgpack where unknown types will outright throw errors (yet to be addressed if that's a concern). I'd like to say that depending on undefined behaviour (which this absolutely is) in your code means that you are taking a risk by using it and not accounting for future changes to that behaviour. There's this many people who knew how to handle vectors but never considered submitting a PR to properly support for them to FiveM for however many years Lua has had a vector type? |
Why not adding native to allowing us to set function to pack/unpack every type like middleware client & server side |
That's part of what #3018 is allowing - swapping to msgpackr and exposing addExtension globally; so you absolutely can replace the packer and unpacker with your own functions. Lua also has this functionality already using metatables.
The default case should be defined and functional. If people want to change it, they can override it. |
Goal of this PR
Allows the JS runtime to unpack vectors received from Lua as arrays, rather than requiring manual handling of buffers.
However, I would like to add default Vector classes instead of using arrays if acceptable.
How is this PR achieving the goal
Adds a msgpackr extension for the vector types (20, 21, 22), dependant on #3018.
This PR applies to the following area(s)
ScRT: JS
Successfully tested on
Game builds: N/A
Platforms: Windows
Checklist
Fixes issues
Supercedes #2946