• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Whats Wrong?

Status
Not open for further replies.
Let us look at this piece of art:
JASS:
native  SaveInteger takes hashtable table, integer parentKey, integer childKey, integer value returns nothing

hashtable table     - the table you are storing data in
integer   parentKey - the 1D parent key value
integer   childKey  - the 2D child key value
integer   value     - the actual data stored
^ this can change depending on what you want to store (e.g handle, real, string)

Now:
JASS:
call SaveInteger(hash, 0, String2OrderIdBJ("humanbarracks"), 0)

hashtable table     - hash
integer   parentKey - 0
integer   childKey  - String2OrderIdBJ("humanbarracks")
integer   value     - 0

call SaveInteger(hash, 1, BType[0], 0)

hashtable table     - hash
integer   parentKey - 0
integer   childKey  - BType[0]
integer   value     - 0
You see now? U messed up the order, thus you dont save orderid - instead you use it as child key.

Edit: You want to load 0?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
but beware, returning 0 is not the best thing, because if you load from keys that were not assigned anything into, you will automatically load default value, which is 0 for integer, so you are better off saving something like 1 or something if you want the data/it is of any importance
 
Status
Not open for further replies.
Top