1. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Timer issue

Discussion in 'Triggers & Scripts' started by Rugarus, Jun 14, 2019 at 7:11 PM.

  1. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    675
    Resources:
    0
    Resources:
    0
    My timer doesn't seem to run, what am I doing wrong here?
    //Zinc
    Code (vJASS):

    private function OnTimy60() {
      timer t=GetExpiredTimer();
      DisplayTextToForce(GetPlayersAll(), "Current test");
    }

    function onStarty() {
    timer t=CreateTimer();
    TimerStart(t, 15, true, function OnTimy60);

            t=null;
    }

    private function onInit() {
      trigger trg = CreateTrigger();
      TriggerAddAction(trg, function onStarty);
    }


     
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,412
    Resources:
    0
    Resources:
    0
    You gave trg an action but no event so it's never run. The function that starts the timer is the action for trg so the timer is never started.
     
  3. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    675
    Resources:
    0
    Resources:
    0
    I thought that if you create a trigger and give it an action with no event it runs on map initialization?
    How do I get this to run right from the start? Thanks.
     
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,412
    Resources:
    0
    Resources:
    0
    No, it does not work like that. The entire onInit function runs on map init and can have anything you want in it. Just put the timerstart in there.
    Code (vJASS):

    private function OnTimy60() {
      timer t=GetExpiredTimer();
      DisplayTextToForce(GetPlayersAll(), "Current test");
    }

    private function onInit() {
      TimerStart(CreateTimer(), 15, true, function OnTimy60);
    }
     
  5. Rugarus

    Rugarus

    Joined:
    Dec 2, 2016
    Messages:
    675
    Resources:
    0
    Resources:
    0
    Thanks!