Entity/NextThink

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
Line 18: Line 18:
 
     print("Hello, World!")
 
     print("Hello, World!")
  
     self:NextThink(CurTime() + 1)
+
     self:NextThink( CurTime() + 1 )
 
     return true -- Note: You need to return true to override the default next think time
 
     return true -- Note: You need to return true to override the default next think time
 
end
 
end
|Output=Hello, World!
+
|Output=Hello, World! every second the entity exists in the work.
 
}}
 
}}

Revision as of 03:16, 23 August 2014

 Entity:NextThink( )

Contents

Description

In the case of a scripted entity, this will cause the next ENTITY:Think event to be run at the given time.

Does not work clientside! Use Entity:SetNextClientThink instead.

Arguments

number timestamp

The relative to CurTime 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! every second the entity exists in the work.
Personal tools
Navigation