SC2Mapster.com Wiki

Wait

void Wait (fixed seconds, int timezone);

Pause the current trigger without blocking.

When called, the trigger is being executed in a separate thread not to block the rest of the scripts. The main use of this function is to wrap it with a while (1) in order to have a script executed every X seconds.

Parameters

fixed seconds

Number of seconds to wait

int timezone

Timezone used. Can be one of

  • 0: Game
  • 1: Real
  • 2: AI

There is no difference in timing between those 3 values in the beta at the moment. Maybe Real won't take in account the Pause, Game will be affected by the speed (Fastest, Slow ...) and AI by the APM?

Examples

Example: Run script every X seconds
// Define the trigger function
bool TriggerTiming (bool checkConds, bool doActions) {
  while (1) {
    // Do something every 5 seconds
    Wait(5, 0);
  }
}

// Create a new trigger based off the function
trigger t = TriggerCreate("TriggerTiming");

// Run it at map initialization
TriggerAddEventMapInit (t);

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of xhatix xhatix Mar 24, 2010 at 15:36 UTC - 0 likes

    Can confirm the following:

    Game Timezone: - Affected by pause - gamespeed (fastest is properly affects delay by 0.7) Real Timezone: - seems to be OS-clock - also affected by pause

    test code: http://paste.sc2mapster.com/1868/

    To see the result: You start this code You will start seeing a 2 (this is seems to be a 'bug' as no threading used) - after that 1's You press F10 - going to options gameplay - set gamespeed to fastest (full) - will result in 0's if real timezone would be the same as game-timezone you would still see a 1

    guessing if you use float you will see approx 0.7

    "There's always another choice."

  • 1 comment

Facts

Date created
Mar 09, 2010
Last updated
Mar 10, 2010

Author