HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Acquiring arrays from events

11-28-2008, 06:33 AM#1
ShadowWolf
Is it possible to acquire the element of an array in an event and use it in an action? I got stuck with a list of triggers for an arrayed timer because I can't figure this out and I really want to condense them.

Problem: I have a timer array with 12 elements to have a countdown timer that corresponds to each player respectively because each person can have a different count as another player simultaneously. I have a similar set of actions for if any of the timers expire, but those actions require knowing which timer set off the trigger. Right now I have a seperate trigger for each timer with the following setup
Trigger:
Release 1
Collapse Events
Time - timer_Capture[1] expires
Conditions
Collapse Actions
Set temp_Player = Player 1 (Red)
Set temp_Int = (Player number of temp_Player)
Player Group - Remove temp_Player from pg_Jail[3]
Trigger - Run Release <gen> (ignoring conditions)
Trigger "Release" has the universal actions that function on the two temp variables shown. I want to be able to throw it all into one trigger with a list of the 12 events, and then be able to pull the number of the element that ran the trigger. I doubt this is possible, but I'm asking for the sake of a possibility. I don't know any JASS, so if the solution lies therein, you'll need to spoonfeed me some custom script :<
11-28-2008, 07:25 AM#2
botanic
could use a 12 array global and set the aproprate players # to true then false after the 2nd trigger runs, and do some sort of loop to find which one is true at the begining
11-28-2008, 08:14 AM#3
ShadowWolf
That would be sloppy compared to what it is now, and wouldn't make anything more efficient. It runs fine as is, I'm just looking for a way to compact it.
11-28-2008, 08:44 AM#4
Pyrogasm
You could do this:
[trigger]
Trigger:
Collapse Events
Time - timer_Capture[1] expires
Time - timer_Capture[2] expires
Time - timer_Capture[3] expires
Time - timer_Capture[4] expires
Time - timer_Capture[5] expires
Time - timer_Capture[6] expires
Time - timer_Capture[7] expires
Time - timer_Capture[8] expires
Time - timer_Capture[9] expires
Time - timer_Capture[10] expires
Time - timer_Capture[11] expires
Time - timer_Capture[12] expires
Conditions
Collapse Actions
Set temp_Timer = (Expired Timer)
Collapse For each (Integer A) from 1 to 12 do (Actions)
Collapse Loop - Actions
Collapse If (All conditions are true) then do (Then actions) else do (Else actions)
Collapse If - Conditions
temp_Timer equal to timer_Capture[(Integer A)]
Collapse Then - Actions
Set temp_Player = Player((Integer A))
Set temp_Int = (Integer A)
Custom script: exitwhen true
Player Group - Remove temp_Player from pg_Jail[3]
Trigger - Run Release <gen> (ignoring conditions)
12-04-2008, 07:09 PM#5
ShadowWolf
omg i <3 you.

aff i feel stupid now ._.

EDIT: Eh, Idk if I'm just blind, but there's no Timer Comparison condition. wtf D:<
12-05-2008, 12:58 AM#6
Pyrogasm
I think you might have to do it through a boolean comparison:
Trigger:
(temp_Timer equal to Expired Timer) equal to True
Yeah, GUI is dumb like that.
12-05-2008, 04:54 AM#7
ShadowWolf
That doesn't exist as a boolean either. Yes, I know GUI is lame.. What's the custom script for that condition? WEU allows custom script conditions so, I'm thinking that's the best way to go at this point.
12-05-2008, 05:20 AM#8
Pyrogasm
Collapse JASS:
udg_temp_Timer == GetExpiredTimer()
I never realized that GUI doesn't even have a Variable == Variable comparison. That's super fail.
12-05-2008, 05:31 AM#9
ShadowWolf
Thanks a bunch man, I'll give it a try.