I've had this question myself, and others have as well on various forums. So I thought I'd centralize all the answers in to one tutorial. This doesn't actually change the command card (since there is no way to via triggers (yet?)), but rather gives the illusion that it does, which is just as good.
In this example, I will be swapping between 2 sets of units to train from my Nexus.
First, you just need to set all of your abilities on command card page 1. In my example, I have Protoss units as the default buttons, and Terran units as the alternate:
Next, you need to have a button that swaps between the units:
I'm not showing all of the units, because that would require too many pictures. The idea is the same for all of them; however with unit training, you have to disable the entire ability to train units. Thus if you only want 1 unit disabled, you would have to create a new train ability for each unit individually (of course, in the case of abilities that you have created yourself, disabling just that ability alone works fine).
Finally, just set up your trigger like so:
making sure that you've set a global variable into an array (only global array variable works for some reason, and local anything doesn't. I'm not sure why), and there you have it. What this does, is it allows the player to swap back and forth between the unit builds. Normally, when you swap to command card page 2, it swaps back to page one after:
1) selecting an ability, or
2) when you select a different unit and back
This video displays the working trigger in action, swapping between the unit choices and staying that way even when you select another unit and back.
If anyone needs clarification on anything, feel free to ask.
The reason a local doesn't work is because local variables get deleted after each run of the trigger. So the next time you come into the trigger the local variable is reset to the default value. So whenever you want to store something between trigger runs you need to put it into a global variable.
It should be possible to change the command card via triggers by writing to the catalog, although I haven't tested it and certain catalog values can't be written so no confirmation yet.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I've had this question myself, and others have as well on various forums. So I thought I'd centralize all the answers in to one tutorial. This doesn't actually change the command card (since there is no way to via triggers (yet?)), but rather gives the illusion that it does, which is just as good.
In this example, I will be swapping between 2 sets of units to train from my Nexus.
First, you just need to set all of your abilities on command card page 1. In my example, I have Protoss units as the default buttons, and Terran units as the alternate:
Next, you need to have a button that swaps between the units:
I'm not showing all of the units, because that would require too many pictures. The idea is the same for all of them; however with unit training, you have to disable the entire ability to train units. Thus if you only want 1 unit disabled, you would have to create a new train ability for each unit individually (of course, in the case of abilities that you have created yourself, disabling just that ability alone works fine).
Finally, just set up your trigger like so:
making sure that you've set a global variable into an array (only global array variable works for some reason, and local anything doesn't. I'm not sure why), and there you have it. What this does, is it allows the player to swap back and forth between the unit builds. Normally, when you swap to command card page 2, it swaps back to page one after:
1) selecting an ability, or
2) when you select a different unit and back
This video displays the working trigger in action, swapping between the unit choices and staying that way even when you select another unit and back.
If anyone needs clarification on anything, feel free to ask.
Neat tutorial.
The reason a local doesn't work is because local variables get deleted after each run of the trigger. So the next time you come into the trigger the local variable is reset to the default value. So whenever you want to store something between trigger runs you need to put it into a global variable.
Just to add: The maximum of buttons you can have in one command card are 32. That's very limiting..
It should be possible to change the command card via triggers by writing to the catalog, although I haven't tested it and certain catalog values can't be written so no confirmation yet.