• 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.

Return an item's description

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

What is the native that returns the string which is a given item's (or unit's) description (the text that is produced when the cursor is above an item, e.g. "Restores 500 hit points")?

JASS:
native function GetItemDescription takes item whichItem returns string
  //returns a string that is the item's text description
endfunction
 
There is technically a way to do it, sort of, by reading the wts file. It just isn't a guaranteed method (and I don't know if the optimizer will alter the results).

Tooltips, names, etc. are statically stored within the map's wts file, as are trigger strings that are used in GUI. You can refer to those trigger strings with TRIGSTR_####, but you can also read the other contents of the wts file through this method. See:
http://www.hiveworkshop.com/forums/1632693-post8.html
(you can extend it beyond 1000, since your map may have more strings than that. Also, the GetLocalizedString() isn't necessary. I think that is mostly used for strings that vary based on language.)

So if you have a keyword, you could perform a linear search to find the description. But I don't quite remember the exact behavior of the string table. I don't remember if it is all ordered, or if it is ordered based on the last edited string, or what. You'll have to experiment. A linear search is obviously very performance-heavy (since it'll be O(n) worst-case), but there are ways to improve it with hashtables (i.e. hash an item to the ### of its trigger string).

As for default items, you can't find them without databasing (store its description under the rawcode of the item).

idk, this may not be that helpful. Someone should really write a script that'll generate a database for a field of your choice. There is one, but I haven't tested it. Perhaps you could give it a go.
 
Status
Not open for further replies.
Top