Пример #1
0
void LoadGameLibrary(LuaState &state) {
	state.SetGlobal("ChunkWidth", ChunkWidth);
	state.SetGlobal("ChunkHeight", ChunkHeight);
	state.SetGlobal("ChunkLength", ChunkLength);
	
	state.GetGlobalNamespace()
	
	.beginClass<Dimension>("Dimension")
	.addFunction("GetBlock", &Dimension::GetBlockByCoord)
	.addFunction("IsSolidBlock", &Dimension::IsSolidBlock)
	.endClass()
	
	
	.beginClass<Chunk>("Chunk")
	.addFunction("GetBlock", &Chunk::GetBlock)
	.addFunction("IsSolidBlock", &Chunk::IsSolidBlock)
	.addFunction("GetDimension", &Chunk::GetDimension)
	.addFunction("GetX", &Chunk::GetX)
	.addFunction("GetZ", &Chunk::GetZ)
	.endClass()
	
	
	.beginClass<Block>("Block")
	.addFunction("GetX", &Block::GetX)
	.addFunction("GetY", &Block::GetY)
	.addFunction("GetZ", &Block::GetZ)
	.addFunction("GetAbsX", &Block::GetAbsoluteX)
	.addFunction("GetAbsZ", &Block::GetAbsoluteZ)
	.addFunction("IsSolid", &Block::IsSolid)
	.addFunction("GetChunk", &Block::GetChunk)
	.endClass()
	
	.beginClass<Entity>("Entity")
	.addFunction("GetPosition", &Entity::GetPosition)
	.addFunction("GetRotation", &Entity::GetRotation)
	.addFunction("SetPosition", &Entity::SetPosition)
	.addFunction("SetRotation", &Entity::SetRotation)
	.endClass()
	
	
	
	.beginClass<TextureAtlas<TEXTURE_ATLAS_BLOCK>>("BlockTexture")
	.addStaticFunction("GetTexCoord", &TextureAtlas<TEXTURE_ATLAS_BLOCK>::GetTextureCoords)
	;
}
Пример #2
0
/** Loads game libraries for a given state */
void shootergame::LoadGameLibraries(LuaState &state) {
	
	// Add game folders
	state["game_folder"] = Game::Current()->GetGameFolder().GetPath().c_str();
	state["model_folder"] = Game::Current()->GetModelFolder().GetPath().c_str();
	state["shader_folder"] = Game::Current()->GetShaderFolder().GetPath().c_str();
	state["script_folder"] = Game::Current()->GetScriptFolder().GetPath().c_str();
	state["texture_folder"] = Game::Current()->GetTextureFolder().GetPath().c_str();
	
	
	// Add some other stuff
	state.SetGlobal("display", Game::Current()->GetDevice()->GetDisplay());
	state.SetGlobal("scene_manager", Game::Current()->GetDevice()->GetSceneManager());
	
	
	// Register some stuff for Lua
	LoadUtilLibrary(state);
	LoadGameLibrary(state);
	
	
	
}