Wednesday, March 13, 2013
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.