Item Management: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
→‎Acquiring & Using Items: Add clear_booze_helper(), clear_food_helper()
 
(56 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{TOCright}}
==Informational==
{{Flink|int|my_meat|desc=Returns the amount of meat you have on hand.}}
{{Flink|int|my_meat|desc=Returns the amount of meat you have on hand.}}
{{Flink|int|my_closet_meat|desc=Returns the amount of meat you have in your Colossal Closet.}}
{{Flink|int|my_closet_meat|desc=Returns the amount of meat you have in your Colossal Closet.}}
{{Flink|int|my_storage_meat|desc=Returns the amount of meat you have in Hagnk's Ancestral Mini-Storage.}}
{{Flink|int|pulls_remaining|desc=Returns the number of pulls you can make from storage, or 0 if not applicable.}}
{{Flink|int|pulls_remaining|desc=Returns the number of pulls you can make from storage, or 0 if not applicable.}}
{{Flink|boolean|have_chef|desc=Returns true if you have a chef-boxen at your campground.}}
{{Flink|boolean|have_chef|desc=Returns true if you have a chef-boxen at your campground.}}
{{Flink|boolean|have_bartender|desc=Returns true if you have a bartender-boxen at your campground.}}
{{Flink|boolean|have_bartender|desc=Returns true if you have a bartender-boxen at your campground.}}
{{Flink|int [item]|get_campground|desc=Returns a map of your campground items.}}
{{Flink|int [item]|get_campground|desc=Returns a map of your campground items.}}
{{Flink|int [item]|get_clan_lounge|desc=Returns a map of your Clan VIP Lounge items.}}
{{Flink|item|get_dwelling|desc=Returns the item corresponding with your dwelling.}}
{{Flink|boolean|have_mushroom_plot|desc=Returns true if and only if you've purchased a mushroom plot this run.}}
{{Flink|boolean|have_mushroom_plot|desc=Returns true if and only if you've purchased a mushroom plot this run.}}
{{Flink|int|stills_available|desc=Returns the number of Nash Crosby's Still uses left for the day (0 if not accessible).}}
{{Flink|int|stills_available|desc=Returns the number of Nash Crosby's Still uses left for the day (0 if not accessible).}}
{{Flink|string|item_type|item|desc=Returns the type of item specified.}}
{{Flink|int|item_amount|item}}
{{Flink|int|item_amount|item}}
{{Flink|int|closet_amount|item}}
{{Flink|int|closet_amount|item}}
Line 12: Line 18:
{{Flink|int|equipped_amount|item}}
{{Flink|int|equipped_amount|item}}
{{Flink|int|shop_amount|item}}
{{Flink|int|shop_amount|item}}
{{Flink|int [item]|get_shop|desc=Returns entire contents of shop and quantity of each item}}
{{Flink|int|stash_amount|item|}}
{{Flink|int|stash_amount|item|}}
{{Flink|int|storage_amount|item|desc=These 7 functions return the total number available of a given item in the respective section of your inventory.}}
{{Flink|int|storage_amount|item|desc=These 7 functions return the total number available of a given item in the respective section of your inventory.}}
{{Flink|int|available_amount|item|desc=Returns the total number available of a given item in all inventory sections accessible to your character based on current restrictions.}}
{{Flink|int|available_amount|item|desc=Returns the total number available of a given item in all inventory sections accessible to your character based on current restrictions.}}
{{Flink|boolean|take_storage|int|item}}
{{Flink|int|creatable_amount|item|desc=Returns the amount of the item that you are capable of creating given your current inventory and skills.}}
{{Flink|boolean|take_closet|int|item}}
{{Flink|int [item]|get_ingredients|item|desc=Returns a map where each key is one of the required ingredients, with the integer value the number required. If you don't have the skills needed to make the item, it will return an empty map.}}
{{Flink|boolean|take_stash|int|item}}
{{Flink|string|craft_type|item|desc=Returns a string identifying how an item is crafted and any other requirements for creating it.}}
{{Flink|boolean|take_display|int|item}}
{{Flink|int [item]|get_inventory|desc=Returns a map where each key is an item in your inventory, with the integer value its quantity.}}
{{Flink|boolean|put_coset|int|item}}
{{Flink|int [item]|get_related|item|string|desc=Returns associated items in a zap or fold group (see page for details).}}
{{Flink|boolean|put_stash|int|item}}
[[File:Item category.png|frame|You can categorize items in KoL using [[is tradeable|is_tradeable()]], [[is giftable|is_giftable()]], and [[is displayable|is_displayable()]].]]
{{Flink|boolean|put_display|int|item|desc=Attempts to take or put the specified item in the appropriate section of your inventory, and returns its success.}}
{{Flink|boolean|is_tradeable|item|desc=Returns whether the item can be placed in the mall.}}
{{Flink|boolean|take_closet|int|desc=Attempts to move meat from your closet to on-hand and reports success.}}
{{Flink|boolean|is_giftable|item|desc=Returns whether the item can be traded in a gift package.}}
{{Flink|boolean|put_closet|int|desc=Attempts to move meat from on-hand to your closet and reports success.}}
{{Flink|boolean|is_displayable|item|desc=Returns whether the item can be put in a display case (true for all but quest items).}}
{{Flink|boolean|put_shop|int|int|{{opt|int}}|item|desc=Puts items in your store (see page for details).}}
{{Flink|boolean|is_discardable|item|desc=Returns whether the item can be discarded or autosold.}}
{{Flink|boolean|buy|int|item|desc=Attempts to buy the specified item, checking NPC stores first, then mall if available, and reports success.}}
{{Flink|boolean|have_shop|desc=Returns whether you have a mall store.}}
{{Flink|int|buy|int|item|int|desc=Tries to buy the given amount of items at or below your specified price, and returns the number purchased.}}
{{Flink|boolean|have_display|desc=Returns whether you have a display case.}}
'''boolean [[buy()|buy( int quantity, item it )]]''' - tries to buy the specified [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|items]].  First preference is given to NPC stores that you have access to and then, if possible, will buy the cheapest available items from the mall. When passing 0 or a negative number to the buy function, KoLmafia does nothing and automatically returns true.<br />
{{Flink|boolean|is_npc_item|item|desc=Returns whether the item can be bought from an NPC store.}}
'''int [[buy()|buy( int quantity, item it, int price_limit )]]''' - tries to buy the specified number of [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|items]] at or below the specified price.  Returns the number of items successfully purchased, which may be 0 if your limit is too low.
{{Flink|void|refresh_stash|desc=Takes a new look at the contents of your clan stash, as that section of inventory cannot be internally tracked due to access by others.}}
{{Flink|void|refresh_shop|desc=Takes a new look at the contents of your mall store, as that section of inventory cannot be internally tracked due to access by others.}}
{{Flink|int|shop_price|item|desc=Returns the current price for the given item if it is present in your mall store.}}
{{Flink|int|npc_price|item|desc=Returns the current price of the given item if it can currently be bought from an NPC store.}}
{{Flink|int|autosell_price|item|desc=Returns the autosell price of the item (0 for items that cannot be autosold).}}
{{Flink|int|get_power|item|desc=Returns the power of the item (0 for items that don't have a power).}}
{{Flink|string|to_plural|item|desc=Returns the plural of an item as a string.}}
{{Flink|int|meat_drop|{{opt|monster}}|desc=Returns a certain monster's base meat drop.}}
{{Flink|int [item]|item_drops|{{opt|monster}}|desc=Returns an array of a certain monster's base item drops, keying item to drop rate. Has certain limitations detailed on individual page.}}
{{Flink|record [int]|item_drops_array|{{opt|monster}}|desc=Returns an array of records holding information regarding a certain monster's base item drops.}}


'''boolean [[autosell()|autosell( int quantity, item it )]]''' - autosells the given [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|items]].
===Mall Prices===
{{FunctionEmbed|historical_age|desc=yes}}
{{FunctionEmbed|historical_price|desc=yes}}
{{FunctionEmbed|mall_price|desc=yes}}
{{FunctionEmbed|mall_prices|desc=yes}}


'''int [[autosell_price()|autosell_price( item it )]]''' - returns the autosell price of the [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|item]].  Non-discardable items return a negative value.
==Moving Items Around==
 
{{Flink|boolean|empty_closet|desc=Remove every item from the closet in a single server hit.}}
'''boolean [[mall_price()|mall_price( item it )]]''' - returns the current mall price of the given [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|item]].
{{Flink|boolean|put_closet|int|{{opt|item}}}}
 
{{Flink|boolean|put_display|int|item}}
'''boolean [[retrieve_item()|retrieve_item( int quantity, item it )]]''' - uses KoLmafia internal logic to gather the [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|items]] in the least destructive manner. See the &#8220;acquire&#8221; documentation in [http://kolmafia.sourceforge.net/scripting.html the CLI manual] for more details.
{{Flink|boolean|put_stash|int|item}}
 
{{Flink|boolean|take_closet|int|{{opt|item}}}}
'''boolean [[hermit()|hermit( int quantity, item it )]]'''<br />
{{Flink|boolean|take_display|int|item}}
Buys the appropriate number of the given [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|item]] from the Hermit, buying hermit permits and adventuring in the sewer for more worthless items if necessary.
{{Flink|boolean|take_stash|int|item}}
 
{{Flink|boolean|take_storage|int|item|desc=Attempts to take or put the specified item in the appropriate section of your inventory, and returns its success.<br />If the item parameter is omitted from put_closet() or take_closet(), meat is transferred instead of an item.}}
'''boolean [[use()|use( int quantity, item it )]]'''<br />
{{Flink|boolean|put_shop|int|int|{{opt|int}}|item}}
'''boolean [[eat()|eat( int quantity, item it )]]'''<br />
{{Flink|boolean|take_shop|{{opt|int}}|item|desc=Adds or removes items in your store and returns success.}}
'''boolean [[drink()|drink( int quantity, item it )]]'''<br />
Consumes the given [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|items]].  These are not interchangeable - food must be consumed with eat(), booze with drink(), and non-foods with use().
 
'''boolean [[create()|create( int quantity, item it )]]''' - attempts to create the specified [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|items]].  Depending on your in-game settings and conditions, this may involve buying ingredients for the items or servants to create the items for you.
 
'''int [[creatable_amount()|creatable_amount( item it )]]''' - returns the amount of the [[%28ASHRM%29_Datatype_Constants#.24item.5Bconstant.5D|item]] that you are capable of creating with your current inventory and skills.


'''int [item] [[get_ingredients()|get_ingredients( item it )]]''' - returns a map where each item key is a known ingredient and each int value is the number of that ingredient required. If you do not have the relevant skill to create the item from the ingredients, returns an empty map.
==Acquiring & Using Items==
{{Flink|boolean|autosell|int|item|desc=Attempts to autosell the given items and reports success.}}
{{Flink|boolean|buy|{{opt|coinmaster}}|int|item}}
{{Flink|int|buy|int|item|int|desc=Tries to purchase the specified items.}}
{{Flink|boolean|buy_using_storage|int|item}}
{{Flink|int|buy_using_storage|int|item|int|desc=Tries to purchase the specified items using meat in Hangks.}}
{{FunctionEmbed|clear_booze_helper|desc=yes}}
{{FunctionEmbed|clear_food_helper|desc=yes}}
{{Flink|boolean|create|int|item|desc=Attempts to create the specified items, following your KoLmafia settings regarding purchases to gather ingredients & require boxen.}}
{{FunctionEmbed|drink|desc=yes}}
{{FunctionEmbed|eat|desc=yes}}
{{Flink|boolean|eatsilent|int|item|desc=Attempts to eat items as specified.}}
{{Flink|boolean|chew|int|item|desc=Attempts to chew spleen items as specified and reports success.}}
{{Flink|boolean|hermit|int|item|desc=Trades worthless items (buying and using chewing gum if needed) to the hermit for specified items (see page for details).}}
{{Flink|boolean|use|int|item|desc=Attempts to use items as specified and reports success.}}
{{FunctionEmbed|overdrink|format=signature|desc=yes}}
{{Flink|boolean|retrieve_item|int|item|desc=Uses KoLmafia internal logic to gather items (see page for details).}}
{{Flink|int|craft|string|int|item|item|desc=Raw crafting that obeys KoLmafia settings (see page for details).}}
{{Flink|string|last_item_message|desc=Returns message that KoL reports in the event of error.}}


'''int [item] [[get_related|get_related( item it , string type )]]''' - type can be either "zap" or "fold". "zap" returns the zap group that the item is part of. The integer values in the map are meaningless in this case, and the item itself isn't included. "fold" returns the fold group that the item is part of. The integer is the position in the fold sequence (1..N), and the item itself IS included, so you can determine its position. Retrieves some variable-length internal data that isn't readily readable via file_to_map().
==Coinmaster Control==
Some items can be bought from or sold to various "coinmasters" which are like shops that deal in a currency other than meat. These coinmasters include the Dimemaster and Quartermaster during the Island War, the Hermit, the Mr. Store and many others. Some relevant information can be found in [[proxy records]] for the item and coinmaster data types. The rest is controlled by the following functions.


'''void [[refresh_stash()]]''' - takes a new look at the contents of your clan stash. Crucial if your clanmates have been manipulating the contents during your session.
===Inquiries===
{{Flink|coinmaster|to_coinmaster|string|desc=Converts a string to a valid coinmaster.}}
{{Flink|boolean|is_coinmaster_item|item|desc=Is a given item acquirable from a coinmster.}}
{{Flink|boolean|buys_item|coinmaster|item|desc=Is a specific item acquirable from the named coinmster.}}
{{Flink|int|buy_price|coinmaster|item|desc=What is the coinmaster's purchase price for an item.}}
{{Flink|boolean|sells_item|coinmaster|item|desc=Is a specific item sellable to the named coinmster.}}
{{Flink|int|sell_price|coinmaster|item|desc=What is the coinmaster's selling price for an item.}}


'''boolean [[is_tradeable|is_tradeable( item it )]]''' - returns true if the item can be placed in the mall
===Coinmaster transactions===
{{Flink|boolean|is_accessible|coinmaster|desc=Is a given coinmaster currently accessible.}}
{{Flink|string|inaccessible_reason|coinmaster|desc=The reason a given coinmaster is currently inaccessible.}}
{{Flink|boolean|visit|coinmaster|desc=Refreshes information at a coinmaster.}}
{{Flink|boolean|buy|coinmaster|int|item|desc=Buys an item from a coinmaster.}}
{{Flink|boolean|sell|coinmaster|int|item|desc=Sells an item to a coinmaster.}}


'''boolean [[is_giftable|is_giftable( item it )]]''' - returns true for tradeable items and gift items like stuffies
===Sweet Synthesis===
{{Flink|item [int]|candy_for_tier|int|{{opt|int}}|desc=Returns all the candy to create a given tier of effect.}}
{{Flink|item [int]|sweet_synthesis_pairing|effect|item|{{opt|int}}|desc=Find a second candy to synthesize.}}
{{Flink|item [int]|sweet_synthesis_pair|effect|{{opt|int}}|desc=Picks a pair of candies to synthesize for an effect.}}
{{Flink|effect|sweet_synthesis_result|item|item|desc=Show result of synthesis.}}
{{Flink|boolean|sweet_synthesis|item|item|desc=Synthesize specified candies.}}
{{Flink|boolean|sweet_synthesis|effect|{{opt|int}}|desc=Picks a pair of candies and synthesizes them for the effect.}}


'''boolean [[is_displayable|is_displayable( item it )]]''' - returns true for all items that can be put in a display case (all items but quest items)


'''boolean [[is_npc_item|is_npc_item( item it )]]''' - returns true for all items that can be bought from an NPC store
[[Category:Scripting]]

Latest revision as of 14:26, 13 July 2021

Informational

int my_meat()

Returns the amount of meat you have on hand.

int my_closet_meat()

Returns the amount of meat you have in your Colossal Closet.

int my_storage_meat()

Returns the amount of meat you have in Hagnk's Ancestral Mini-Storage.

int pulls_remaining()

Returns the number of pulls you can make from storage, or 0 if not applicable.

boolean have_chef()

Returns true if you have a chef-boxen at your campground.

boolean have_bartender()

Returns true if you have a bartender-boxen at your campground.

int [item] get_campground()

Returns a map of your campground items.

int [item] get_clan_lounge()

Returns a map of your Clan VIP Lounge items.

item get_dwelling()

Returns the item corresponding with your dwelling.

boolean have_mushroom_plot()

Returns true if and only if you've purchased a mushroom plot this run.

int stills_available()

Returns the number of Nash Crosby's Still uses left for the day (0 if not accessible).

string item_type( item )

Returns the type of item specified.

int item_amount( item )

int closet_amount( item )

int display_amount( item )

int equipped_amount( item )

int shop_amount( item )

int [item] get_shop()

Returns entire contents of shop and quantity of each item

int stash_amount( item )

int storage_amount( item )

These 7 functions return the total number available of a given item in the respective section of your inventory.

int available_amount( item )

Returns the total number available of a given item in all inventory sections accessible to your character based on current restrictions.

int creatable_amount( item )

Returns the amount of the item that you are capable of creating given your current inventory and skills.

int [item] get_ingredients( item )

Returns a map where each key is one of the required ingredients, with the integer value the number required. If you don't have the skills needed to make the item, it will return an empty map.

string craft_type( item )

Returns a string identifying how an item is crafted and any other requirements for creating it.

int [item] get_inventory()

Returns a map where each key is an item in your inventory, with the integer value its quantity.

int [item] get_related( item, string )

Returns associated items in a zap or fold group (see page for details).
You can categorize items in KoL using is_tradeable(), is_giftable(), and is_displayable().

boolean is_tradeable( item )

Returns whether the item can be placed in the mall.

boolean is_giftable( item )

Returns whether the item can be traded in a gift package.

boolean is_displayable( item )

Returns whether the item can be put in a display case (true for all but quest items).

boolean is_discardable( item )

Returns whether the item can be discarded or autosold.

boolean have_shop()

Returns whether you have a mall store.

boolean have_display()

Returns whether you have a display case.

boolean is_npc_item( item )

Returns whether the item can be bought from an NPC store.

void refresh_stash()

Takes a new look at the contents of your clan stash, as that section of inventory cannot be internally tracked due to access by others.

void refresh_shop()

Takes a new look at the contents of your mall store, as that section of inventory cannot be internally tracked due to access by others.

int shop_price( item )

Returns the current price for the given item if it is present in your mall store.

int npc_price( item )

Returns the current price of the given item if it can currently be bought from an NPC store.

int autosell_price( item )

Returns the autosell price of the item (0 for items that cannot be autosold).

int get_power( item )

Returns the power of the item (0 for items that don't have a power).

string to_plural( item )

Returns the plural of an item as a string.

int meat_drop( [monster] )

Returns a certain monster's base meat drop.

int [item] item_drops( [monster] )

Returns an array of a certain monster's base item drops, keying item to drop rate. Has certain limitations detailed on individual page.

record [int] item_drops_array( [monster] )

Returns an array of records holding information regarding a certain monster's base item drops.


Mall Prices

float historical_ageitem )

Returns the age of the price returned by historical_age() in days.

int historical_priceitem )

Returns the most recently seen mall price of an item without making a server request.

int mall_priceitem )

Returns the current (lowest) mall price of an item.

int mall_pricesstring, string? )

Updates the mall price for a category of items, and returns the number of items searched.

int mall_pricesboolean [item] )

Updates the mall price for a set of items, and returns the number of items searched.

Moving Items Around

boolean empty_closet()

Remove every item from the closet in a single server hit.

boolean put_closet( int, [item] )

boolean put_display( int, item )

boolean put_stash( int, item )

boolean take_closet( int, [item] )

boolean take_display( int, item )

boolean take_stash( int, item )

boolean take_storage( int, item )

Attempts to take or put the specified item in the appropriate section of your inventory, and returns its success.
If the item parameter is omitted from put_closet() or take_closet(), meat is transferred instead of an item.

boolean put_shop( int, int, [int], item )

boolean take_shop( [int], item )

Adds or removes items in your store and returns success.


Acquiring & Using Items

boolean autosell( int, item )

Attempts to autosell the given items and reports success.

boolean buy( [coinmaster], int, item )

int buy( int, item, int )

Tries to purchase the specified items.

boolean buy_using_storage( int, item )

int buy_using_storage( int, item, int )

Tries to purchase the specified items using meat in Hangks.

void clear_booze_helper()

Clears all queued booze helper items.

void clear_food_helper()

Clears all queued food helper items.

boolean create( int, item )

Attempts to create the specified items, following your KoLmafia settings regarding purchases to gather ingredients & require boxen.

boolean drinkitem, int? )

Attempts to drink the booze item(s).

boolean drinkint, item )

Attempts to drink qty of booze.

boolean eatitem, int? )

Attempts to eat the food item(s).

boolean eatint, item )

Attempts to eat qty of item.

boolean eatsilent( int, item )

Attempts to eat items as specified.

boolean chew( int, item )

Attempts to chew spleen items as specified and reports success.

boolean hermit( int, item )

Trades worthless items (buying and using chewing gum if needed) to the hermit for specified items (see page for details).

boolean use( int, item )

Attempts to use items as specified and reports success.

boolean overdrinkint, item )

boolean overdrinkitem, int? )

Attempts to drink a given number of item(s), suppressing overdrinking warnings.

boolean retrieve_item( int, item )

Uses KoLmafia internal logic to gather items (see page for details).

int craft( string, int, item, item )

Raw crafting that obeys KoLmafia settings (see page for details).

string last_item_message()

Returns message that KoL reports in the event of error.


Coinmaster Control

Some items can be bought from or sold to various "coinmasters" which are like shops that deal in a currency other than meat. These coinmasters include the Dimemaster and Quartermaster during the Island War, the Hermit, the Mr. Store and many others. Some relevant information can be found in proxy records for the item and coinmaster data types. The rest is controlled by the following functions.

Inquiries

coinmaster to_coinmaster( string )

Converts a string to a valid coinmaster.

boolean is_coinmaster_item( item )

Is a given item acquirable from a coinmster.

boolean buys_item( coinmaster, item )

Is a specific item acquirable from the named coinmster.

int buy_price( coinmaster, item )

What is the coinmaster's purchase price for an item.

boolean sells_item( coinmaster, item )

Is a specific item sellable to the named coinmster.

int sell_price( coinmaster, item )

What is the coinmaster's selling price for an item.


Coinmaster transactions

boolean is_accessible( coinmaster )

Is a given coinmaster currently accessible.

string inaccessible_reason( coinmaster )

The reason a given coinmaster is currently inaccessible.

boolean visit( coinmaster )

Refreshes information at a coinmaster.

boolean buy( coinmaster, int, item )

Buys an item from a coinmaster.

boolean sell( coinmaster, int, item )

Sells an item to a coinmaster.


Sweet Synthesis

item [int] candy_for_tier( int, [int] )

Returns all the candy to create a given tier of effect.

item [int] sweet_synthesis_pairing( effect, item, [int] )

Find a second candy to synthesize.

item [int] sweet_synthesis_pair( effect, [int] )

Picks a pair of candies to synthesize for an effect.

effect sweet_synthesis_result( item, item )

Show result of synthesis.

boolean sweet_synthesis( item, item )

Synthesize specified candies.

boolean sweet_synthesis( effect, [int] )

Picks a pair of candies and synthesizes them for the effect.