Difference between revisions of "To item"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
(Created page with '{{ #vardefine:name|to_item}}{{ #vardefine:return_type|item}}{{ FunctionPage| name={{#var:name}}| function_category=Datatype Conversions| function1={{Function| name={{#var:name}…')
 
imported>Bale
m
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Datatype Conversions|
 
  
 
function1={{Function|
 
function1={{Function|
Line 43: Line 42:
 
special=Unlike direct casting via $item[ ], no match found by this function will return $item[ none ] rather than abort.|
 
special=Unlike direct casting via $item[ ], no match found by this function will return $item[ none ] rather than abort.|
 
}}
 
}}
 +
 +
[[Category:Datatype Conversions]]

Revision as of 05:22, 22 May 2010

needs(code_samples);

Function Syntax

item to_item(string name )

item to_item(int id )

  • id is an item ID # to convert

item to_item(string name ,int qty )

  • name is an item name to convert
  • qty is an item quantity (acts as a check)
    • If qty is 1, this function follows normal string matching
    • If qty is any other number, this function will allow plural names to match

Returns the item that matches name or id as specified. Plural names will not match unless the third form is used and qty is not equal to 1.

Special

Unlike direct casting via $item[ ], no match found by this function will return $item[ none ] rather than abort.