Most of my game's logic in hardcoded in C++ but take, for example, a trigger. When the player hits a trigger something should happen, and what happens can be different for each instance of a trigger. Therefore, I thought it would be nice to have something like an onHit(params) function in a Lua script that is called to execute some logic for a trigger.
The problem is that each instance of a trigger needs a separate onHit function. So I thought maybe I could create a table that maps trigger ids to their onHit function. Now each trigger can have a separate function.
What's your view on this? I see in the Luabind docs, another solution might be extending my C++ trigger class in Lua.
Another thing is: if I were to create a game object with all its logic implemented in Lua...how is this generally done? Could each object, in C++, have a tick function that calls some Lua function? Or is this generally not how that problem is approached.
Thanks!