| 06-22-2005, 05:30 PM | #1 |
The search function is giving me a hard time now that the site is being worked on, so I guess I'll just post my question. What I am trying to do is figure out the Id of a unit type or an item type. I know the hard way of doing it, by preplacing the unit and then checking it's unit type Id, but surely there's an easier way? A way to see the Id in the object editor (display as raw data doesn't help it just shows the 4 letter codes). If there's no way to see this number, then I guess I can get it from the 4 letter code? The function UnitId() seems to do that, it takes a string and returns an integer, but I'm still not sure if the string is meant to be the 4 letter code... and I can't find a similar function for items... |
| 06-22-2005, 05:36 PM | #2 |
The four letters code is the id As in Typing 'Aloc' is another way of typing a number Groups of 4 ascii cars between ' ' are considered integers by JASS and the resulting integer is the number you would get if you read those 4 characters as a 4 bytes number. |
| 06-22-2005, 07:41 PM | #3 |
Thanks Vex. another totaly unrelated question, but I just don't want to make a new thread... Code:
local group ug
set ug = GetUnitsInRectMatching(GetPlayableMapRect(), Condition( function IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) )) I tried my best to logically construct this line based on what the trigger editor throws out when I tell it to convert a GUI trigger to custom text. Is it that functions I call as a condition aren't allowed to accept arguments or something else lame like that? |
| 06-22-2005, 08:04 PM | #4 |
The interface of the Condition function needs to be exactly "takes nothing returns boolean", so in your case do it this way: Code:
function MyCondition takes nothing returns boolean return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) endfunction .... set ug = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function MyCondition)) |
| 06-28-2005, 09:57 AM | #5 | |
Quote:
but, how do you do if you need to use a local in the main function and then check the local in the Condition(...) ? |
| 06-28-2005, 10:29 AM | #6 |
game cache ;) |
| 07-01-2005, 12:34 AM | #7 | |
Quote:
yes, or teporarily copy the local to a global variable and in the Condition-function assign the global to a local again. |
| 07-04-2005, 05:13 PM | #8 |
Or use an if/then/else rather than a condition. |
| 07-05-2005, 08:35 AM | #9 | |
Quote:
You can't use an if/then/else as a filter. |
| 07-05-2005, 09:44 AM | #10 | |
Quote:
I know, I was just saying in many cases were you might use a condition an if/then/else would be easier. This just does not happen to be one of those cases. |
