Extract items: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
Created page with '{{ #vardefine:name|extract_items}}{{ #vardefine:return_type|int [item]}}{{ #vardefine:aggregate|yes}}{{ FunctionPage| name={{#var:name}}| function_category=String Handling Routi…'
 
imported>Heeheehee
m Added restriction (bug notice).
Line 17: Line 17:
}}|
}}|


function_description=This function searches your supplied {{pspan|text}}, searching for either the phrase "You acquire an item: <nowiki><b>THING</b></nowiki>" or "You acquire <nowiki><b># THINGS</b></nowiki>" and returns a map keyed by items ("THING"), with the quantity of each item as the value. Note that the phrases to search are both case-sensitive (it will not match on "You Acquire 10 broken skulls"). This function can be used for parsing item acquisition from combat and kmails (though only the system messages are recommended from the latter, as the message text of a kmail can be set in a non-standard way).|
function_description=This function searches your supplied {{pspan|text}}, searching for either the phrase "You acquire an item: <nowiki><b>THING</b></nowiki>" or "You acquire <nowiki><b># THINGS</b></nowiki>" and returns a map keyed by items ("THING"), with the quantity of each item as the value. Note that the phrases to search are both case-sensitive (it will not match on "You Acquire 10 broken skulls"). This function can be used for parsing item acquisition from combat and kmails (though only the system messages are recommended from the latter, as the message text of a kmail can be set in a non-standard way).</p><p>Note that this function cannot identify items affected by the sword behind inappropriate prepositions (acquired via pickpocketing, for instance). This has been reported as a bug and is subject to change.|


needscode=yes|
needscode=yes|

Revision as of 00:40, 18 March 2010

needs(code_samples);

Function Syntax

int [item] extract_items(string text )

  • text is the string to search

This function searches your supplied text, searching for either the phrase "You acquire an item: <b>THING</b>" or "You acquire <b># THINGS</b>" and returns a map keyed by items ("THING"), with the quantity of each item as the value. Note that the phrases to search are both case-sensitive (it will not match on "You Acquire 10 broken skulls"). This function can be used for parsing item acquisition from combat and kmails (though only the system messages are recommended from the latter, as the message text of a kmail can be set in a non-standard way).

Note that this function cannot identify items affected by the sword behind inappropriate prepositions (acquired via pickpocketing, for instance). This has been reported as a bug and is subject to change.

See Also

extract_meat()

Special

This function returns an empty map if it does not find any matches.


Attention KoLmafia Experts!

We need your help; some details of this function's operation are unknown or unclear.

The following specific question has been raised:

  • Are there any additional matches that will be found by this function?