• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Basics - HandleId

Status
Not open for further replies.

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
Part 1

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
 

Attachments

  • [Crash Course] Basics - HandleId.w3m
    23.5 KB · Views: 72
Status
Not open for further replies.
Top