• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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: 69
Status
Not open for further replies.
Top