Results 1 to 4 of 4

Thread: to_item() results

  1. #1
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    921

    Default to_item() results

    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 =>

  2. #2
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    921

    Default

    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]]

  3. #3
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,115

    Default

    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:
    > ash to_item( 0 )
    
    Returned: none
    ...
    > ash to_item( 1 )
    
    Returned: seal-clubbing club
    ...
    > ash to_item( 11111111 )
    
    Returned: none
    ...
    > ash to_item( "[0]" )
    
    Returned: [0]
    ...
    > ash to_item( "[1]" )
    
    Returned: seal-clubbing club
    ...
    > ash to_item( "[11111111]" )
    
    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.

  4. #4
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    921

    Default

    Thanks for clarification.
    I will make a feature request to update to_item() to return $item[none] for non-valid "[XXX]" strings
    Last edited by ckb; 07-17-2019 at 11:13 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •