$item is a compile-time lookup. to_item() is a run-time lookup - although in the case of a constant string argument, we could optimize it into the compile-time constant.
Originally Posted by zarqon
Seems to me that if you know the item id, you could just do to_item( 2325).
> ash to_item( "Staff of Ed" ).to_int()
> ash to_item( 2325 ).to_int()
When loading files, presumably we are converting strings into "item" objects.
And when writing files, we'd need to know that Staff of Ed and ancient amulet are both ambiguous and include the item id.
This is all connected with DataTypes.parseItemValue() which has the following code:
ItemDatabase.getItemId resolves this via:
// Otherwise, let ItemDatabase parse the name using fuzzy matching.
int itemId = ItemDatabase.getItemId( name );
Which is to say, a single map lookup. There is no knowledge of which items have ambiguous names. Although, I imagine we could determine that when loading the data file.
ItemDatabase.itemIdByName.get( name )