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

Problem with Hashtable

Status
Not open for further replies.
I currently want to take a value from an hashtable and put it somewhere else in my hashtable.

So, yeah, you would say that's easy just use Save <VariableType> in Hashtable. But i want to move my value regardless of it's type, and this value could be of any type.

A solution would be to test if the value is from X type and if yes, then move it using action Save X in hashtable. But well, this would just suck and might even lag since this would be put in a loop that might repeat itself thousand times in a normal game situation and this every 0.03 seconds.

I heard that we can save several datas at the same place in an hashtable aslong as they are from different types. And so, if there's a way of moving the value if it's an handle regardless of it being an unit's handle, an object handle or whatever's handle, it would solve the problem. So, yeah kinda a Save Handle in Hashtable instead of the Save Something's Handle in Hashtable.

So, two questions :

- Is it possible to put two different values in the same place on an hashtable if they're not from the same type, i.e. save both an Integer and a String at the same place in the hashtable ?
- If yes, is there a function to save an handle (from any type of handle) in an hashtable ?
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
1) no u cant save two values at one place in a hashtable the old one will be overwritten.
2) if u dont know the handle type u will have to do a check to see what it is.

if u are going to save a lot of things in hashtables of different types try changing all there types to integers.

u can save every type allowed in a hashtable but not in the same place. like u can save an item to item handle of 1 then save a unit to unit handle of 2. but if u save unit to 1 u risk overwriting. it should never overwrite using the handles but y take the chance.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hashtables only saves numbers (handles). You can then retrieve the number and turn it again into a unit, destructable, region, timer, or whatever it was.

So... no,you can't save 2 values of different type at the same place because, in the hashtable, they're both whole numbers.
 
1) Yes you can,though not for child handles. You can only have the same positions for Integer, Real, String, Boolean and Child Handles. For ex. Saving a unit with the key 0,0 and saving a lightning with the key 0,0 overwrites the saved unit.
2) Yes you can. But that needs typecasting(if you want to save all handles with a single func such as SaveHandle). I have a resource(Element : deleted) which uses typecasting to save Damage Types and Attack Types. You can also check this out : http://www.hiveworkshop.com/forums/graveyard-418/snippet-needs-opinion-misctable-232992/
 
Status
Not open for further replies.
Top