Menu

#162 Way to (easily) get number of arches inside inventory (cfpy.

open
nobody
None
5
2007-03-10
2007-03-10
No

Could there be added an easy way to get the number of archtypes inside a player's inventory? (not nrof of coins, etc, just the number of specific arch objects inside the inventory) via cfpython?

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I would say that this would be best to impliment at the same time as implimenting things like this as itterables for the python side. This would enable things like:

    num = ob.inv.count()

    to get the number of objects, or things like:

    for ob2 in ob1.inv:
    #do stuff

    which would be much cleaner.

     
  • Alexander Schultz

    Logged In: YES
    user_id=886813
    Originator: NO

    (The previous comment was mine. Forgot to log in)

     
  • Nobody/Anonymous

    Logged In: NO

    Does your request mean
    - "how do i count how many items a player has in inventory"
    or
    - "how do i count how many items of a specific archetype a player has"
    or
    - "how do i count how many different archetypes are in the player's inventory"
    ?

    first would be like like:
    inv = player.Inv;
    count = 0;
    while inv:
    count++;
    inv = inv.Below;

    second would look like:
    inv = player.Inv;
    count = 0;
    while inv:
    if inv.ArchName == 'namebeinglookedfor': [or "inv.Archetype == arch" if you got the archetype you're searching for in arch]
    count++;
    inv = inv.Below;

    third would be more complex, probably with a dictionary to accumulate different archetypes found

    (hasn't been tested, but that's the general logic)

     

Log in to post a comment.