Part 1
Create 5 footmen units and print their handleid to screen.
Part 2
Declare 2 local variables and let them point to the same unit, then print both of their handleids.
Create 5 footmen units and print their handleid to screen.
vJASS:
//! zinc
library HandleId {
private {
integer Counter[];
function onInit() {
integer Count = 0;
while( Count < 5 ) {
DisplayTextToPlayer( GetLocalPlayer(), 0, 0, I2S(
GetHandleId( CreateUnit( Player(0), 'hfoo', 0, 0, 0 ) )
));
Count = Count + 1;
}
}
}
}
//! endzinc
Part 2
Declare 2 local variables and let them point to the same unit, then print both of their handleids.
vJASS:
//! zinc
library HandleId {
private {
integer Counter[];
function onInit() {
integer Count = 0;
unit a;
unit b;
while( Count < 5 ) {
a = CreateUnit( Player(0), 'hfoo', 0, 0, 0 );
b = a;
DisplayTextToPlayer( GetLocalPlayer(), 0, 0,
"a's HandleId: " + I2S( GetHandleId(a) ) + "\n" +
"b's HandleId: " + I2S( GetHandleId(b) )
);
Count = Count + 1;
}
a = null;
b = null;
}
}
}
//! endzinc