Npc price: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Theraze
No edit summary
imported>Bale
clarity of non-availability
 
(One intermediate revision by one other user not shown)
Line 15: Line 15:
}}|
}}|


function_description=Returns the current price of the given item from NPC shops, given availability to the player. This function runs a new check each time it is called, so if you call this function and then unlock a new NPC store, calling this function again will return the new availability state of the item.|
function_description=Returns the current price of the given item from NPC shops, given availability to the player. If it is not available from an NPC store or the store is not available, then it returns 0.</p>
 
<p>This function runs a new check each time it is called, so if you call this function and then unlock a new NPC store, calling this function again will return the new availability state of the item.|


code1={{CodeSample|
code1={{CodeSample|
Line 24: Line 26:
foreach i in get_inventory()
foreach i in get_inventory()
{
{
   if (is_npc_item(i)) if (npc_price(i) == 0) print(i+" can be bought but not by you.");
   if (is_npc_item(i))
  else print(i+" can be bought for "+npc_price(i));
  {
    if (npc_price(i) == 0) print(i+" can be bought but not by you.");
    else print(i+" can be bought for "+npc_price(i));
  }
}
}
</syntaxhighlight>}}|
</syntaxhighlight>}}|

Latest revision as of 22:04, 31 January 2015

Function Syntax

int npc_price(item shop_for )

  • shop_for is the item to inquire on the npc price and availability of.

Returns the current price of the given item from NPC shops, given availability to the player. If it is not available from an NPC store or the store is not available, then it returns 0.

This function runs a new check each time it is called, so if you call this function and then unlock a new NPC store, calling this function again will return the new availability state of the item.

Code Sample

Parse your inventory checking to see which NPC items are available to you.

foreach i in get_inventory()
{
  if (is_npc_item(i))
  {
    if (npc_price(i) == 0) print(i+" can be bought but not by you.");
    else print(i+" can be bought for "+npc_price(i));
  }
}

See Also

historical_price() | buy() | mall_price() | retrieve_item()

Special

Items not currently available will return 0. When not logged in, this function returns 0 for all items, as none of them are available to you at the time.