+ Reply to Thread
Results 1 to 3 of 3

Thread: LibEnfiltrate: Filter ALL the tables!

  1. #1
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default LibEnfiltrate: Filter ALL the tables!

    http://www.riftui.com/downloads/info...nfiltrate.html

    This is the generic filtering API that I've been yammering about. The idea here is that you can use this for ANYTHING which comes in tables like:

    Code:
    key = { field = value, otherfield = value, ... },
    ...
    It's got a framework for type-awareness so it can learn things like "the default for item rarities should probably be equal-or-exceed, and relations between them are not alphabetical" or "people usually want a case-insensitive contains match for names".

    This is going to be replacing a large portion of the guts of LibBaggotry, any day now.

    Would really appreciate feedback on design problems you encounter with it, because now's the time to change things.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  2. #2
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    Looking at the example, I can't help but wonder.

    Why:
    Code:
    named_bob = Library.LibEnfiltrate.Filter:new('bob')
    named_bob:include('name:bob')
    results = named_bob:filter(your_table_here)
    But then:
    Code:
    named_bob:disinclude(1)
    named_bob:include({ name = 'name', relation = '==', value = 'bob' })
    Why not:
    Code:
    named_bob:include('name==bob')
    Last edited by Verea; 03-01-2012 at 07:15 AM.
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

  3. #3
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    There's a format: field:relop:value and if you just do field:value, it guesses the relop. You can also give an explicit table if you want.

    The reason it's name:==:bob and not name==bob is that it hadn't occurred to me, and also that it wouldn't work for match. I could use ~, I guess, but that'd be confusing to Lua users, because Lua uses ~= for not-equal, not matches-with.

    The reason I show two different ways of specifying similar things is to show the multiple input forms taken. A matcher can be:

    1. A string which is @code, where code is compilable lua.
    2. A string with colons, split up to determine field, value, and possibly relop.
    3. A strong with no colons, which implicitly matches against "name".
    4. A { field, relop, value } table.

    The 4th form exists in case someone manages to find a case where the naive parsing doesn't do what they want for colons.

    I like the idea of a literal name==bob type thing, or rarity<rare, etc., so I will think a bit about this. Really, if I could find a good spelling for 'match' I could probably make that work.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

+ Reply to Thread

Bookmarks

Posting Permissions

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