I have a few concerns with how I would do this kind of integration in my engine.
My engine currently consists of a few things, there's the main Game class where all the magic happens.
Then there are other classes as well like Graphics etc.
My game has an instance of Graphics for example.
Now, I have a separate class for Lua called LuaInterp.
What I want to know is, if I have an instance of Graphics and also LuaInterp on my Game class,
how do I reference the Graphics from LuaInterp.
Also, I'm currently creating static functions for the lua scripts, example:
Code: Select all
lua_register(L, "CreateSprite", CreateSprite_Lua);
Code: Select all
int CreateSprite_Lua(lua_State *L)
{
// code goes here
}
Inside that function CreateScript_Lua I want to be able to reference it's Game parent and then the Graphics child so I can do the following:
Code: Select all
// grab the sprite image you're trying to load
std::string filename = lua_tostring(L, 1);
// create a Drawable
Drawable sprite;
// set the image to the one requested from Lua
// using ImageBank
sprite.SetImage( graphics.imageBank.GetImage(filename) );
// set the new id
int sprite_id = graphics.spriteStack.size();
// add to the sprite_stack
graphics.spriteStack[sprite_id] = sprite;
lua_pushnumber(L, sprite_id);
Can someone help me out here with this?
Thanks a lot.