Zalinian
New Member
- Reaction score
- 0
Sorry I couldn't be more descriptive in the title, but I wasn't sure how to word it.
edit: thanks for changing the title to a more appropriate wording.
Anyway here's the issue:
I originally had multiple arrays used to store units/heroes, the file path for their custom icons(used for my multiboard), bounty from killing them, and several other bits of data. I wanted to change this into a structure, since it will look more organized and make adding new units/heroes into the system, or even entire new branches of data easier. All of the data is set in the code and doesn't change.
For Example:
Instead of
unit array unit_list[2]
integer array unit_bounty[2]
set unit_list[1] = Peasant
set unit_list[2] = Footman
set unit_bounty[1] = 10
set unit_bounty[2] = 15
I would set up a struct:
Then in a function triggered on map initialization:
I just need a way to look up the correct struct to obtain the data once I have the unit in question.
Is there a way to return data from a struct using its name in a variable? I can get the name of struct, but I can't get to the data if that makes any sense.
IE: A unit dies. {say the unit is a peon}
set name = GetUnitName(GetDyingUnit()) {this would return the string "Peon"}
The data I need I would have stored in Peon_Data. Is there a way to make that jump?
If anyone has any better ideas for storing my data, I'm open to suggestions.
edit: thanks for changing the title to a more appropriate wording.
Anyway here's the issue:
I originally had multiple arrays used to store units/heroes, the file path for their custom icons(used for my multiboard), bounty from killing them, and several other bits of data. I wanted to change this into a structure, since it will look more organized and make adding new units/heroes into the system, or even entire new branches of data easier. All of the data is set in the code and doesn't change.
For Example:
Instead of
unit array unit_list[2]
integer array unit_bounty[2]
set unit_list[1] = Peasant
set unit_list[2] = Footman
set unit_bounty[1] = 10
set unit_bounty[2] = 15
I would set up a struct:
JASS:
Then in a function triggered on map initialization:
JASS:
I just need a way to look up the correct struct to obtain the data once I have the unit in question.
Is there a way to return data from a struct using its name in a variable? I can get the name of struct, but I can't get to the data if that makes any sense.
IE: A unit dies. {say the unit is a peon}
set name = GetUnitName(GetDyingUnit()) {this would return the string "Peon"}
The data I need I would have stored in Peon_Data. Is there a way to make that jump?
If anyone has any better ideas for storing my data, I'm open to suggestions.