User Tools

Site Tools


4rpl:commands:func_awake

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:func_awake [2021/10/06 12:37] – Clarified Awake in Global Control scripts Karsten754rpl:commands:func_awake [2023/06/10 15:53] (current) Grabz
Line 8: Line 8:
 '':Awake''  is called whenever a unit with this script attached is created. This can happen at game load, or during a game when a unit is created with [[4rpl:commands:createunit|CreateUnit]]. '':Awake''  is called whenever a unit with this script attached is created. This can happen at game load, or during a game when a unit is created with [[4rpl:commands:createunit|CreateUnit]].
  
-A critical distinction exists between scripts attached to units and scripts scheduled to run during Pre- or Post-phases of Global Control.  +Please refer to [[cw4:Programming Notes]] for an in-depth discussion and comparison between ''[[func_Once| :Once]]''''[[func_GameLoaded|:GameLoaded]]'', and ''[[func_Awake|:Awake]]''.
- +
-Functionally, the '':Awake'' function in preor Post Global Control phases are equivalent to a ''[[func_once|:Once]]'' function. It is not executed until the appropriate moment in processing (before or after all units are processed for every game tick). This may cause execution of '':Awake'' functions to appear in the incorrect order, where each unit will execute it's '':Awake" function as it is instantiated during map load (either initial load or load from a save, there is no difference), and the '':Awake'' in a Global Control script will execute at the beginning or end, respectively, of a game tick.+
  
 ===== Examples ===== ===== Examples =====
Line 18: Line 16:
    SetUnitDebugText(self "I Live")    SetUnitDebugText(self "I Live")
 </code> </code>
 +
 +===== See Also =====
 +
 +[[cw4:Programming notes]]
 +
4rpl/commands/func_awake.1633538221.txt.gz · Last modified: 2021/10/06 12:37 by Karsten75