Internal Script Export

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Internal Script Export

      Hey,

      This is specifically for Rez as you wrote the Lua Chapter. I am using Luabind which is slightly different than the examples shown, however that doesn't really have much to do with the question.

      In different Manager Classes I have been exposing certain methods to Lua, for instance in CApplication (My Application Layer)

      Source Code

      1. lua_State* pLuaSate = m_pLuaManager->GetLuaState();
      2. luabind::module(pLuaSate)
      3. [
      4. class_<CApplication>("CApplication")
      5. .def("Quit", &CApplication::Quit)
      6. .def("GetLogic", &CApplication::GetGameLogic)
      7. .def("GetResCache", &CApplication::GetResourceCache)
      8. .def("GetTimer", &CApplication::GetTimer)
      9. .def("GetWidth", &CApplication::GetWidth)
      10. .def("GetHeight", &CApplication::GetHeight)
      11. ];
      12. luabind::globals(pLuaState)["Application"] = this;
      Display All


      This works great, I guess luabind automatically matches my CApplication instance to the CApplication Definition exposed to Lua. Several of my systems are Singleton Classes so I have been passing in the 'this' pointer right from the constructor.

      In the Lua Scripting Chapter there was a small section called Internal Script Exports, I was not completely sure what this was, but just to clarify, this is a central spot to put all the Lua Exposures rather then putting them right in the classes constructor?
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • RE: Internal Script Export

      Yes, this is a place to put all those little functions you expose to Lua. I prefer centralizing the C++ / script glue as much as possible to avoid having it litter the code-base everywhere. It's also nice and hidden so other systems don't call those functions; their entire purpose is to act as the glue between Lua and C++.

      -Rez
    • I was just working on making up a list of all the Lua Exposed Functions throughout the engine, then I remembered back to this spot, I wasn't sure what you were saying in the book at first but now that makes sense, instead of having to keep track of a list, having it in a central spot is nice and I'll be sure to implement this,

      thanks again
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz