I have mission selecting screen on my campaign and there are 11 buttons already with exactly same actions and only "used dialog item" thing is different on each case.
What is best way to make this thing work with only 1 trigger?
OK. Thanks for quick reply. You saied "drop them into array something like MissionButton[10] - array of size 10" I have no idea how to make arrays and this is propably the BIG thing I have missed earlier.
//Creating buttonsActions// Your button 1 creating codeVariable-SetMyButtons[1]=(Lastcreateddialogitem)// Your button 2 creating codeVariable-SetMyButtons[2]=(Lastcreateddialogitem)// Etc...
UntitledTriggerEventsDialog-AnyDialogItemisusedbyPlayerAnyPlayerwitheventtypeClickedLocalVariablesConditionsActionsGeneral-Switch(Actions)dependingon(Useddialogitem)CasesGeneral-If(MyButtons[1])Actions// Do something for button 1General-If(MyButtons[2])Actions// Do something for button 2Default
Can you help with that text message part of my trigger somehow?
I mean: For example "Mission1 pressed" - Can I include that action into text message like "MissionX selected." without actually using text message trigger as I did?
you can create local variable of type integer,
replace 'ui -display text' with 'myInt = x' where x is mission number
under entire switch even below 'default' do something like:
ui - display text(CombineTextMultiple( "Mission " + ConvertIntegerToText(MyInt) + "selected" ))
EDIT:
Quote:
How to link used button? (array)
No such thing
@DogmaiSEA: Go
i bet he doesn't know how and it will just create more questions :)
This is fine for a low amount of buttons, like you got there. You could probably change your Mission Number from a global variable to a local variable. You created it in the same area you create a new trigger. You can instead create it by adding it to the Local Variables - field within your trigger, so the variable becomes exclusive to this trigger.
However, if the buttons get more, it becomes tedious to copy & paste the switch line again and again. Thats where you could use a loop as suggested before.
Note, that your version triggers for all dialog buttons you can click, and even, if it is not one of your mission buttons, it will consider it as the 1000th button.
Also, don't loop more than you need. If you have 4 buttons, loop 4 times.
I moved UI - Display before 'Break' so update your trigger.
Idk much about loading other maps. If you can type them by name it's similar process as with UI message. It they are only variables then you need to create array of those maps and load map[i];
So how can set next map to xxx_Mission1, xxx_Mission2 etc after all this array looping stuff ;)
Loading a new map within another one is ONLY possible, if all of the following requirements are met (at least to my knowledge):
The map is played in singleplayer, by actually opening the map file with SC2, not just by selecting "Play vs CPU" on Bnet
The map, and every new map, which should be opened is in this folder:
(SC2 Installation folder)\Maps
NOT in the maps folder in your documents.
This also means, that it does not work in multiplayer, ever. Also, you cannot distribute the map via Battle.net. Everyone playing the map needs to download all the map files manually and place them in the correct folder.
If you matched these requirements, you can set a new map by name with the Set Next Map function. Once set, it will be automatically started, after you trigger a victory for the player,
My campaign maps are played offline so it doesn't matter and I have used load next mission earlier. I'm not exactly sure how I'm supposed to name my maps with this system.
Hand_of_Humanity_Mission1 , Hand_of_Humanity_Mission01... or something else?
How that variable (integer) is combined as text? 01 or 1?
Hope you understand my question. I'll do some some testing.
- -
EDIT: For each integer x to x seems to affect how number is converted.
How that variable (integer) is combined as text? 01 or 1?
It's converted. No reason why it should add 0 in front of it. You need to learn what variables are and what their types represent. Really don't go shortcut just because we pasted some code. Use google and search for things like 'integer' 'string' 'loop' etc.
EDIT: For each integer x to x seems to affect how number is converted.
It's not converted. For each is a loop. it goes from xstart to xend like from 0 to 5 it goes 0,1,2,3,4,5 every time executing code in its Actions section. On top of that the 'integer', passed as your variable, is set to current value of loop so if 0-5 loop goes second time it will be 1. round0-0,round1-1 etc..
At first thanks for this tutorial: http://www.sc2mapster.com/forums/resources/tutorials/34020-trigger-keeping-your-code-clean-and-organised-beginner/#p19
I have mission selecting screen on my campaign and there are 11 buttons already with exactly same actions and only "used dialog item" thing is different on each case.
What is best way to make this thing work with only 1 trigger?
OK. Thanks for quick reply. You saied "drop them into array something like MissionButton[10] - array of size 10" I have no idea how to make arrays and this is propably the BIG thing I have missed earlier.
when you create variable - either global or local - there's a checkbox
I'm stuck at the moment. Now I have an idea what is array but I don't really understand yet how I'm going to tell my trigger that array thing :)
So final result should be trigger "Any button pressed" instead of "Mission1 pressed" "Mission2..." etc.
Example:
Global Variable: MyButtons <Dialog Item[10]>
I'm learning :D
EDIT: You posted at the same time as me Nerfpl :)
Can you help with that text message part of my trigger somehow?
I mean: For example "Mission1 pressed" - Can I include that action into text message like "MissionX selected." without actually using text message trigger as I did?
How to link used button? (array)
Use Arrays then use a loop to loop through them all.
you can create local variable of type integer,
replace 'ui -display text' with 'myInt = x' where x is mission number
under entire switch even below 'default' do something like:
ui - display text(CombineTextMultiple( "Mission " + ConvertIntegerToText(MyInt) + "selected" ))
EDIT:
No such thing
@DogmaiSEA: Go i bet he doesn't know how and it will just create more questions :)
Well, you need to check, which of the buttons in the array is the one, which was pressed. You might want to do something like this (pseudocode):
€ wow, dual ninja
Improved version of trigger. This way text message part works but I still need to change variable on each situation.
More tips? :)
I have learned alot, thank you!
This is fine for a low amount of buttons, like you got there. You could probably change your Mission Number from a global variable to a local variable. You created it in the same area you create a new trigger. You can instead create it by adding it to the Local Variables - field within your trigger, so the variable becomes exclusive to this trigger.
However, if the buttons get more, it becomes tedious to copy & paste the switch line again and again. Thats where you could use a loop as suggested before.
as DogmaiSEA said
Shortest version possible
Just don't ask how does it work :p
What DogmaiSEA saied earlier works good. I just didn't understand anything about loops before Nerfpl did that example trigger.
If you can help with one last part of map selection my mission selection is screen is perfect :)
So how can set next map to xxx_Mission1, xxx_Mission2 etc after all this array looping stuff ;)
It isn't necessary to make this because there won't be like 200 buttons ever but I'm interested is that kind of thing possible.
So my current trigger is:
Note, that your version triggers for all dialog buttons you can click, and even, if it is not one of your mission buttons, it will consider it as the 1000th button.
Also, don't loop more than you need. If you have 4 buttons, loop 4 times.
@Terhonator: Go
I moved UI - Display before 'Break' so update your trigger.
Idk much about loading other maps. If you can type them by name it's similar process as with UI message. It they are only variables then you need to create array of those maps and load map[i];
Loading a new map within another one is ONLY possible, if all of the following requirements are met (at least to my knowledge):
(SC2 Installation folder)\Maps
NOT in the maps folder in your documents.
If you matched these requirements, you can set a new map by name with the Set Next Map function. Once set, it will be automatically started, after you trigger a victory for the player,
My campaign maps are played offline so it doesn't matter and I have used load next mission earlier. I'm not exactly sure how I'm supposed to name my maps with this system.
Hand_of_Humanity_Mission1 , Hand_of_Humanity_Mission01... or something else?
How that variable (integer) is combined as text? 01 or 1?
Hope you understand my question. I'll do some some testing.
- -
EDIT: For each integer x to x seems to affect how number is converted.
It's converted. No reason why it should add 0 in front of it. You need to learn what variables are and what their types represent. Really don't go shortcut just because we pasted some code. Use google and search for things like 'integer' 'string' 'loop' etc.
It's not converted. For each is a loop. it goes from xstart to xend like from 0 to 5 it goes 0,1,2,3,4,5 every time executing code in its Actions section. On top of that the 'integer', passed as your variable, is set to current value of loop so if 0-5 loop goes second time it will be 1. round0-0,round1-1 etc..
Imo thread solved. i'm out