overextended / cfxlua-vscode

https://marketplace.visualstudio.com/items?itemName=overextended.cfxlua-vscode
MIT License
51 stars 23 forks source link

Support for automatic unpacking of vector values #26

Closed r3ps4J closed 1 year ago

r3ps4J commented 1 year ago

When you supply a vector value to a native, the language server does not account for automatic unpacking.

Example with SetEntityCoords: image

The language server sees the vector3 parameter as 1 argument, but ideally it should see it as 3. The same thing happens for the other vector-like types.

Alternatively, the use of function overloading could be used for this to provide a signature with vectors as parameter types and without. This approach would mean that every native needs to be mapped and there are natives that can have multiple vector fields resulting in many overloads with all possible combinations.

The issue might be related more to JetbrainIDE-CFX.RE, let me know if you'd like me to move it there.

thelindat commented 1 year ago

Automatic unpacking of vectors is complicated and would require overloading every function that takes a vector, with additional overloads for each vector available.

Off the top of my head, none of the native definitions out there include vectors either.

There's also the matter of the oal natives not supporting vector unpacking which makes things more complex again.

In the end it's best to be explicit with your code as it's easier to parse, and easier for everyone to tell what's happening at a glance.

r3ps4J commented 1 year ago

Yeah good point. I'll just switch to typing out all values or making specific overloads when needed.