Entity/NextThink

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=NextThink |Parent=Entity |Description= |Realm=Shared |IsClass=Yes }}")
 
Line 2: Line 2:
 
|Name=NextThink
 
|Name=NextThink
 
|Parent=Entity
 
|Parent=Entity
|Description=
+
|Description=In the case of a scripted entity, this will cause the entity's next "OnThink" event to be run at the given time.
 +
 
 +
Does not work clientside!
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=timestamp
 +
|desc=The timestamp at which the next think should occur.
 +
}}
 +
{{Example
 +
|Description=Prints 'Hello, World!' in console and sleeps for a second.
 +
|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
 +
|Output=Hello, World!
 
}}
 
}}

Revision as of 21:37, 13 April 2013

 Entity:NextThink( )

Contents

Description

In the case of a scripted entity, this will cause the entity's next "OnThink" event to be run at the given time.

Does not work clientside!

Arguments

number timestamp

The timestamp at which the next think should occur.

Examples

Example

Prints 'Hello, World!' in console and sleeps for a second.

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

Output:

Hello, World!
Personal tools
Navigation