I'm making a trigger that fires on a unitDeath event. The event will result in a printout to a file with the following information:
[player, x-coord of death, y-coord of death, gametime, unit-type-name]
I succeeded to make a printout with everything except the last element: unit-type-name. An example:
The problem with such a function is that the name varies depending on the language of SC II. That is why you only have a function that will return it as a text (Unit Type - Unit Type of Unit).
You should still be able to use that to print it to chat or save it in a bank (as a text).
I think that the only alternative is to make a function with a giant if over your relevant unit types.
And since I'm only interested in the unit name (or other form of ID) I cant access the string. Do you know any way to retreive the Type element from that data?
I had the gigantic if/switch in mind as well. I would prefer do avoid it if possible...
Variable - Set string = (Value of Buttons (String((Unit type of (xxUNITxx)))) "Name" for player xxPLAYERxx)
Variable - Set text = StringExternal(lv_string)
The StringExternal is the function to call from the text files; you will need to write it in the custom script field. You can change buttons to Unit/Actor whatever depending on your preference.
If you just want the ID then you can just use the string variable without using stringexternal.
I'm making a trigger that fires on a unitDeath event. The event will result in a printout to a file with the following information: [player, x-coord of death, y-coord of death, gametime, unit-type-name]
I succeeded to make a printout with everything except the last element: unit-type-name. An example:
But when it comes to the unit-type-name i fail. Is there some way to retreive a specific units type-name as a string, if you have the unit as such?
The problem with such a function is that the name varies depending on the language of SC II. That is why you only have a function that will return it as a text (Unit Type - Unit Type of Unit).
You should still be able to use that to print it to chat or save it in a bank (as a text).
I think that the only alternative is to make a function with a giant if over your relevant unit types.
@SBeier: Go The problem with the Unit Type - Unit Type of Unit is that it will create a bank element like this:
And since I'm only interested in the unit name (or other form of ID) I cant access the string. Do you know any way to retreive the Type element from that data?
I had the gigantic if/switch in mind as well. I would prefer do avoid it if possible...
@Monkalizer: Go
I decided to use a switch with some focus unit types. Its not perfect, but it will do. The bank-output is now:
...
Catalog Field Value Get.
Create a local string variable called string.
Variable - Set string = (Value of Buttons (String((Unit type of (xxUNITxx)))) "Name" for player xxPLAYERxx) Variable - Set text = StringExternal(lv_string)
The StringExternal is the function to call from the text files; you will need to write it in the custom script field. You can change buttons to Unit/Actor whatever depending on your preference.
If you just want the ID then you can just use the string variable without using stringexternal.