Difference between revisions of "Dynamic Text"
m |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
− | + | =Basics= | |
Lets take a look at the baneling suicide building attack button tooltip. It uses a reference to automatically update the damage of the Tooltip when the Baneling's damage gets rebalanced or when upgrades are researched ingame: | Lets take a look at the baneling suicide building attack button tooltip. It uses a reference to automatically update the damage of the Tooltip when the Baneling's damage gets rebalanced or when upgrades are researched ingame: | ||
Line 16: | Line 16: | ||
*Navigate to the object you want to link | *Navigate to the object you want to link | ||
*To get the values you need, you have to turn on '''[[Raw Values]]''' with the leftmost orange button in the Data Editor | *To get the values you need, you have to turn on '''[[Raw Values]]''' with the leftmost orange button in the Data Editor | ||
− | *Datatype can be get from the field names: If you select an effect, you will see the Fieldnames starting with CEffect_, thus we need Effect. | + | *Datatype can be get from the field names: If you select an effect, you will see the Fieldnames starting with CEffect_, thus we need Effect. Behavior is CBehavior_, thus we need Behavior. |
*Object is the ID of your selected information source. With Raw Values on, it is the first word of its name ( the rest of the name is in brackets ). | *Object is the ID of your selected information source. With Raw Values on, it is the first word of its name ( the rest of the name is in brackets ). | ||
*Field is the name of the field whichs value you want to display. With Raw Values on it is the part of the Fieldname after the last "_". If the Fieldname has more than 1 underscore, look at the next section to learn how to build the correct path. | *Field is the name of the field whichs value you want to display. With Raw Values on it is the part of the Fieldname after the last "_". If the Fieldname has more than 1 underscore, look at the next section to learn how to build the correct path. | ||
Line 25: | Line 25: | ||
− | + | =Advanced= | |
To acess fields with multiple values, you can use the normal '''array''' notation: | To acess fields with multiple values, you can use the normal '''array''' notation: | ||
Line 53: | Line 53: | ||
− | + | =Closing= | |
Further research required: '''"<s ref="''' instead of '''"<d ref="''' seems to resolve, but displays nothing. String and decimal? | Further research required: '''"<s ref="''' instead of '''"<d ref="''' seems to resolve, but displays nothing. String and decimal? | ||
Now you know how to reference fields of the Data Editor in displayed Texts, reducing work needed to maintaince your map when changes to existing objects need to be made and allowing you to easily create templates where you just have to change the object without transfering all values. | Now you know how to reference fields of the Data Editor in displayed Texts, reducing work needed to maintaince your map when changes to existing objects need to be made and allowing you to easily create templates where you just have to change the object without transfering all values. | ||
− | = | + | =Credit(s)= |
*[http://www.sc2mod.com/board/index.php?page=Thread&threadID=242 Dynamic Text through Data Editor References] (Dekar, ''Sc2Mod.com'') Original article that this page is based on. Thanks to Dekar for the work he put into writing this. | *[http://www.sc2mod.com/board/index.php?page=Thread&threadID=242 Dynamic Text through Data Editor References] (Dekar, ''Sc2Mod.com'') Original article that this page is based on. Thanks to Dekar for the work he put into writing this. | ||
Latest revision as of 21:35, 8 April 2012
Dynamic Text is a reference in a displayed text to any field in the Data Editor of any type of object. It will automatically be replaced with the value of this field and thus allows you to create tooltips which show updated unit stats, no matter how much you change them around or how many upgrades are changing their stats.
Basics
Lets take a look at the baneling suicide building attack button tooltip. It uses a reference to automatically update the damage of the Tooltip when the Baneling's damage gets rebalanced or when upgrades are researched ingame:
<d ref="Effect,BanelingU2,Amount"/>
Essentially what this means is:
<d ref="(Datatype),(Object),(Field)"/>
Lets try to build a dynamic link now (using the image below as reference):
- Navigate to the object you want to link
- To get the values you need, you have to turn on Raw Values with the leftmost orange button in the Data Editor
- Datatype can be get from the field names: If you select an effect, you will see the Fieldnames starting with CEffect_, thus we need Effect. Behavior is CBehavior_, thus we need Behavior.
- Object is the ID of your selected information source. With Raw Values on, it is the first word of its name ( the rest of the name is in brackets ).
- Field is the name of the field whichs value you want to display. With Raw Values on it is the part of the Fieldname after the last "_". If the Fieldname has more than 1 underscore, look at the next section to learn how to build the correct path.
- Put your dynamic link together and use it in a displayed text. You are done!
Be aware though, that the displayed values will be rounded to the nearest whole number!
Advanced
To acess fields with multiple values, you can use the normal array notation:
Fieldname: PeriodicPeriodArray[0]
Some fields have more complicated names, for example the cooldown of the Blink ability:
CAbilEffect_Cost_Cooldown_TimeUse
This is the "Fieldname" we want to get in the end: Cost[0].Cooldown.TimeUse
This is a bit trickier:
- First we need to find out if the main field "Cost" is an array. Therefore we either enable "Combine Structure Values" and look if the name has a "+" like this: CAbilEffect_Cost + or we look if there are multiple field names with the same part of the name (here "Cost").
- If that is the case, we have to add an array index. Cost seems to have only one instance, so it should always get [0] added.
- Then we also have to replace all underscores with periods.
You can even do math with the values:
<d ref="Effect,250mmStrikeCannonsCreatePersistent,PeriodCount * Effect,250mmStrikeCannonsCreatePersistent,PeriodicPeriodArray[0]"/>
And you can use it in triggers whenever the Text type is used, like in Display Text. Strings containing a dynamic link converted to Text does also work.
Closing
Further research required: "<s ref=" instead of "<d ref=" seems to resolve, but displays nothing. String and decimal?
Now you know how to reference fields of the Data Editor in displayed Texts, reducing work needed to maintaince your map when changes to existing objects need to be made and allowing you to easily create templates where you just have to change the object without transfering all values.
Credit(s)
- Dynamic Text through Data Editor References (Dekar, Sc2Mod.com) Original article that this page is based on. Thanks to Dekar for the work he put into writing this.