Search code examples
cmultithreadingapilualua-lanes

How do I get Lua Lanes to work with my game server?


I've been racking my brain at this all day and I just cannot figure it out. My server uses a single state that loads all of my scripts in as global variables (for calling any time without having to luaL_dofile each time I want to run a script). The problem comes in when I attempt to use lanes. require "lanes" works as it should (I think? It returns a table to package.loaded appropriately...) since I have the lanes.lua in the appropriate directory on Linux (Ubuntu 11.10 x86). However, when I go to do lanes.gen("", functionName) it tells me... attempt to index global 'lanes': a nil value. At this point I decided to try package.loaded["lanes"].gen("", functionName) and it tells me... attempt to index field 'gen': a nil value If you need more information, please let me know. Thank you in advance for at least trying to help.


Solution

  • If you are using the latest LuaLanes (which is what you get by luarocks install lanes), the supported way of loading the module is this:

    local lanes = require "lanes".configure()
    

    configure() will create all the necessary functions, before calling configure() the module table is empty, which seems like your issue.