• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] How to get that integer

Status
Not open for further replies.
Level 10
Joined
Dec 15, 2012
Messages
650
Maybe you didn't get what I mean from the title, ok let's us see...
[trigger=My trigger]Get that integer
Events
Time - Timer[(Random integer number between 1 and 8192)] expires
Actions
Set Integer_variable = ARRAY number that causing the event[/trigger]
Ok, hopes you understand after seeing the event.How do I know which array number of Timer is causing the event ?? :vw_wtf:

This thing turns my head inside-out.Please help if you know how to get that.
:ogre_haosis: THANKS :ogre_haosis:
_____________________________________________________________
:goblin_sleep:It is too hard to be explained well. . . .
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
What do you need that for? I don't think there's a good way to do this in GUI.
In JASS, you can do GetExpiredTimer() (self-explanatory), but then you'd have to loop through all possibilities until you get the correct one (not the way to go).

Find another way to do what you want to do, or tell us what it is that you want to do :D.
 
Level 10
Joined
Dec 15, 2012
Messages
650
What do you need that for? I don't think there's a good way to do this in GUI.
In JASS, you can do GetExpiredTimer() (self-explanatory), but then you'd have to loop through all possibilities until you get the correct one (not the way to go).

Find another way to do what you want to do, or tell us what it is that you want to do :D.
:ogre_frown:Hmmmm....I told you that it is a thing that very hard to explain by me:ogre_frown:
:ogre_datass:
  • Events
    • Time - Timer[(Random integer number between 1 and 8192)] expires
  • Actions
    • Unit - Remove Unit[(that array number... lolx, sorry and sorry if I didn't explain it well)]
:fp: Do you get what I mean now ? :ogre_icwydt:
Please do a example for me if you get what I mean :D
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
:ogre_frown:Hmmmm....I told you that it is a thing that very hard to explain by me:ogre_frown:
:ogre_datass:
  • Events
    • Time - Timer[(Random integer number between 1 and 8192)] expires
  • Actions
    • Unit - Remove Unit[(that array number... lolx, sorry and sorry if I didn't explain it well)]
:fp: Do you get what I mean now ? :ogre_icwydt:
Please do a example for me if you get what I mean :D

He did, and the answer was correct, you cant. You have to loop through every timer and check if the expired timer was the timer, than u use the loop variable
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
:ogre_frown:Hmmmm....I told you that it is a thing that very hard to explain by me:ogre_frown:
Oh damn, I thought that was your signature. It's confusing.


I don't really know what you're trying to achieve with that, but I see 3 (actually 5) possibilities:
The easiest one (from what you've shown):
  • Unit - Add a (Real) second Generic expiration timer to (Unit)
Kills the (unit) after (real) seconds. No timers involved here.

The second and third option (in case you want to do more than just kill/remove the unit) are used to make stuff MUI.

Indexing (option 2):
  • Actions
    • Set Index = (Index + 1)
    • Set Unit[Index] = Unit that will get removed
    • Set TimeLeft[Index] = How much time (seconds) before getting removed
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Index Equal to 1
      • Then - Actions
        • Trigger - Turn on Index Loop <gen>
      • Else - Actions
  • Index Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopInt) from 1 to Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeLeft[LoopInt] Less than or equal to 0.00
            • Then - Actions
              • -------- Do actions here --------
              • Unit - Remove Unit[LoopInt] from the game
              • -------- Recycle index --------
              • Set Unit[LoopInt] = Unit[Index]
              • Set TimeLeft[LoopInt] = TimeLeft[Index]
              • Set Index = (Index - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 1
                • Then - Actions
                  • Trigger - Turn off Index Loop <gen>
                • Else - Actions
            • Else - Actions
              • Set TimeLeft[LoopInt] = (TimeLeft[LoopInt] - 0.10)
Hashtables (option 3):
  • Actions
    • Set Unit = Unit that will get removed
    • Custom script: set udg_HandleId = GetHandleId( udg_Unit )
    • Hashtable - Save 10.00 as 0 of HandleId in Hashtable
    • Unit Group - Add Unit to LoopGroup
    • Set GroupCount = (GroupCount + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • GroupCount Equal to 1
      • Then - Actions
        • Trigger - Turn on Hash Loop <gen>
      • Else - Actions
  • Hash Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in LoopGroup and do (Actions)
        • Loop - Actions
          • Custom script: set udg_HandleId = GetHandleId( GetEnumUnit() )
          • Set TimeLeft = ((Load 0 of HandleId from Hashtable) - 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeLeft Less than or equal to 0.00
            • Then - Actions
              • -------- Do actions here --------
              • Unit - Remove (Picked unit) from the game
              • -------- Flush Hashtable --------
              • Unit Group - Remove (Picked unit) from LoopGroup
              • Hashtable - Clear all child hashtables of child HandleId in Hashtable
              • Set GroupCount = (GroupCount - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GroupCount Equal to 1
                • Then - Actions
                  • Trigger - Turn off Hash Loop <gen>
                • Else - Actions
            • Else - Actions
              • Hashtable - Save TimeLeft as 0 of HandleId in Hashtable
The "maybe 4th option" uses a local timer (if you really insist on using a timer) and a hashtable.
I don't really like this method, so I'll only post this if you say you really need those timers (and why).

The 5th option is the one I stated in my original post. It's not recommended.
 
Level 10
Joined
Dec 15, 2012
Messages
650
Oh damn, I thought that was your signature. It's confusing.


I don't really know what you're trying to achieve with that, but I see 3 (actually 5) possibilities:
The easiest one (from what you've shown):
  • Unit - Add a (Real) second Generic expiration timer to (Unit)
Kills the (unit) after (real) seconds. No timers involved here.

The second and third option (in case you want to do more than just kill/remove the unit) are used to make stuff MUI.

Indexing (option 2):
  • Actions
    • Set Index = (Index + 1)
    • Set Unit[Index] = Unit that will get removed
    • Set TimeLeft[Index] = How much time (seconds) before getting removed
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Index Equal to 1
      • Then - Actions
        • Trigger - Turn on Index Loop <gen>
      • Else - Actions
  • Index Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopInt) from 1 to Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeLeft[LoopInt] Less than or equal to 0.00
            • Then - Actions
              • -------- Do actions here --------
              • Unit - Remove Unit[LoopInt] from the game
              • -------- Recycle index --------
              • Set Unit[LoopInt] = Unit[Index]
              • Set TimeLeft[LoopInt] = TimeLeft[Index]
              • Set Index = (Index - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 1
                • Then - Actions
                  • Trigger - Turn off Index Loop <gen>
                • Else - Actions
            • Else - Actions
              • Set TimeLeft[LoopInt] = (TimeLeft[LoopInt] - 0.10)
Hashtables (option 3):
  • Actions
    • Set Unit = Unit that will get removed
    • Custom script: set udg_HandleId = GetHandleId( udg_Unit )
    • Hashtable - Save 10.00 as 0 of HandleId in Hashtable
    • Unit Group - Add Unit to LoopGroup
    • Set GroupCount = (GroupCount + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • GroupCount Equal to 1
      • Then - Actions
        • Trigger - Turn on Hash Loop <gen>
      • Else - Actions
  • Hash Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in LoopGroup and do (Actions)
        • Loop - Actions
          • Custom script: set udg_HandleId = GetHandleId( GetEnumUnit() )
          • Set TimeLeft = ((Load 0 of HandleId from Hashtable) - 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeLeft Less than or equal to 0.00
            • Then - Actions
              • -------- Do actions here --------
              • Unit - Remove (Picked unit) from the game
              • -------- Flush Hashtable --------
              • Unit Group - Remove (Picked unit) from LoopGroup
              • Hashtable - Clear all child hashtables of child HandleId in Hashtable
              • Set GroupCount = (GroupCount - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GroupCount Equal to 1
                • Then - Actions
                  • Trigger - Turn off Hash Loop <gen>
                • Else - Actions
            • Else - Actions
              • Hashtable - Save TimeLeft as 0 of HandleId in Hashtable
The "maybe 4th option" uses a local timer (if you really insist on using a timer) and a hashtable.
I don't really like this method, so I'll only post this if you say you really need those timers (and why).

The 5th option is the one I stated in my original post. It's not recommended.
Thanks ! I will take a look at it. :)ogre_datass:but I won't use Hashtable, I damn hate it)
 
Level 10
Joined
Dec 15, 2012
Messages
650
:goblin_good_job:Actually I want something like this, possible o.0
  • Events
    • Timer[1]
  • Actions
    • Unit - Then resume corpse decaying of unit[1]
  • Events
    • Timer[2]
  • Actions
    • Unit - Then resume corpse decaying of unit[2]
But not possible to call me do them one by one till 8192, right...?
 
Status
Not open for further replies.
Top