Difference between revisions of "Dota 2 Workshop Tools/Scripting/ThinkerFunctions"

From Valve Developer Community
Jump to: navigation, search
m (Added link to "Thinking" page to help readers understand what a "Think" function does.)
Line 1: Line 1:
 +
{{otherlang2
 +
|zh-cn = Dota_2_Workshop_Tools:zh-cn/Scripting:zh-cn/ThinkerFunctions:zh-cn
 +
}}
 
[[Think|Thinking]] functions can be registered at any time using <code>SetThink</code> 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.
 
[[Think|Thinking]] functions can be registered at any time using <code>SetThink</code> 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.
  

Revision as of 00:39, 12 September 2014

简体中文

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.

Usage

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.