ITexture.IsError
From GMod Wiki
Function | |
Syntax | ITexture:IsError( ) |
Description: | |
Returns false if the specified texture initialized properly, and true if it didn't. | |
Returns: | Boolean |
In Object: | ITexture |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=ITexture.IsError]ITexture.IsError [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Creates a method that checks if a texture is valid |
---|---|
Used on | Client |
Code | function IsValidMaterial( strName ) local mat, basetex mat = Material( strName ) basetex = mat:GetMaterialTexture( "$basetexture" ) return not basetex:IsError( ) end function SafeSetMaterial( strName ) if not IsValidMaterial( strName ) then LocalPlayer( ):SetMaterial( "" ) else LocalPlayer( ):SetMaterial( strName ) end end SafeSetMaterial( "models/purple" ) |
Output | If the texture "models/purple" is valid, the local player has their material set to that, else their material is cleared |