lua/wrappers/gfx/lua_asset.cpp
/**
	 * Sets the texture by filename at the given index. 
	 * Defaults to setting the first texture.
	 *
	 * @param string filename The path to the texture.
	 * @param integer [0] index The index to set the texture at.
	 * @returns am.asset This
	 * @returns am.code Return code for loading the texture.
	 * <table class='return_codes'>
	 *  <tr><td>success</td><td>The texture loaded the new file successfully.</td></tr>
	 *  <tr><td>file_not_found</td><td>Texture didn't load because the file could not be found.</td></tr>
	 *  <tr><td>texture_load_failed</td><td>Texture didn't load because there was an issue with the file.</td></tr>
	 * </table>
	 */
Sets the texture by filename at the given index.
Defaults to setting the first texture.

@param string filename The path to the texture.
@param integer [0] index The index to set the texture at.
@returns am.asset This
@returns am.code Return code for loading the texture.

successThe texture loaded the new file successfully.
file_not_foundTexture didn't load because the file could not be found.
texture_load_failedTexture didn't load because there was an issue with the file.

Sets the texture by filename at the given index . Defaults to setting the first texture . @param string filename The path to the texture . @param integer [ 0 ] index The index to set the texture at . @returns am . asset This @returns am . code Return code for loading the texture . successThe texture loaded the new file successfully . file_not_foundTexture didn ' t load because the file could not be found . texture_load_failedTexture didn ' t load because there was an issue with the file .
int Asset_texture(lua_State *lua)
	{
		Asset *asset = castUData<Asset>(lua, 1);
		if (asset)
		{
			int args = lua_gettop(lua);
			if (args == 1)
			{
				base::Handle<Texture> texture = asset->getTexture();
				if (texture)
				{
					wrapRefObject<Texture>(lua, texture);
					return 1;
				}
				lua_pushnil(lua);
				return 1;
			}
			else if (args == 2)
			{
				if (lua_isnum(lua, 2))
				{
					base::Handle<Texture> texture = asset->getTexture(lua_tointeger(lua, 2));
					if (texture)
					{
						wrapRefObject<Texture>(lua, texture);
						return 1;
					}
					lua_pushnil(lua);
					return 1;
				}
				Texture *texture = nullptr;
				if (lua_isstr(lua, 2))
				{
					base::ReturnCode result = GfxEngine::getEngine()->getTexture(lua_tostring(lua, 2), texture);
					if (result != base::SUCCESS)
					{
						lua_pushvalue(lua, 1);
						lua_pushinteger(lua, result);
						return 2;
					}
				}
				else
				{
					texture = castUData<Texture>(lua, 2);
				}
				if (texture)
				{
					unsigned int index = 0;
					if (lua_isnum(lua, 3))
					{
						index = static_cast<unsigned int>(lua_tointeger(lua, 3));
					}
					asset->setTexture(texture, index);
					lua_pushvalue(lua, 1);
					lua_pushinteger(lua, base::SUCCESS);
					return 2;
				}
			}
			return LuaState::expectedArgs(lua, "texture", 2, "integer index = 0", "am.texture texture, integer index = 0");
		}
		return LuaState::expectedContext(lua, "texture", "am.asset");
	}
int Asset_texture ( lua_State * lua ) { Asset * asset = castUData < Asset > ( lua , 1 ) ; if ( asset ) { int args = lua_gettop ( lua ) ; if ( args == 1 ) { base :: Handle < Texture > texture = asset -> getTexture ( ) ; if ( texture ) { wrapRefObject < Texture > ( lua , texture ) ; return 1 ; } lua_pushnil ( lua ) ; return 1 ; } else if ( args == 2 ) { if ( lua_isnum ( lua , 2 ) ) { base :: Handle < Texture > texture = asset -> getTexture ( lua_tointeger ( lua , 2 ) ) ; if ( texture ) { wrapRefObject < Texture > ( lua , texture ) ; return 1 ; } lua_pushnil ( lua ) ; return 1 ; } Texture * texture = nullptr ; if ( lua_isstr ( lua , 2 ) ) { base :: ReturnCode result = GfxEngine :: getEngine ( ) -> getTexture ( lua_tostring ( lua , 2 ) , texture ) ; if ( result != base :: SUCCESS ) { lua_pushvalue ( lua , 1 ) ; lua_pushinteger ( lua , result ) ; return 2 ; } } else { texture = castUData < Texture > ( lua , 2 ) ; } if ( texture ) { unsigned int index = 0 ; if ( lua_isnum ( lua , 3 ) ) { index = static_cast < unsigned int > ( lua_tointeger ( lua , 3 ) ) ; } asset -> setTexture ( texture , index ) ; lua_pushvalue ( lua , 1 ) ; lua_pushinteger ( lua , base :: SUCCESS ) ; return 2 ; } } return LuaState :: expectedArgs ( lua , " " , 2 , " " , " " ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the texture by filename at the given index.
Sets the texture by filename at the given index .
// Returns the first texture // Returns the texture at the index.