Garry's Mod Wiki

Revision Difference

Entity:NextThink#562767

<function name="NextThink" parent="Entity" type="classfunc"> <description> In the case of a scripted entity, this will cause the next <page>ENTITY:Think</page> event to be run at the given time. ⤶ Does not work clientside! Use <page>Entity:SetNextClientThink</page> instead. Controls when, relative to <page>Global.CurTime</page>, the <page>Entity</page> will next run its Think function. ⤶ For Scripted Entities, this is the <page>ENTITY:Think</page> function. For engine Entities, this is an internal function whose behavior will depend on the specific Entity type.⤶ ⤶ ⤶ For a Client-side equivalent, see <page>Entity:SetNextClientThink</page>.⤶ <bug issue="3269">This does not work with SWEPs or Nextbots.</bug> </description> <realm>Shared</realm> <args> <arg name="timestamp" type="number">The relative to <page>Global.CurTime</page> timestamp, at which the next think should occur.</arg>⤶ <arg name="timestamp" type="number">⤶ The timestamp, relative to <page>Global.CurTime</page>, when the next think should occur.⤶ </arg>⤶ </args> </function>⤶ ⤶ </function>⤶ <example> <description>Prints 'Hello, World!' in console and sleeps for a second.</description> <description>Repeatedly prints "Hello, World!" in console with a 1 second delay between each repetition.</description> <code> function ENT:Think() print("Hello, World!") self:NextThink( CurTime() + 1 ) return true -- Note: You need to return true to override the default next think time end </code> <output>Hello, World! every second the entity exists in the world.</output>⤶ <output>⤶ ```⤶ Hello, World!⤶ Hello, World!⤶ Hello, World!⤶ Hello, World!⤶ ...⤶ ```⤶ </output>⤶ </example>