• 🏆 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!

Hashtable values not saving, have I missed something?

Status
Not open for further replies.
Level 6
Joined
Jan 8, 2009
Messages
140
This is my first attempt at hashtables so bare with me here...

I've run into this problem where I have this sort of variable setup, (var1, var2 etc) and I feel like hashtables are the solution. The issue i'm having is that no values are ever saved to the hashtable.

  • hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- HASHTABLES --------
      • Hashtable - Create a hashtable
      • Set hashPrices = (Last created hashtable)
  • Set day = (day + 1)
  • For each (Integer loop) from 1 to Count, do (Actions)
    • Loop - Actions
      • -------- old --------
      • Set PriceDay7[loop] = PriceDay6[loop]
      • Set PriceDay6[loop] = PriceDay5[loop]
      • Set PriceDay5[loop] = PriceDay4[loop]
      • Set PriceDay4[loop] = PriceDay3[loop]
      • Set PriceDay3[loop] = PriceDay2[loop]
      • Set PriceDay2[loop] = PriceDay1[loop]
      • Set PriceDay1[loop] = PriceLast[loop]
      • Set PriceLast[loop] = Price[loop]
      • -------- hash --------
      • Hashtable - Save Price[loop] as day of loop in hashPrices
      • Game - Display to (All players) the text: (Load day of loop from hashPrices)
This doesn't display anything, even a blank line
  • Game - Display to (All players) the text: (Load day of loop from hashPrices)
thanks.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
shouldn't you use
  • Game - Display to (All players) the text: (Load day of Price[loop] from hashPrices)
instead of
  • Game - Display to (All players) the text: (Load day of loop from hashPrices)
 
Level 6
Joined
Jan 8, 2009
Messages
140
Do you properly convert the integer to a string?

You cant load "day of loop" as a string if you saved it as an integer, you must first convert it to a string.

this was exactly the problem, they were real values and i was trying to access them as strings and integers. thanks a lot!
 
Level 3
Joined
Dec 31, 2003
Messages
42
Aren't you missing the [loop] as well though? As is, it only overwrites the same hashtable value
 
Level 6
Joined
Jan 8, 2009
Messages
140
Aren't you missing the [loop] as well though? As is, it only overwrites the same hashtable value

I don't think so, i'm trying to save the price value on every day that passes for each entity (loop). It works like that now that I fixed up the conversions, i'm not sure what you mean.
 
Level 3
Joined
Dec 31, 2003
Messages
42
I don't think so, i'm trying to save the price value on every day that passes for each entity (loop). It works like that now that I fixed up the conversions, i'm not sure what you mean.

Never mind... I didn't look at the code that carefully
 
Status
Not open for further replies.
Top