• 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.

[Trigger] Make variable for all players?

Status
Not open for further replies.
Level 3
Joined
Mar 24, 2015
Messages
43
I'm fairly new to the WE, triggers, and especially making variables for triggers. Right now my solution for triggers goes something like this:

Event
-Player Red...
-Player Blue...
-Player Teal...
-Player Purple... (I have to do this for every, single, player for almost every, single, trigger I plan to use...)
Action
-example

How can I set up a variable to group all units into one, so instead of making an event for each player, I can just do one event and choose for the event to happen to all players? ...Make it look something like this:

Event
-Player (All Players)...etc
Action
-example
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
You can not directly. Here is a workaround:

Trigger1
Event
Map initialization
Actions
-bleh
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Trigger - Add to Trigger2 the event (Player - (Player((Integer A))) does something)
-bleh

Trigger2
Event
-Empty
Conditions
-Bleh
-Bleh
Actions
-Bleh
-Bleh
-Bleh
 
Level 18
Joined
May 11, 2012
Messages
2,108
As nedio mentioned.
If you have your initializating trigger, make there a loop that goes through all the players in your map and add event to your trigger(s).

I had this problem before, and this solves it pretty nicely.
 
Level 3
Joined
Mar 24, 2015
Messages
43
As nedio mentioned.
If you have your initializating trigger, make there a loop that goes through all the players in your map and add event to your trigger(s).

I had this problem before, and this solves it pretty nicely.

Can you show me exactly what you're talking about the way nedio did? I've never done a trigger with a loop.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
The loop does something for each number which you give it. In this case it will do something for every number between 1 and 12.
You can use the current number of the loop to do different things
Player((Integer A)) means that when the loop is on 1 it will do something for player 1, when it is on 2 it will do it for player 2 etc. etc.

Note: I tried to explain it as clear and simple as possible but I believe that I have failed...

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to GimmeGold <gen> the event (Player - (Player((Integer A))) types a chat message containing -Give Me Gold as An exact match)
  • GimmeGold
    • Events
    • Conditions
    • Actions
      • Player - Add 1000 to (Triggering player) Current gold
 
Status
Not open for further replies.
Top