<=[[4rpl:start|Index]] \\ <=[[cw4:Tutorials]] ===== Executing Scripts When Paused ===== ==== Global Scripts ==== Global script can be added to any cpack. Open a cpack and select the SCRIPTS tab. From there click "+New" and create a new script. In the top middle pane next to the "Units" tab is the "Global Control" tab. Select that and you can added the newly created script to either the Pre or Post sections. The "Pre" section is for scripts that will execute at the beginning of the game loop. The "Post" section is for scripts that will execute at the end of the game loop. After adding a script to either, or both sections, select the script in the pre/post section by clicking on it. That will show "Script Execution Settings" in the right pane. From there you can select "Run when paused". When a global script is told to run when paused, it will execute every frame even if the game is paused. ==== Units ==== Units can register for special messages [[4rpl:commands:MSG_PreUpdate]] and [[4rpl:commands:MSG_PostUpdate]]. These messages are sent even when the game is paused. Any script that listens for these messages can execute code when the messages are received (so even when the game is paused). :Awake RegisterForMsg("MSG_PreUpdate" "MyCall") :MyCall PrintAllSp("MyCall")