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