This trigger works great because I'm able to use the (Triggering player) in the Actions because the event that triggers this is a player's vespene count changes.
When I'm trying to record some attribute about the player every X seconds like APM:
I don't have a notion of (Triggering player) anymore so I'm forced to use Player 1 APM score to get the APM and then player 1 to get the bank. This will record data on Player 1's computer, but Player 2's data won't be saved unless I make another trigger or duplicate some code to also get their APM.
Is there any way around this Timer-triggered events/getting access to the player index? I don't particularly care about player indices in this case and I don't want to have 2 version of every trigger. Am I missing something obvious?
Thanks in advance for the help!
EDIT: Here's the most "concise" solution I can come up with:
You only need to open your banks once ever during the map. So your script would look like this now:
WriteAPMtoevery1secondEventsTimer-Every1.0secondsofGameTimeLocalVariablesi=0<Integer>playerAPM=(PlayeriAPMscore)<Integer>ConditionsActionsPlayerGroup-Foreachplayeriin(Allplayers)do(Actions)ActionsVariable-SetplayerAPM=(PlayeriAPMscore)Bank-StoreintegerplayerAPMas"player_apm"ofsection"data"inbankBanks[i]
Bank - Save bank Banks[i]
Now that you've got your banks stored in an array variable, you can very easily reference them in the future. Bank[1] is player 1's bank, bank[7] would be player 7's bank, etc... Using the "Last created/destroyed/opened/used whatever" functions is generally something I advise against, except of course when using it immediately after the corresponding action to something to assign a variable. You just tend to run into less issues that way (using the "last created" functions is not a problem itself, but improperly using them will result in issues).
In the case of banks I advise people use to use variables like this to keep things clean and organized, but again, the trigger you have now looks totally fine.
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
To post a comment, please login or register a new account.
Hi all! Having some problems with a 2 player map I'm working on. Here's where I'm getting stuck...
This trigger works great because I'm able to use the (Triggering player) in the Actions because the event that triggers this is a player's vespene count changes.
When I'm trying to record some attribute about the player every X seconds like APM:
I don't have a notion of (Triggering player) anymore so I'm forced to use Player 1 APM score to get the APM and then player 1 to get the bank. This will record data on Player 1's computer, but Player 2's data won't be saved unless I make another trigger or duplicate some code to also get their APM.
Is there any way around this Timer-triggered events/getting access to the player index? I don't particularly care about player indices in this case and I don't want to have 2 version of every trigger. Am I missing something obvious?
Thanks in advance for the help!
EDIT: Here's the most "concise" solution I can come up with:
Once I learn how to write share-able modules, this probably won't look to bad, but is there a better way?
"For each player in player group" is a loop that can iterate over all active players storing their player number in a variable.
Also, you would want to save bank variables in an array with the player number as its index. Then you can always save the value in the correct bank.
@Ahli634: Go
Thank you for the reply! I think I got the first part of your recommendation working!
What would the bank code you described look like generally? Is what I'm doing now not correct or just not recommended/standard?
Thank you!
The "Standard" banking procedure would be something like this:
At the start of the map this is run once:
You only need to open your banks once ever during the map. So your script would look like this now:
Now that you've got your banks stored in an array variable, you can very easily reference them in the future. Bank[1] is player 1's bank, bank[7] would be player 7's bank, etc... Using the "Last created/destroyed/opened/used whatever" functions is generally something I advise against, except of course when using it immediately after the corresponding action to something to assign a variable. You just tend to run into less issues that way (using the "last created" functions is not a problem itself, but improperly using them will result in issues).
In the case of banks I advise people use to use variables like this to keep things clean and organized, but again, the trigger you have now looks totally fine.