Use milk leads to Carbonated Soy Milk?

barnaby36

New member
When I'm not remembering how bad of an idea it is, I ask the CLI to "use milk", which leads to it purchasing the Carbonated Soy Milk instead of Milk of Magnesium. Could a special case be built in to tell users to disambiguate, or is there a wonderful reason I'm missing as to why Carbonated Soy Milk is such a sought-after MP restorer?
 

Fluxxdog

Active member
Hmmm... KoL items that have "milk" in their name:

carbonated soy milk
milk of magnesium
glass of baboon milk (food)
glass of goat's milk (food)
Blue Milk Club Card (non-usable quest item)
Tiger-lily's milk (food)

My guess is you gave it an ambiguous item, it with with the first logical choice. You should learn to type "use milk of" when you want to use it, though an easier way to avoid it is to use the button in the Item Manger under food.
 

Bale

Minion
That's why I always "use mom", your mom. That works just fine.

or is there a wonderful reason I'm missing as to why Carbonated Soy Milk is such a sought-after MP restorer?

Restorers are always given disambiguation priority over other items. I don't remember why. If there are no restorers amongst the items that fit the command, then it will abort and ask for clarification.
 

slyz

Developer
In UseItemCommand.java (and all the other CLI commands that have item names as parameters), ItemFinder.getMatchingItemList() is used to parse the item list. This in turns uses ItemFinder.getFirstMatchingItem() on each substring in the list of parameters you entered in the gCLI.

ItemFinder.getFirstMatchingItem() gets a list of item names that contain the substring with ItemFinder.getMatchingNames( String searchString ) and then calls ItemFinder.getFirstMatchingItemName( List nameList, String searchString, int filterType ).

What I don't understand is that ItemFinder.getFirstMatchingItemName() doesn't use searchString at all, it just removes entries from nameList if there are multiple matches such that one is a substring of the others. I guess the actual disambiguation happens in ItemFinder.getMatchingNames), but I don't really understand where.

From glancing at the revision log, I think that fuzzy matching in CLI commands is an intended KoLMafia feature - the fact that 'milk' will match a specific item instead of leading to an error asking the user to disambiguate is done on purpose. Changing this would probably require quite an overhaul.

ETA: the cases where Mafia asks for disambiguation (Candy hearts, snowcones and cupcakes apparently) are hardcoded in ItemFinder.getFirstMatchingItemName().

EDIT2: I forgot to look at ItemFinder.filterNameList() - it looks like Bale nailed it: restorers take precedence for disambiguation.

EDIT3: there still are strange things happening though:
Code:
> use glass

Searching for "clan looking glass"...
Stopped purchasing Clan looking glass @ 20,750,000.
Using cached search results for Clan looking glass...
Stopped purchasing Clan looking glass @ 20,750,000.
You need 1 more Clan looking glass to continue.
 
Last edited:
Top