to_item() results

ckb

Minion
Staff member
I am not sure exactly what is happening here, and I think this might have to do with the fact that to_item() can take lots of argument types, and sometimes items can start with [itemid] numbers... but this does not give the result I expect:

> ash to_item("[consumables]");

Returned: [0]
name =>
plural => nulls
descid =>
image =>
smallimage =>
levelreq => 0
quality =>
adventures =>
muscle =>
mysticality =>
moxie =>
fullness => 0
inebriety => 0
spleen => 0
minhp => 0
maxhp => 0
minmp => 0
maxmp => 0
dailyusesleft => 0
notes =>
quest => false
gift => false
tradeable => false
discardable => false
combat => false
combat_reusable => false
usable => false
reusable => false
multi => false
fancy => false
candy => false
candy_type => none
chocolate => false
seller => none
buyer => none
name_length => 0
noob_skill => none
tcrs_name =>
 

ckb

Minion
Staff member
I think this might be that $item[none] == $item[[0]], but I would think that to_item() would return $item[none] and not $item[[0]]
 

Veracity

Developer
Staff member
You are using "to_item( string )". If a string starts with "[XXX]", where XXX is a number, you get the item with itemId XXX.
If XXX is not a number, we should probably throw an error.
Instead, apparently, the non-number is interpreted as 0.

Code:
[color=green]> ash to_item( 0 )[/color]

Returned: none
...
[color=green]> ash to_item( 1 )[/color]

Returned: seal-clubbing club
...
[color=green]> ash to_item( 11111111 )[/color]

Returned: none
...
[color=green]> ash to_item( "[0]" )[/color]

Returned: [0]
...
[color=green]> ash to_item( "[1]" )[/color]

Returned: seal-clubbing club
...
[color=green]> ash to_item( "[11111111]" )[/color]

Returned: [11111111]
...
Yeah, if we don't throw an error, we should probably return $item[none] for anything in the [] which is not a valid item number.
 

ckb

Minion
Staff member
Thanks for clarification.
I will make a feature request to update to_item() to return $item[none] for non-valid "[XXX]" strings
 
Last edited:
Top