Hey guys! I heard this community was really good when it comes to StarCraft in general.
Straight to the point, I made a unit with a couple of random names in the Data Editor (in Unit>(Unit Here)>Random Names) and I want to know if it is possible to return the (random) name of the unit for a trigger I'm using. Can anyone help me on this?
As far as I can tell, there's no way to reference a unit's random name with triggers. Depending on what you're trying to do, it may be better to randomly assign the unit a name with your own trigger than to use the Data editor. Then you can store the unit's name in a variable and later show the unit's name with a custom dialog.
There is no native way of changing a units name via script, the only possibility is using a custom UI and, for example, datatables to link a custom text to a unit and display it.
you can also set the names with catalog. have an array of text, select a random one and set the name of index 0 (might need one dummy name on index 0).
now save the array index as custom value on the unit. do that for all units
Okay, so I get what you're trying to say I just don't know how to set up the trigger?
Could you show me an example of this catalog and setting unit custom value thing? I'm not the best at the editor.
EDIT: So I did the catalog thing, I removed the random names section and instead made it into a trigger with 12 different strings in an array. I used the select random integer with the array to get a random name but is there a way to make it so that you can't have the same random name? Say if the number chosen was 9, is there a way to remove the 9th string from the random integer selection?
you have to build this yourself. in your case you could have another array of booleans. bool[12]. you pick a random number, set the name, save the custom, set the bool[x] to true. next time you check the bool first if it is true, use another random variable.
my way of doing this is a custom function returning an int with a param int, mycustomFun(int x).
inside this function is a if then else, if bool[x] == true then return myCustomFun(random integer from 1 to 12) otherwise return x
this works if you need "some" different integers, if you need to use all 12 you also have to shrink the min and max of the random int if taken already.
alternativly you could just take the next free int of the array, myCustomFun2 (int x).
if bool[x] == true && x < 12 then return myCustomFun2 (x +1), if bool[x] == false then return x, if x>= 12 then return myCustomFun2 (1)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey guys! I heard this community was really good when it comes to StarCraft in general.
Straight to the point, I made a unit with a couple of random names in the Data Editor (in Unit>(Unit Here)>Random Names) and I want to know if it is possible to return the (random) name of the unit for a trigger I'm using. Can anyone help me on this?
Much appreciated!
As far as I can tell, there's no way to reference a unit's random name with triggers. Depending on what you're trying to do, it may be better to randomly assign the unit a name with your own trigger than to use the Data editor. Then you can store the unit's name in a variable and later show the unit's name with a custom dialog.
How would I go about changing the unit's name in a trigger?
There is no native way of changing a units name via script, the only possibility is using a custom UI and, for example, datatables to link a custom text to a unit and display it.
i don't know why noone likes the catalog triggers.i have tested this and works well
Catalog : Units
Entry : YourUnit
Path : RandomNameArray[x]
you can show all random names from index 0 to x
you need the stringExternal native or you will just get the textKey and not the name
How do you know which random name is currently active though?
@Mille25: Go
you can also set the names with catalog. have an array of text, select a random one and set the name of index 0 (might need one dummy name on index 0). now save the array index as custom value on the unit. do that for all units
Okay, so I get what you're trying to say I just don't know how to set up the trigger? Could you show me an example of this catalog and setting unit custom value thing? I'm not the best at the editor.
EDIT: So I did the catalog thing, I removed the random names section and instead made it into a trigger with 12 different strings in an array. I used the select random integer with the array to get a random name but is there a way to make it so that you can't have the same random name? Say if the number chosen was 9, is there a way to remove the 9th string from the random integer selection?
@CantThinkOfOneSmileyFace: Go
you have to build this yourself. in your case you could have another array of booleans. bool[12]. you pick a random number, set the name, save the custom, set the bool[x] to true. next time you check the bool first if it is true, use another random variable.
my way of doing this is a custom function returning an int with a param int, mycustomFun(int x).
inside this function is a if then else, if bool[x] == true then return myCustomFun(random integer from 1 to 12) otherwise return x
this works if you need "some" different integers, if you need to use all 12 you also have to shrink the min and max of the random int if taken already.
alternativly you could just take the next free int of the array, myCustomFun2 (int x). if bool[x] == true && x < 12 then return myCustomFun2 (x +1), if bool[x] == false then return x, if x>= 12 then return myCustomFun2 (1)