Techmo Posted July 5, 2019 Share Posted July 5, 2019 The most daunting aspect of developing binary modules for the server is dealing with the lua stack in order to retrieve, and pass return values to and from c functions. After an afternoon of boredom, I decided to write a library to make this process much easier. As far as i know (i havent actually checked) the name GLib isnt taken so thats what im gonna call it for now. GLib provides an object oriented interface for the creation of binary modules, It automatically handles the complexity of retrieving function parameters, and sending return values. GLib isnt invasive, so if you still need to play around with the stack, you can. GLib currently supports the following parameter types: Booleans Numbers Strings Vectors Angles Plans are in motion to add support for passing tables, entities, and other data types. With this, i hope binary optimization of server code will be much easier to accomplish. If you want to check it out, you can find the git repo here. Just download the repo, and open the project file in visual studio. Everything should be set up for you to build the example plugin. An example lua script is also provided to test the example plugin. Just a side note, due to a bug in Visual Studio 2019, this library will not work. You will need to use Visual Studio 2017 or older. 2 Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 5, 2019 Author Share Posted July 5, 2019 Just added a benchmark to the example lua test script. It shows the C++ function to calculate the dot product being about 4 times faster than a function written in lua. The speed increase is quite small here due to the function being simple, and the constant function call overhead taking a significant amount of that time. Functions that take longer to execute should see much larger gains written in C++. 1 Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 11, 2019 Author Share Posted July 11, 2019 GLib has been updated to support pretty much every data type available, as well as custom binary data. GLib now uses the ILuaObject interface provided by the garrysmod_common library. The parameter type filter has also been made optional, allowing functions to accept different parameter types. 1 Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 12, 2019 Author Share Posted July 12, 2019 Fixed the issues with the filter. Unfortunately, the library used to interface with lua objects is out of date and a few value fetching functions don't match the signatures in the gmod binary. I've provided workarounds in the example plugin until I can patch the issues. 1 Quote Link to comment Share on other sites More sharing options...
Techmo Posted July 12, 2019 Author Share Posted July 12, 2019 Fixed the dependency issues. It should now be as easy as doing a recursive clone of the repo, and opening the solution in visual studio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.