Is it possible to use triggers to make an income tab that is visible during game-play? We need this to adjust some mining values and see the results instantly. Any help is appreciated.
Create a dialog and measure the change in resources earned over time, then display that value. For example, create two integer variables (MineralsTHEN and MineralsNOW.) Create a periodic trigger running every 5 seconds in which you set MineralsTHEN = MineralsNOW, then MineralsNOW = minerals earned by player X. Oh, and make sure you set MineralsNOW to start at 1 or higher or you'll get a divide by zero error. Here's what I have in mind:
Thanks! I am working on it. I am kinda new at triggers. Now "Income" will be set as a local varable and I assume that "MineralsTHEN" will be set as a global variable (since it is not set up at all) but when I add "variable" to actions I can only pick from the local ones. Any help? :)
Well, MineralsTHEN could be made a local variable since it doesn't need to be stored outside of the trigger's functions. MineralsNOW, however, must be global. If you want to read income from multiple players, I recommend making MineralsNOW an array of integers, one for each player.
You'll need to declare the variables in the trigger object window (lower left side of the Triggers dialog) before you can use them in functions. You can also declare them via script but I think that's a bit more advanced than what we need right now :P
If your global variables are still not showing up, make sure you have them set as Integers.
The example I set up won't be a perfect indicator of income (since it's really just averaging the change in resources collected per second over 5 seconds) but it should help keep performance from dragging too much. If you need it to be more accurate, adjust the times and maths as necessary; the more often you check the change in resources collected, the more accurately you will portray "income."
Here I'm using the Set Dialog Item Text function, and within that function I'm using the Convert Integer to Text function instead of a straight text entry.
Got it! Now I am having trouble actually creating the dialog (it does not show up on my screen).
I use:
Dialog - Create a Modal dialog of size (something, something) at (somwhere) realitve to center of the map
Dialog - Create a Button (maybe it should be label) for dialog (Last created dialog)
Dialog - Set (Last created dialog) text to (Text(Income)) for (All players)
What's wrong?
Edit: I got it to show up by using the show/hide dialog, but is just showing a bit "2" no matter my income.
I recommend making it a label rather than a button, but that's mostly for aesthetic reasons (unless you want the button to actually do something.)
You need to create a global dialog item variable and set it to the label (or button) you created in your dialog. The best way to do this is to declare the variable in the trigger object window and set it in your actions immediately after creating the label/button (use the "last created dialog item" function.) Then in your income trigger, set it to change the text of the dialog item variable you just made. In my example trigger, I called the variable "My Income Dialog - Amount." I don't remember if spaces can actually be used for variable names, but I think you get the idea!
I get the general idea, but I still cannot get it to work. Sorry for bothering so much, but I am learning a lot from this. Hopefully I won't need this much help in the future.
So this is what I did. I made a separate trigger which creates a dialog and added a "show dialog" to it. I also created a label in the same trigger (I used the map initialization as condition).
Then I made a global dialog item to "save" the label (last created dialog item). Then I used the "Set (Name of dialog item) text change text to integer" in the income display trigger (the trigger we have been working on).
It does not "connect" the one I make with the text change I desire. It creates the dialog and shows the text on the label, but it does not change it to my current income.
Here are both triggers and the dialog item variable. There are some more triggers there as well but they are for worker behavior, they should not interfere.
Ok, I see what happened. You need to assign the dialog item variable to your label with a Set Variable action immediately after creating the label. Functions like "last created dialog item" don't work as initial values for variables at declaration.
Hello!
Is it possible to use triggers to make an income tab that is visible during game-play? We need this to adjust some mining values and see the results instantly. Any help is appreciated.
@KanBan85: Go
Create a dialog and measure the change in resources earned over time, then display that value. For example, create two integer variables (MineralsTHEN and MineralsNOW.) Create a periodic trigger running every 5 seconds in which you set MineralsTHEN = MineralsNOW, then MineralsNOW = minerals earned by player X. Oh, and make sure you set MineralsNOW to start at 1 or higher or you'll get a divide by zero error. Here's what I have in mind:
Thanks! I am working on it. I am kinda new at triggers. Now "Income" will be set as a local varable and I assume that "MineralsTHEN" will be set as a global variable (since it is not set up at all) but when I add "variable" to actions I can only pick from the local ones. Any help? :)
@KanBan85: Go
Well, MineralsTHEN could be made a local variable since it doesn't need to be stored outside of the trigger's functions. MineralsNOW, however, must be global. If you want to read income from multiple players, I recommend making MineralsNOW an array of integers, one for each player.
You'll need to declare the variables in the trigger object window (lower left side of the Triggers dialog) before you can use them in functions. You can also declare them via script but I think that's a bit more advanced than what we need right now :P
If your global variables are still not showing up, make sure you have them set as Integers.
The example I set up won't be a perfect indicator of income (since it's really just averaging the change in resources collected per second over 5 seconds) but it should help keep performance from dragging too much. If you need it to be more accurate, adjust the times and maths as necessary; the more often you check the change in resources collected, the more accurately you will portray "income."
Thanks again! I've gotten global variables to work now. One more thing:
Which dialog action do I chose to display a variable? I can only get it to display text and I cannot set the text as the variable.
I did google around and check the wiki before posting this but I cannot find it.
@KanBan85: Go
Use the conversion > convert integer to text function. It's what I used in my example:
Here I'm using the Set Dialog Item Text function, and within that function I'm using the Convert Integer to Text function instead of a straight text entry.
Got it! Now I am having trouble actually creating the dialog (it does not show up on my screen).
I use:
Dialog - Create a Modal dialog of size (something, something) at (somwhere) realitve to center of the map Dialog - Create a Button (maybe it should be label) for dialog (Last created dialog) Dialog - Set (Last created dialog) text to (Text(Income)) for (All players)
What's wrong?
Edit: I got it to show up by using the show/hide dialog, but is just showing a bit "2" no matter my income.
@KanBan85: Go
I recommend making it a label rather than a button, but that's mostly for aesthetic reasons (unless you want the button to actually do something.)
You need to create a global dialog item variable and set it to the label (or button) you created in your dialog. The best way to do this is to declare the variable in the trigger object window and set it in your actions immediately after creating the label/button (use the "last created dialog item" function.) Then in your income trigger, set it to change the text of the dialog item variable you just made. In my example trigger, I called the variable "My Income Dialog - Amount." I don't remember if spaces can actually be used for variable names, but I think you get the idea!
I get the general idea, but I still cannot get it to work. Sorry for bothering so much, but I am learning a lot from this. Hopefully I won't need this much help in the future.
So this is what I did. I made a separate trigger which creates a dialog and added a "show dialog" to it. I also created a label in the same trigger (I used the map initialization as condition).
Then I made a global dialog item to "save" the label (last created dialog item). Then I used the "Set (Name of dialog item) text change text to integer" in the income display trigger (the trigger we have been working on).
It does not "connect" the one I make with the text change I desire. It creates the dialog and shows the text on the label, but it does not change it to my current income.
Hmm, I'm going to need a screenshot of both triggers to troubleshoot.
Here are both triggers and the dialog item variable. There are some more triggers there as well but they are for worker behavior, they should not interfere.
http://imgur.com/MVkNiS9
http://imgur.com/6I4CXvF
http://imgur.com/vfYjeaZ
@KanBan85: Go
Ok, I see what happened. You need to assign the dialog item variable to your label with a Set Variable action immediately after creating the label. Functions like "last created dialog item" don't work as initial values for variables at declaration.
But the label is the dialog item. I can only assign dialogs to labels not a dialog item.Would you care to expand your last statement a bit more? Sorry that you have to spoon-feed me this, I am very new to trigger work.Scrap that, fixed it, thanks for all the help!