• 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 - Hashtable - 1

Status
Not open for further replies.

NEL

NEL

Level 6
Joined
Mar 6, 2017
Messages
113
Part 1

Create a unit and save it into hashatble. ParentKey = 123456789 ; ChildKey = 0

vJASS:
//! zinc
library Hashtable1 {
    private {
        hashtable hash = InitHashtable();
   
        function onInit() {
            SaveUnitHandle( hash, 123456789, 0, 
                CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), 'hfoo', 0, 0, 0 )
            );
        }
    }
}//! endzinc





Part 2

Print the name of the saved unit using the loaded value from hashtable. (you can do it in same function)
vJASS:
//! zinc
library Hashtable1 {
    private {
        hashtable hash = InitHashtable();
   
        function onInit() {
            SaveUnitHandle( hash, 123456789, 0, 
                CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), 'hfoo', 0, 0, 0 )
            );
           
            DisplayTextToPlayer( GetLocalPlayer(), 0, 0, 
                GetUnitName( LoadUnitHandle( hash, 123456789, 0 ) )
            );
        }
    }
}
//! endzinc
 

Attachments

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