[Solved] Set integer to ID of unit type?

Level 9
Joined
Jun 13, 2010
Messages
365
My rawcode for my unit type is h004:hfoo.
I want the integer representation of it like when i use this, i get "174798532":
  • Custom script: set udg_TFT_EnteringInteger1 = GetUnitTypeId(udg_TFT_EnteringUnit)
If I use this, it doesn't give me an integer I can use:
  • Custom script: set udg_TempInteger = GetUnitTypeId(udg_TempUnit)
Is it possible to get this type of integer "174798532" from referring to a unit type instead of a unit through a Unit Variable in game?
 
Level 29
Joined
Sep 26, 2009
Messages
2,594
your raw code is h004. The "hfoo" is just the rawcode of unit your custom unit is based off.
Raw code is already an integer. In WE editor, unit-type variable is just an extension of an integer. So you can do something like this:
  • -------- one way --------
  • Set VariableSet unitType = Footman
  • Custom script: set udg_int = udg_unitType
  • Game - Display to (All players) the text: (String(int))
  • -------- another way --------
  • Custom script: set udg_int = 'hfoo'
  • Game - Display to (All players) the text: (String(int))
 
Level 9
Joined
Jun 13, 2010
Messages
365
your raw code is h004. The "hfoo" is just the rawcode of unit your custom unit is based off.
Raw code is already an integer. In WE editor, unit-type variable is just an extension of an integer. So you can do something like this:
  • -------- one way --------
  • Set VariableSet unitType = Footman
  • Custom script: set udg_int = udg_unitType
  • Game - Display to (All players) the text: (String(int))
  • -------- another way --------
  • Custom script: set udg_int = 'hfoo'
  • Game - Display to (All players) the text: (String(int))
If I do the last one and try to do a message nothing shows up.

I will try to do the first way you mentioned and see if it works.
 
Level 29
Joined
Sep 26, 2009
Messages
2,594
"udg_int" is an integer variable. Make sure the hfoo is encapsulated by single quotes

Edit: the single quote thing is for jass only. If you are using lua, you want to call FourCC function instead.
JASS:
// in jass
set udg_int = 'hfoo'

//in lua
udg_int = FourCC('hfoo')
 
Level 9
Joined
Jun 13, 2010
Messages
365
"udg_int" is an integer variable. Make sure the hfoo is encapsulated by single quotes

Edit: the single quote thing is for jass only. If you are using lua, you want to call FourCC function instead.
JASS:
// in jass
set udg_int = 'hfoo'

//in lua
udg_int = FourCC('hfoo')
If i used

  • set udg_int = 'hfoo'
I got no value for a game message to display, so didn't think it worked.
 
Level 29
Joined
Sep 26, 2009
Messages
2,594
writing integer as four characters encapsulated by single quotes is in jass for as long as I can remember, it's not a new thing.
In fresh map, this works just fine:
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: set udg_int = 'hfoo'
      • Game - Display to (All players) the text: (String(int))
In game it prints:
1744553018363.png
 
Level 9
Joined
Jun 13, 2010
Messages
365
writing integer as four characters encapsulated by single quotes is in jass for as long as I can remember, it's not a new thing.
In fresh map, this works just fine:
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: set udg_int = 'hfoo'
      • Game - Display to (All players) the text: (String(int))
In game it prints:
View attachment 527541
You were right, again. Thanks. :)
 
Top