er2.getFactionFlag 4
Returns the official flag of a faction as a Texture handle, the same image the game uses in its menus, regional censorship included.Together with loadTexture this means a texture is a texture, wherever it comes from: both functions return the same kind of handle, and whatever accepts one accepts the other.
Return value
| Return Type | Description |
|---|---|
| Texture | The texture handle, or nil if the id is not a faction (the console says why). |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | string | The faction id, for example UnitedStates_allies. The winner argument of the battle_ended callback is already in this form. |
Examples
Texture a generic flag prop (texture API)
-- Textures are handles: load one once and pass it around. The same
-- prop works with a faction flag or any image from the mission folder.
local flagTex = er2.getFactionFlag("UnitedStates_allies")
-- local flagTex = er2.loadTexture("flags/my_banner.png")
er2.createProp("FlagWaving_1", vec3(100.0, 25.0, 200.0), vec3(0, 90, 0), false,
function(prop)
prop:setAlbedo(flagTex)
end)
-- In a prop script placed in the mission editor the prop is "myself",
-- and the texture is re-applied automatically when it streams back in:
-- myself:setAlbedo(er2.getFactionFlag("Germany_axis"))