I’ve been updating how my Lua binding system works over the last few days. My original system was getting me in the shit with co-routines because I short sightedly stored a global Lua instance and accessed it from everything.
While this has worked, and is accessible, it does fuck me about in a lot of ways. Like I can only really have one Lua instance in each dll realm (menu, client, server). I’ve got no need to have more right now β but that’s not the point.
My old bindings looked like this..
The calls to Get_EntityΒ and Get_Float are what are bumming me. They’re accessing globals.
So now my bindings are looking like this.
The ‘lua’ variable is passed to the function from a function that the LC_Function macro creates. It’s no longer retrieved from a global β it’s retrieved from the lua_state that is passed by Lua to all function calls.
I also started documenting the functions in a way that I can parse with a PHP script, turn to JSON and automatically throw at the wiki. Something I really really wish I had done over the years for the 2,000 other functions.
Add a Comment