[Solved] Timer[array] doubt/issue

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
Hello everyone! I wanted to ask how can I start a timer[array] upon the expiring of another timer? being the array the number of a player I found it difficult to obtain that number. Do I need to use hashtables or something? if so hwo can I do that ?

Example:
  • Trigger1
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to Trigger3 <gen> the event (Time - Timer_X[(Integer A)] expires)
  • Trigger2
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • Set Real = 0.50
      • Countdown Timer - Start Timer_X[PlayerNumber] as a One-shot timer that will expire in Real seconds
  • Trigger3
    • Events
    • Conditions
    • Actions
      • Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • Set Real = 2.00
      • Countdown Timer - Start Timer_Y[PlayerNumber] as a One-shot timer that will expire in Real seconds
I'm having trouble to obtain the needed array number on Trigger3, can anyone please help ?

PS: I don't know if I did something wrong on Trigger1 (I'm not so sure how loops work).

All help is appreciated
 
Last edited:
Shouldn't Trigger 3 has the Event (Timer_X expires), cause you add it to Trigger 2 which somehow looks wrong.
Beaware that Timer Objects of an Timer-Array are not created automatacally if you did set the Array starting size to a to low number.

To takeover the Index hastables are good.

Here so your's would look like

  • Trigger 1
    • Ereignisse
      • Map initialization
    • Bedingungen
    • Aktionen
      • Hashtabelle - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Schleifen - Aktionen
          • Trigger - Add to Trigger 3 <gen> the event (Zeit - Timer_X[(Integer A)] expires)
  • Trigger 2
    • Ereignisse
      • Unit - A unit Dies
    • Bedingungen
    • Aktionen
      • Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • Set Real = 0.50
      • Countdown-Timer - Start Timer_X[PlayerNumber] as a One-shot timer that will expire in Real seconds
      • Hashtabelle - Save PlayerNumber as 0 of (Key (Last started timer)) in Hashtable
  • Trigger 3
    • Ereignisse
    • Bedingungen
    • Aktionen
      • Set PlayerNumber = (Load 0 of (Key (Expiring timer)) from Hashtable)
      • Set Real = 0.50
      • Countdown-Timer - Start Timer_Y[PlayerNumber] as a One-shot timer that will expire in Real seconds
PS: I Heared JNGP, that alternative Editor which i do not use therefore no idea if that changed, does not have this GetHandle Functions of GUI implemented.
If you use JNGP you need to use this Function
  • Custom script: set udg_Key = GetHandleIdBJ(udg_Timer [udg_PlayerNumber])
 
Last edited:
  • TimerExpired
    • Events
    • Conditions
    • Actions
      • Set tempInteger = 1
      • Custom script: loop
      • Custom script: exitwhen udg_tempInteger>12
      • Custom script: if GetExpiredTimer()==udg_Timer_X[udg_tempInteger] then
      • Custom script: exitwhen true
      • Custom script: endif
      • Set tempInteger = (tempInteger + 1)
      • Custom script: endloop
      • -------- -- now variable tempInteger is your number youre looking for --------
      • -------- ------------ --------
 
Status
Not open for further replies.
Top