Historical age: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | <onlyinclude>{{{{{format|Function2}}} | ||
|name=historical_age | |||
|function1.return_type=float | |||
|function1.description=Returns the age of the price returned by {{f|historical_age}} in days. | |||
|function1.param1=shop_for | |||
|function1.param1.type=item | |||
|function1.param1.description=Item to check for | |||
|description=The return value is in days. For example, a return value of 0.5 means that the price is 12 hours old. | |||
|code1={{CodeSample | |||
|title=Code Samples | |||
|description=This function returns a price no more than 18 hours old by checking {{f|mall_price}} if {{f|historical_price}} is older than that. | |||
|code= | |||
{{{!}} class="wikitable" | |||
! style="width: 50%" {{!}} ASH | |||
! style="width: 50%" {{!}} JavaScript | |||
{{!}}- style="vertical-align: top" | |||
{{!}} | |||
<syntaxhighlight lang="d" line highlight="2"> | |||
int check_price( item shopfor ) { | |||
if ( historical_age( shopfor ) > .75 ) | |||
return mall_price( shopfor ); | |||
return historical_price( shopfor ); | |||
} | |||
</syntaxhighlight> | |||
{{!}} | |||
<syntaxhighlight lang="js" line highlight="4"> | |||
const { historicalAge, historicalPrice, mallPrice } = require("kolmafia"); | |||
function checkPrice(shopfor) { | |||
if (historicalAge(shopfor) > .75) | |||
return mallPrice(shopfor); | |||
return historicalPrice(shopfor); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{!}}} | |||
|moreinfo= | |||
}} | }} | ||
|see_also={{SeeAlso/Mall Prices}} | |||
|cli_equiv= | |||
|more_info= | |||
|special= | |||
|{{{1|}}} | |||
}}</onlyinclude> | |||
[[Category:Item Management]] | [[Category:Item Management]] |
Latest revision as of 15:06, 31 December 2020
Function Syntax
float historical_age( item shop_for )
- Returns the age of the price returned by
historical_age()
in days.- shop_for: Item to check for
The return value is in days. For example, a return value of 0.5 means that the price is 12 hours old.
Code Samples
This function returns a price no more than 18 hours old by checking mall_price()
if historical_price()
is older than that.
ASH | JavaScript |
---|---|
int check_price( item shopfor ) {
if ( historical_age( shopfor ) > .75 )
return mall_price( shopfor );
return historical_price( shopfor );
}
|
const { historicalAge, historicalPrice, mallPrice } = require("kolmafia");
function checkPrice(shopfor) {
if (historicalAge(shopfor) > .75)
return mallPrice(shopfor);
return historicalPrice(shopfor);
}
|