Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: List all clubs in inventory

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    504

    Default List all clubs in inventory

    I wrote the following snippet to list all the clubs I currently have in my inventory:

    Code:
    void main() {
        item it;
        buffer it_desc;
        matcher club_matcher;
        string pattern;
        
        pattern = "Type: <b>weapon \\((\\d+-handed) club\\)<\\/b>";
        
        foreach it in get_inventory() {
            if (weapon_type(it) == $stat[muscle]) {
                it_desc = visit_url("desc_item.php?whichitem=" + to_string(it.descid));
                club_matcher = create_matcher(pattern, it_desc);
                if (find(club_matcher)) {
                    print (it.name + " - " + group(club_matcher, 1), "green");
                }
            }
        }
    }
    This works, but I am curious if there is any way to get a list of all available clubs without parsing and searching the descriptions of all the items in my inventory? I assume this information is available to e.g. the modifier-maximizer, since you can specify that you just want to equip clubs there, but I haven't found any way to make this information available to my script.

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

    Default

    Code:
    foreach it in get_inventory() {
    	if (item_type(it)=="club") { print(it); }
    }
    Also, I find these functions useful:

    Code:
    boolean IsAccord(item it) {
    	return (item_type(it)=="accordion");
    }
    
    
    boolean IsClub(item it) {
    	return (item_type(it)=="club");
    }
    Last edited by ckb; 07-17-2017 at 11:15 PM.

  3. #3
    Senior Member
    Join Date
    Dec 2008
    Posts
    504

    Default

    Thanks! That is much simpler

  4. #4

    Default

    I use
    Code:
    foreach it in get_inventory()
    {
    	if ( item_type( it ) == "club" && weapon_hands( it ) == 1 )
    	{
    		print_html( it + ": " + get_power( it ) );
    	}
    }
    Usually I only want 1-handed clubs. I also tend to go with print_html() to avoid cluttering my session log with the script's output.

  5. #5
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    211

    Default

    Is there a way to check items for enchantments?

  6. #6
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,697

    Default

    When I know what enchantment I am looking for, I have alias:
    Code:
    findmoda=> ash foreach it in get_inventory() { int modval = numeric_modifier(it, $string[%%]); if (modval!=0) { print(it + ": " + modval); } }
    If you just want "any enchantment" or enumerate all enchantments on an item ... I don't know how.

  7. #7

    Default

    Code:
    string_modifier( item, "Modifiers" ) != ""
    should work (incorporated into the right script).

  8. #8
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    211

    Default

    When I know what enchantment I am looking for, I have alias:
    Code:
    findmoda=> ash foreach it in get_inventory() { int modval = numeric_modifier(it, $string[%%]); if (modval!=0) { print(it + ": " + modval); } }
    If you just want "any enchantment" or enumerate all enchantments on an item ... I don't know how.
    Originally Posted by xKiv View Post
    I'm looking for the enchantment "Adventures at rollover"

  9. #9
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,697

    Default

    Looking at modifiers.txt in mafia source, that's just "Adventures". Inside mafia, you can either check some item you know has the enchantment using string_modifier (item, "Modifiers"), or ... the modtrace command? And there's at least one more command that lists all modifiers that can be associated with something ... modref?.

  10. #10

    Default

    Using "modtrace adv" would let you know that Adventures is what you want.

Posting Permissions

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