Difference between revisions of "Is displayable"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>PhilmASTErpLus
(Added code sample and removed needscode=yes.)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Item Management|
 
  
 
function1={{Function|
 
function1={{Function|
Line 18: Line 17:
 
function_description=This function checks to see if the item {{pspan|check_me}} can be put in a display case, returning true if it can and false otherwise.|
 
function_description=This function checks to see if the item {{pspan|check_me}} can be put in a display case, returning true if it can and false otherwise.|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Code Sample|
 +
description=The following code attempts to fill your display case with one of every item, only using the ones you have in your inventory. This is essentially a mock-up of [http://www.jickenwings.org/collections/index.cgi?query_value=holderofsecrets&query_type=player&last_query_type=&last_query_value=&Search=Search HolderofSecrets](Warning: large page), who is striving to get one of every item in the game.|
 +
code=<syntaxhighlight>
 +
batch_open();
 +
foreach itm, quantity in get_inventory()
 +
{
 +
  if ( is_displayable( itm ) && display_amount( itm ) == 0 )
 +
      put_display( 1 , itm );
 +
}
 +
batch_close();
 +
</syntaxhighlight>
 +
|moreinfo=Note that [[put_display]]() returns a boolean value indicating whether the operation is successful or not.
 +
}}|
  
 
see_also={{SeeAlso|is_giftable|is_tradeable}}|
 
see_also={{SeeAlso|is_giftable|is_tradeable}}|
 
}}
 
}}
 +
 +
[[Category:Item Management]]

Latest revision as of 18:20, 28 June 2010

Function Syntax

boolean is_displayable(item check_me )

  • check_me is an item to test

This function checks to see if the item check_me can be put in a display case, returning true if it can and false otherwise.

Code Sample

The following code attempts to fill your display case with one of every item, only using the ones you have in your inventory. This is essentially a mock-up of HolderofSecrets(Warning: large page), who is striving to get one of every item in the game.

batch_open();
foreach itm, quantity in get_inventory()
{
   if ( is_displayable( itm ) && display_amount( itm ) == 0 )
      put_display( 1 , itm );
}
batch_close();

Note that put_display() returns a boolean value indicating whether the operation is successful or not.

See Also

is_giftable() | is_tradeable()