Difference between revisions of "Autosell"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
imported>Bale
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#vardefine:name|autosell}}
+
{{
{{#vardefine:return_type|boolean}}
+
#vardefine:name|autosell}}{{
{{FunctionPage|
+
#vardefine:return_type|boolean}}{{
 +
 
 +
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Item Management|
 
  
 
function1={{Function|
 
function1={{Function|
Line 16: Line 17:
 
}}|
 
}}|
  
function_description=Attempts to autosell {{pspan|qty}} of {{pspan|it}}. Returns true if all items are sold as specified, or as many as possible, and false.</p>
+
function_description=Attempts to autosell {{pspan|qty}} of {{pspan|it}}. Returns true if all items are sold as specified, or as many as possible, and false otherwise.</p>
 
<p>Note that specifying a higher {{pspan|qty}} than you have of an item, or an item that cannot be autosold, will still return true as the function has done as much as it could.|
 
<p>Note that specifying a higher {{pspan|qty}} than you have of an item, or an item that cannot be autosold, will still return true as the function has done as much as it could.|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Code Sample|
 +
description=Sell off all pork gems.|
 +
code=
 +
<syntaxhighlight>
 +
if(item_amount($item[pork elf goodies sack]) > 0)
 +
  use(item_amount($item[pork elf goodies sack]), $item[pork elf goodies sack]);
 +
foreach stone in $items[hamethyst, baconstone, porquoise]
 +
  autosell(item_amount(stone), stone);
 +
</syntaxhighlight>
 +
}}|
  
 
cli_equiv=The CLI commands "sell" and "autosell" function similarly.|
 
cli_equiv=The CLI commands "sell" and "autosell" function similarly.|
 
}}
 
}}
 +
 +
[[Category:Item Management]]

Latest revision as of 22:07, 21 May 2010

Function Syntax

boolean autosell(int qty ,item it )

  • qty is the quantity to sell
  • it is the item to sell

Attempts to autosell qty of it. Returns true if all items are sold as specified, or as many as possible, and false otherwise.

Note that specifying a higher qty than you have of an item, or an item that cannot be autosold, will still return true as the function has done as much as it could.

Code Sample

Sell off all pork gems.

if(item_amount($item[pork elf goodies sack]) > 0)
   use(item_amount($item[pork elf goodies sack]), $item[pork elf goodies sack]);
foreach stone in $items[hamethyst, baconstone, porquoise]
   autosell(item_amount(stone), stone);

CLI Equivalent

The CLI commands "sell" and "autosell" function similarly.