1. Fill your cup and take your pick among the maps best suited for this year's Hive Cup. The 6th Melee Mapping Contest Poll is up!
    Dismiss Notice
  2. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  3. Do you hear boss music? It's the 17th Mini Mapping Contest!
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] call TriggerSleepAction (?)

Discussion in 'Triggers & Scripts' started by Legal_Ease, Apr 25, 2016.

  1. Legal_Ease

    Legal_Ease

    Joined:
    Feb 8, 2013
    Messages:
    1,453
    Resources:
    28
    Icons:
    11
    Packs:
    1
    Skins:
    2
    Maps:
    10
    Template:
    1
    Tutorials:
    3
    Resources:
    28
    I need this:

    • Custom script: call TriggerSleepAction (217.00)


    ...to wait 2 minutes and 17 seconds.

    Is this the proper syntax?

    I am concerned that the decimal is wrong. and it will play at 217 seconds, which is close, but not what I want.

    Also, is there a better way to loop a theme music sound? If so, then I don't need to call sleep.
     
  2. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    842
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Use Timers!
     
  3. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,525
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    It's proper syntax, but it is exactly the same was Wait action in GUI, so GUI could be used.
    Also, you might have wanted to write 137, as a minute has 60 seconds. ;p
     
  4. Legal_Ease

    Legal_Ease

    Joined:
    Feb 8, 2013
    Messages:
    1,453
    Resources:
    28
    Icons:
    11
    Packs:
    1
    Skins:
    2
    Maps:
    10
    Template:
    1
    Tutorials:
    3
    Resources:
    28
  5. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,784
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    If you want to wait 2 minutes and 17 seconds it would be
    TriggerSleepAction(137)


    You should be using a timer like Ice said though.
     
  6. Arad MNK

    Arad MNK

    Joined:
    Dec 11, 2014
    Messages:
    1,887
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    Waits are horrible. Best advice I can give you.
    Waits are so inaccurate, they wait like 0.27 more than the given value.
    Timers, on the other hand, are very accurate.

    You might want to learn how to use
    TimerStart(CreateTimer(), false, 5., function MyFunc) // AFAIR these were the parameters
     
  7. Meatmuffin

    Meatmuffin

    Joined:
    Jul 25, 2014
    Messages:
    451
    Resources:
    9
    Maps:
    2
    Spells:
    7
    Resources:
    9
    Switch timeout with boolean and it's fine.
     
  8. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,638
    Resources:
    3
    Spells:
    3
    Resources:
    3
    I dont really think you are understanding what you are doing.

    Bribe will never (ever) recommend someone to use TriggerSleepAction() if it is not about clearing local data.
    What he does is simply ending the current function and creating a new one that runs by a timer...
    So this cannot be used in a lot of circumstances and will not allow you to use local variables properly.

    So to sum it up:
    1, Bribe did not recommend you to use TriggerSleepAction().
    2, It is better to use timers.
    3, Waits are still horrible, but you can use them because you wouldnt really care about the inaccuracy... except if you want that map to work in multiplayer, then
    4, You have to use timers instead.
     
  9. Legal_Ease

    Legal_Ease

    Joined:
    Feb 8, 2013
    Messages:
    1,453
    Resources:
    28
    Icons:
    11
    Packs:
    1
    Skins:
    2
    Maps:
    10
    Template:
    1
    Tutorials:
    3
    Resources:
    28
    Hey, thanks for the summary. Well put. I think I get it now. I am using them in a single player map to play music every 2 minutes. Accuracy doesn't seem like an issue, but I will try to avoid them as often as possible. Bribe's tutorial is about
    Code (vJASS):
    //! runtextmacro SleepAction("0.0", "1")
    I didn't notice the difference at first, but now I get it.