surface.GetTextureID

From GMod Wiki

Revision as of 22:15, 23 November 2010 by Di-0xide (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax surface.GetTextureID( String Texture )
Where is this used?
Description:
Converts the filepath of a texture to a table so it can be used with Surface.SetTexture.
Returns: Number
Part of Library: surface
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Surface.GetTextureID]Surface.GetTextureID [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionDraws the brick texture to the center of the screen.
Used onNewerClient.png
Code
local tex = surface.GetTextureID("Brick/brickfloor001a") //Gets the texture id for the brick texture
function drawBrickTexture()
	surface.SetTexture(tex)
	surface.SetDrawColor(255,255,255,255) //Makes sure the image draws correctly
	surface.DrawTexturedRect(ScrW()*0.5-32,ScrH()*0.5-32,64,64)
end
hook.Add("HUDPaint","DrawTheBricks",drawBrickTexture)
OutputN/A


Additional Notes

Example:

A texture file is located at garrysmod/materials/custom/my_texture.vtf You would then use the following piece of code to retrieve it:

surface.GetTextureID("custom/my_texture")

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox