From Valve Developer Community
Jump to: navigation, search

Thinking functions can be registered at any time using SetThink with a function. It is possible to have multiple think functions running on an entity at the same time, but does require the think functions to be named so as not to overlap.


SetThink( "ThinkerFunction", self, "thinkerNameString", 1 )

  • ThinkerFunction - This can be a string of the name of the function to call, or a function object.

The following arguments are optional:

  • ThinkerFunctionScope - This can be a table, to cause ThinkerFunction will be indexed on this object. Use this to get member functions as think callbacks.
  • thinkerNameString - The name of the think slot. Use this when handling multiple thinkers.
  • 1 - Number specifying a delay in seconds before the thinker starts to think.

Returning a nil will unregister the thinker and stop it. Returning a number sets the next think time.