Garry's Mod Wiki

Revision Difference

Global.DynamicLight#514803

<function name="DynamicLight" parent="Global" type="libraryfunc">⤶ <description>⤶ Creates or replaces a dynamic light with the given id.⤶ ⤶ <note>Only 32 dlights and 64 elights can be active at once.</note>⤶ <warning>It is not safe to hold a reference to this object after creation since its data can be replaced by another dlight at any time.</warning>⤶ <bug issue="3798">The minlight parameter affects the world and entities differently.</bug>⤶ </description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="index" type="number">An unsigned Integer. Usually an [entity index](/gmod/Entity/EntIndex) is used here.</arg>⤶ <arg name="elight" type="boolean" default="false">Allocates an elight instead of a dlight. Elights have a higher light limit and do not light the world (making the &quot;noworld&quot; parameter have no effect).</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="table">A DynamicLight structured table. See <page>DynamicLight</page></ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Emits a bright white light from local players eyes.</description>⤶ <code>⤶ hook.Add( "Think", "Think_Lights!", function()⤶ local dlight = DynamicLight( LocalPlayer():EntIndex() )⤶ if ( dlight ) then⤶ dlight.pos = LocalPlayer():GetShootPos()⤶ dlight.r = 255⤶ dlight.g = 255⤶ dlight.b = 255⤶ dlight.brightness = 2⤶ dlight.Decay = 1000⤶ dlight.Size = 256⤶ dlight.DieTime = CurTime() + 1⤶ end⤶ end )⤶ </code>⤶ ⤶ </example>