Beispiel #1
0
// ****************************************************************************
// ****************************************************************************
Instance * InstanceManager::Load(const std::string &name)
{
	Instance *inst = Get(name);
	if(inst != NULL)
		return inst;

	std::string fullPath = "Meshes/";
	fullPath += name;
	fullPath += ".lua";

	LuaPlus::LuaState *state = LuaPlus::LuaState::Create();
	_ASSERT(state != NULL);
	
	int retVal = state->DoFile(fullPath.c_str());
	_ASSERT(retVal == 0);

	LuaPlus::LuaObject shaderObj = state->GetGlobals()["MeshList"];
	_ASSERT(shaderObj.IsTable());

	inst = new Instance;
	_ASSERT(inst != NULL);

	m_database[name] = inst;
	return inst;

}
LUA_EXTERN_C void luaplus_dumptable(lua_State* L, int index)
{
	LuaPlus::LuaState* state = lua_State_To_LuaState(L);
	LuaPlus::LuaObject valueObj(state, index);
	LuaPlus::LuaStateOutString stringFile;
	state->DumpObject(stringFile, NULL, valueObj, LuaPlus::LuaState::DUMP_ALPHABETICAL | LuaPlus::LuaState::DUMP_WRITEALL, 0, -1);
	state->PushString(stringFile.GetBuffer());
}
Beispiel #3
0
bool Gyro::UserSettings::Initialize()
{
	LuaPlus::LuaState* theLuaState = LuaPlus::LuaState::Create( true );
	if( theLuaState->DoFile( "data/UserSettings.ini" ) )
		if( theLuaState->GetTop() == 1 )
			assert( 0 ); // an error occured.


	LuaPlus::LuaObject& settings = theLuaState->GetGlobal( "UserSettings" );
	LuaPlus::LuaObject& screen = settings["Screen"];
	screen_width = screen["Width"].GetInteger();
	screen_height = screen["Height"].GetInteger();

	return true;
}