HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Retrieving Unit-Type Name?

01-08-2006, 04:51 AM#1
PCPharaoh
How can I retrieve the name of a type of unit? The only functions I can find return the name of a specific unit. I could make a workaround with creating a temp unit of the type I want, but I really don't want to do that.

Note - I'm not trying to retrieve the A001 code, I'm trying to retrieve 'Footman'.
01-08-2006, 05:52 AM#2
Immoralis
I may not completly undestand your question but is this what you are looking for?

Trigger:
Game - Display to (All players) the text: (Name of Any_Unit)
Any_Unit = unit variable
01-08-2006, 05:58 AM#3
PCPharaoh
I know about that function. What I'm trying to do is:

Game - Display to (All Players) the text: (Name of unit-type(MyUnitTypeVariable))

The problem is I can't find a function that says that.
01-08-2006, 06:09 AM#4
noctune
You could try getting a function that returns unit type and then convert it to a string.
Not sure that's possible though.
01-08-2006, 06:10 AM#5
Immoralis
Trigger:
Actions
Set MyUT = Footman
Game - Display to (All players) the text: (String(MyUT))
There you go.
MyUT=unit type variable
01-08-2006, 06:18 AM#6
PCPharaoh
Quote:
Originally Posted by noctune
You could try getting a function that returns unit type and then convert it to a string.
Not sure that's possible though.

No idea what you're talking about, elaborate please.

Immoralis: What are you using to convert to string? 'Conversion - Convert Unit-Type to String'? That was what I originally was using, but for some reason it returned "custom_A001" or something along those lines. What I want to be returned is "Footman", etc.
01-08-2006, 06:20 AM#7
Immoralis
hmm havent test that out accually ill get back to it

edit: just test it works, it says footman,
Attached Images
File type: pngimg1.PNG (214.1 KB)
01-08-2006, 07:15 AM#8
Jacek
Because you are using normal foot. Try using custom unit and it will be custom_a024
01-08-2006, 07:29 AM#9
Immoralis
You guys keep making it more complex.
Trigger:
Melee Initialization
Collapse Events
Map initialization
Conditions
Collapse Actions
Set My_UT = fatman
Collapse Unit Group - Pick every unit in (Random 1 units from (Units of type My_UT)) and do (Actions)
Collapse Loop - Actions
Game - Display to (All players) the text: (Name of (Picked unit))

same as the last trigger, cept fatman is a footman called fatman...
the accual unit has to be on the map tho, cuz you have to pick it to find the name and it works
01-08-2006, 07:32 AM#10
Jacek
Isn't ForGroupBJ leaking?
01-08-2006, 08:02 AM#11
Immoralis
Quote:
Originally Posted by Jacek
Isn't ForGroupBJ leaking?
i dont care, its 3 am and im going to sleep, good day!
01-08-2006, 08:37 AM#12
Jacek
what are u talking about? it is 10:37 AM :P
01-08-2006, 10:38 AM#13
Extrarius
The problem is that the GUI system uses the function 'UnitId2String' (which, as far as I can tell, exists for no purpose), while the function you need is 'GetObjectName' (which takes an id # just like UnitId2String, but gets the actual name field for anything that has one).
01-08-2006, 10:57 AM#14
Vexorian
What Extrarius said:

Trigger:
Melee Initialization
Collapse Events
Map initialization
Conditions
Collapse Actions
Set typevar = Footman
Custom script: set udg_stringvar= GetObjectName(udg_typevar)
Game - Display to (All players) the text: stringvar

Much better in JASS:

Collapse JASS:
     GetObjectName('hfoo')
01-08-2006, 12:07 PM#15
Jacek
Well, Extrarius deserves rep, I needed that func