Difference between pages "User talk:Relyk" and "Is discardable"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Bale
 
imported>Bale
(category fix)
 
Line 1: Line 1:
Thank you very much for adding {{f|my_effects}} to this wiki. Many hands make for light work so I always hope that eventually we'll have many hands here. :D --[[User:Bale|Bale]] 20:24, 16 August 2012 (EDT)
+
{{
 +
#vardefine:name|is_discardable}}{{
 +
#vardefine:return_type|boolean}}{{
 +
FunctionPage|
 +
name={{#var:name}}|
  
I see no problem with splitting Mood management from Mood (CLI) if you want to do that. You created the Mood page yourself after all and the idea isn't bad. While I'm at it, thanks for attacking the "To Do" list!  --[[User:Bale|Bale]] ([[User talk:Bale|talk]]) 04:40, 24 September 2015 (UTC)
+
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|item|check_me}}|
 +
p1desc={{Pspan|check_me}} is an item to test|
 +
}}|
 +
 
 +
function_description=This function check if item can be discarded, returning true if it can other false. Keep in mind it will return true if item can be autosold.|
 +
 
 +
code1={{CodeSample|
 +
title=Code Sample|
 +
description=The following searches all items in inventory and stores any items on display that can be discarded but not autosold (Autosell value is 0).|
 +
code=
 +
<syntaxhighlight>
 +
batch_open();
 +
int[item] inventory = get_inventory() ;
 +
foreach it in inventory
 +
  if ( is_discardable(it) && autosell_price(it) == 0 ){
 +
      put_display( item_amount(it), it );
 +
  }
 +
batch_close();
 +
// We're using a batch here to minimize server hits.
 +
</syntaxhighlight>
 +
}}|
 +
 
 +
see_also={{SeeAlso|use|autosell|is_giftable}}|
 +
}}
 +
 
 +
[[Category:Item Management]]

Revision as of 10:43, 10 November 2014

Function Syntax

boolean is_discardable(item check_me )

  • check_me is an item to test

This function check if item can be discarded, returning true if it can other false. Keep in mind it will return true if item can be autosold.

Code Sample

The following searches all items in inventory and stores any items on display that can be discarded but not autosold (Autosell value is 0).

batch_open();
int[item] inventory = get_inventory() ;
foreach it in inventory
   if ( is_discardable(it) && autosell_price(it) == 0 ){
      put_display( item_amount(it), it );
   }
batch_close();
// We're using a batch here to minimize server hits.

See Also

use() | autosell() | is_giftable()