Garry's Mod Wiki

Revision Difference

Global.ProjectedTexture#517525

<function name="ProjectedTexture" parent="Global" type="libraryfunc"> <description>Creates a new <page>ProjectedTexture</page>.</description> <realm>Client</realm> <rets> <ret name="" type="ProjectedTexture">Newly created projected texture.</ret> </rets> </function> <example> <description> Creates a simple ProjectedTexture attached to a [Scripted Entity](/gmod/Scripted_Entities). Creates a simple ProjectedTexture attached to a <page text="Scripted Entity">Scripted_Entities</page>. Note that this code must be ran on clientside only, not shared. </description> <code> function ENT:Initialize() local lamp = ProjectedTexture() -- Create a projected texture self.lamp = lamp -- Assign it to the entity table so it may be accessed later -- Set it all up lamp:SetTexture( "effects/flashlight001" ) lamp:SetFarZ( 500 ) -- How far the light should shine lamp:SetPos( self:GetPos() ) -- Initial position and angles lamp:SetAngles( self:GetAngles() ) lamp:Update() end function ENT:OnRemove() if ( IsValid( self.lamp ) ) then self.lamp:Remove() end end function ENT:Think() -- Keep updating the light so it's attached to our entity -- you might want to call other functions here, you can do animations here as well if ( IsValid( self.lamp ) ) then self.lamp:SetPos( self:GetPos() ) self.lamp:SetAngles( self:GetAngles() ) self.lamp:Update() end end </code> </example>