To item: Difference between revisions
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>PhilmASTErpLus Added a code sample and removed needscode=yes| |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
FunctionPage| | FunctionPage| | ||
name={{#var:name}}| | name={{#var:name}}| | ||
function1={{Function| | function1={{Function| | ||
Line 31: | Line 30: | ||
parameter1={{Param|string|name}}| | parameter1={{Param|string|name}}| | ||
parameter2={{Param|int|qty}}| | parameter2={{Param|int|qty}}| | ||
p1desc={{Pspan|name}} is an item name to convert| | p1desc={{Pspan|name}} is an item name or string representation of an item ID # to convert| | ||
p2desc={{Pspan|qty}} is an item quantity (acts as a check) | p2desc={{Pspan|qty}} is an item quantity (acts as a check) | ||
* If {{pspan|qty}} is 1, this function follows normal string matching | * If {{pspan|qty}} is 1, this function follows normal string matching | ||
Line 39: | Line 38: | ||
function_description=Returns the item that matches {{pspan|name}} or {{pspan|id}} as specified. Plural names will not match unless the third form is used and {{pspan|qty}} is not equal to 1.| | function_description=Returns the item that matches {{pspan|name}} or {{pspan|id}} as specified. Plural names will not match unless the third form is used and {{pspan|qty}} is not equal to 1.| | ||
code1={{CodeSample| | |||
title=Code Sample| | |||
description=The following code fills a map with all items that has an ID number between 1000 and 1200.| | |||
code= | |||
<syntaxhighlight> | |||
boolean [item] item_list; | |||
for item_id from 1000 upto 1200 | |||
if to_item( item_id ) != $item[ none ] | |||
item_list[ to_item( item ) ] = true; | |||
</syntaxhighlight> | |||
}}| | |||
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]] |
Latest revision as of 02:52, 26 June 2010
Function Syntax
- id is an item ID # to convert
item to_item(string name ,int qty )
- name is an item name or string representation of an item ID # 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.
Code Sample
The following code fills a map with all items that has an ID number between 1000 and 1200.
boolean [item] item_list;
for item_id from 1000 upto 1200
if to_item( item_id ) != $item[ none ]
item_list[ to_item( item ) ] = true;
Special
Unlike direct casting via $item[ ], no match found by this function will return $item[ none ] rather than abort.