I have a value from the data editor that I need to use, but unfortunately it's a reference. As far as I know, the only way to resolve data editor references is the Convert Game Text function, which returns a Text value (if I'm wrong here, please let me know!). There's no stylistic monkey business being applied to this value, it's just a plain string that I have the misfortune of only being able to reference via this Text variable. I need this to be a String (concatenation, parameters for built-in functions, etc).
Do I have any options, or did I just hit a brick wall?
And there's no other way to resolve the path given to me other than Convert Game Text? :( It's not seriously game-breaking, as I can hard-code the values, but I prefer not to where possible :D
Really just trying to get familiar with the editor with a tinkertoy project of mine. I had hardcoded the race names in ("Terran" "Zerg" "Protoss") and had a conversion to go back and forth from Race - Game Link to the full-name. Then I saw that one of the fields for Races is Name, and thought "Awesome! No more hard-coded value - I'll just grab the name from the Data Editor!"
However, the value for "Name" is "Race/Name/# #id# #," and from there I needed "Convert Game Text," and the rest is history :) I use the full-name in some triggers and need them to be Strings.
Again, not Earth-shattering, but I'm still a little sad that the elegant solution can't work :(
The main intent behind no text -> string conversion is that text values can change based on the locale of the user. You don't want to rely on them for lookups, only for displaying localized content to the user.
I'm still a bit fuzzy on your example, but why not pass the Race's id around (which is a static string value), and do a Catalog lookup for the name when you need it? And ditto, if you need to reference races in other data table entries, use the race id rather than its name ("Prot", "Terr", "Zerg", "Neut", etc). Any time you reference the race as a game link in the GUI, it just spits out a string with the race's id.
Mmm good point; in which case it's probably best that it is Text and not String, as I was expecting "Terran" "Zerg" and "Protoss" and would thus break completely in other locales.
I actually do pass the race ID around quite a bit. However, in some parts, I need the exact strings Terran/Zerg/Protoss and not their truncated Race Game Link counterparts. But since I need the exact strings T/Z/P, and only those strings, it makes sense that I should hard-code those.
Excellent. Thanks for the tips!
As a quick/completely unrelated aside, there's no dynamic memory allocation in Galaxy, correct? I'm trying to figure out how to store data arrays (though I may just leave them be and reference them via functions)... hmm. Something to ponder on tonight.
@Nevir27: Go
As a quick/completely unrelated aside, there's no dynamic memory allocation in Galaxy, correct? I'm trying to figure out how to store data arrays (though I may just leave them be and reference them via functions)... hmm. Something to ponder on tonight.
Sortakinda.
If you use the data table, you can simulate dynamic allocation (and it's pretty quick, though I haven't done extensive profiling yet), but you've got to build out a indexing scheme to use there so you avoid naming collisions. I tend to use "ListName/#" to store the count of items in a dynamic array, and "ListName/1", "ListName/2", etc to store values (starting at 1 makes life a lot easier when interacting with all the other Blizz stuff that starts at 1).
I have a value from the data editor that I need to use, but unfortunately it's a reference. As far as I know, the only way to resolve data editor references is the Convert Game Text function, which returns a Text value (if I'm wrong here, please let me know!). There's no stylistic monkey business being applied to this value, it's just a plain string that I have the misfortune of only being able to reference via this Text variable. I need this to be a String (concatenation, parameters for built-in functions, etc).
Do I have any options, or did I just hit a brick wall?
I think you just hit a brick wall.. Since there is no Text To String conversion.
And there's no other way to resolve the path given to me other than Convert Game Text? :( It's not seriously game-breaking, as I can hard-code the values, but I prefer not to where possible :D
Not sure exactly what you're trying to do, but there's a "Unit Type From String" function, and may be similar functions for other game link types.
@RileyStarcraft: Go
Really just trying to get familiar with the editor with a tinkertoy project of mine. I had hardcoded the race names in ("Terran" "Zerg" "Protoss") and had a conversion to go back and forth from Race - Game Link to the full-name. Then I saw that one of the fields for Races is Name, and thought "Awesome! No more hard-coded value - I'll just grab the name from the Data Editor!"
However, the value for "Name" is "Race/Name/# #id# #," and from there I needed "Convert Game Text," and the rest is history :) I use the full-name in some triggers and need them to be Strings.
Again, not Earth-shattering, but I'm still a little sad that the elegant solution can't work :(
@SiNiquity: Go
The main intent behind no text -> string conversion is that text values can change based on the locale of the user. You don't want to rely on them for lookups, only for displaying localized content to the user.
I'm still a bit fuzzy on your example, but why not pass the Race's id around (which is a static string value), and do a Catalog lookup for the name when you need it? And ditto, if you need to reference races in other data table entries, use the race id rather than its name ("Prot", "Terr", "Zerg", "Neut", etc). Any time you reference the race as a game link in the GUI, it just spits out a string with the race's id.
For ex, to get the localized name of the race:
@Nevir27: Go
Mmm good point; in which case it's probably best that it is Text and not String, as I was expecting "Terran" "Zerg" and "Protoss" and would thus break completely in other locales.
I actually do pass the race ID around quite a bit. However, in some parts, I need the exact strings Terran/Zerg/Protoss and not their truncated Race Game Link counterparts. But since I need the exact strings T/Z/P, and only those strings, it makes sense that I should hard-code those.
Excellent. Thanks for the tips!
As a quick/completely unrelated aside, there's no dynamic memory allocation in Galaxy, correct? I'm trying to figure out how to store data arrays (though I may just leave them be and reference them via functions)... hmm. Something to ponder on tonight.
Sortakinda.
If you use the data table, you can simulate dynamic allocation (and it's pretty quick, though I haven't done extensive profiling yet), but you've got to build out a indexing scheme to use there so you avoid naming collisions. I tend to use "ListName/#" to store the count of items in a dynamic array, and "ListName/1", "ListName/2", etc to store values (starting at 1 makes life a lot easier when interacting with all the other Blizz stuff that starts at 1).