Cannot convert integer to unit

Status
Not open for further replies.
Level 7
Joined
Jun 1, 2009
Messages
125
Hi!
I'm trying to use a custom script for the hashtable from Uncle's example:


But when I try

  • Custom script: set udg_AI_Id = GetUnitTypeId(udg_TempUnitType)
it causes an error: "Cannot convert integer to unit in parameter whichUnit in call to GetUnitTypeId"

It seems to be fine with udg_TempUnit. Ofc. I can create a TempUnit of each Unit Type. But maybe it is possible to convert the UnitType directly?

Thanks for help!
 
Last edited:
I think TempUnitType is the actual result you want to get; you don't need to get the type id of an integer so to speak.

Moreover, it is already possible to get the type id of the unit. You've achieved this (albeit unknowingly) by replacing TempUnitType with TempUnit. GetUnitTypeId should return the result you're looking for.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Hi!
I'm trying to use a custom script for the hashtable from Uncle's example:


But when I try

  • Custom script: set udg_AI_Id = GetUnitTypeId(udg_TempUnitType)
it causes an error: "Cannot convert integer to unit in parameter whichUnit in call to GetUnitTypeId"

It seems to be fine with udg_TempUnit. Ofc. I can create a TempUnit of each Unit Type. But maybe it is possible to convert the UnitType directly?

Thanks for help!
Sorry about that, I updated my post to use the proper method. Like MyPad said, GetUnitTypeId() takes a unit and returns it's unit-type id.

This is what I meant for you to do:
  • Custom script: set udg_SomeInteger = udg_SomeUnitType
This will set SomeInteger to the id of whatever unit-type you've set SomeUnitType to.

Then you use that Integer as the Parent key in your Hashtable as a way to save data to that specific unit-type. The Child keys would hold the actual data.

So now whenever we want to get information about a unit-type but all we have is a unit, we can use the GetUnitTypeId() function to do so:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: set udg_SomeInteger = GetUnitTypeId(GetTriggerUnit())
      • /// Now plug SomeInteger into the Hashtable as the Parent key and you'll have access to any data that you've saved at the Child keys
Note: GetTriggerUnit() is the same thing as (Triggering unit). You can also use a Unit variable here to make the syntax easier to work with.
  • Set Variable udg_SomeUnit = (Triggering unit)
  • Custom script: set udg_SomeInteger = GetUnitTypeId(udg_SomeUnit)
 
Last edited:
Status
Not open for further replies.
Top