Difference between revisions of "Autosell price"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>Bale
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#vardefine:name|autosell_price}}
+
{{
{{#vardefine:return_type|int}}
+
#vardefine:name|autosell_price}}{{
 +
#vardefine:return_type|int}}{{
  
{{FunctionPage|
+
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Item Management|
 
  
 
function1={{Function|
 
function1={{Function|
Line 17: Line 17:
 
function_description=Returns the autosell price of item {{pspan|it}}, or a value <= 0 if the item cannot be autosold. For most items that cannot be autosold, such as common Quest Items, this value will be 0. The value will be presented as a negative number in a few unusual cases where an item can't be autosold, but does have a defined value detectable by other means: a Mall minimum price other than 100, or a price in one of the sign restaurants.  The laser-broiled pear is an example of a non-autosellable item with a value detectable both ways.|
 
function_description=Returns the autosell price of item {{pspan|it}}, or a value <= 0 if the item cannot be autosold. For most items that cannot be autosold, such as common Quest Items, this value will be 0. The value will be presented as a negative number in a few unusual cases where an item can't be autosold, but does have a defined value detectable by other means: a Mall minimum price other than 100, or a price in one of the sign restaurants.  The laser-broiled pear is an example of a non-autosellable item with a value detectable both ways.|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Simple Example|
 +
description=Returns the autosell value if the mall price is at the minimum, else returns the mall price.|
 +
code=
 +
<syntaxhighlight>
 +
float v;
 +
item i = $item[white chocolate chip brownies];
 +
float minPrice = max(100, autosell_price(i) * 2);
 +
if (!use_autosell && !is_tradeable(i)) return 0;
 +
if (historical_age(i) > 3) v = mall_price(i);
 +
else v = historical_price(i);
 +
if (use_autosell && (v == minPrice)) v = autosell_price(i);
 +
print("Value of " + i + ": " + v);
 +
</syntaxhighlight>}}
  
see_also={{SeeAlso|autosell}}|
+
{{SeeAlso|autosell}}|
 
}}
 
}}
 +
 +
[[Category:Item Management]]

Latest revision as of 21:50, 21 May 2010

Function Syntax

int autosell_price(item it )

  • it is the item to check the price of

Returns the autosell price of item it, or a value <= 0 if the item cannot be autosold. For most items that cannot be autosold, such as common Quest Items, this value will be 0. The value will be presented as a negative number in a few unusual cases where an item can't be autosold, but does have a defined value detectable by other means: a Mall minimum price other than 100, or a price in one of the sign restaurants. The laser-broiled pear is an example of a non-autosellable item with a value detectable both ways.

Simple Example

Returns the autosell value if the mall price is at the minimum, else returns the mall price.

float v;
item i = $item[white chocolate chip brownies];
float minPrice = max(100, autosell_price(i) * 2);
if (!use_autosell && !is_tradeable(i)) return 0;
if (historical_age(i) > 3) v = mall_price(i);
else v = historical_price(i);
if (use_autosell && (v == minPrice)) v = autosell_price(i);
print("Value of " + i + ": " + v);


See Also

autosell()