ConvertUnitStringField

Parameters
i integer
comment
note

Many fields don't work at all with BlzGetUnitStringField or BlzSetUnitStringField.

  • Icon - Game Interface uico doesn't
  • Icon - Score Screen ussi doesn't
  • Art - Model File umdl doesn't
  • Art - Special uspa doesn't
  • Combat - Attack 1 - Projectile Art ua1m doesn't
  • Text - Name UNIT_SF_NAME aka 'unam' works
  • Text - Proper Names UNIT_SF_PROPER_NAMES aka 'upro' works
  • Tooltip Awaken uawt doesn't
  • Tooltip Extended utub doesn't
  • Tooltip Revive utpr doesn't

Test code (Lua, 2.0.2):

-- Create unit, try different string fields on it.
-- Output format: rawcode,stringLength, setResult=boolean,string
h5 = CreateUnit(Player(0), FourCC("Hamg"), -30, 0, 90)
t = {"uico", "ussi", "umdl", "uspa", "ua1m", "unam", "upro", "uawt", "utip", "utub", "utpr"}
for k,rawcode in pairs(t) do
    local sf = ConvertUnitStringField(FourCC(rawcode))
    local getPre = BlzGetUnitStringField(h5, sf)
    local setText = "set-" .. rawcode
    local setResult = BlzSetUnitStringField(h5, sf, setText)
    local getPost = BlzGetUnitStringField(h5, sf)
    local fmt = "\x25s=\x25d; setResult=\x25s,\x25s"
    print(fmt:format(rawcode, #getPre, tostring(setResult), getPost))
end
pure
This function is pure. For the same values passed to it, it will always return the same value.
patch

1.31.0.11889

Source
common.j
return type
unitstringfield
Source code
constant native ConvertUnitStringField                  takes integer i returns unitstringfield