Fuzzy matching for numeric modifier input

ereinion

Member
I created this scriptlet to help me decide what familiars to use in the new challenge path:
Code:
void main(string s) {
    foreach f in $familiars[] {
        if (is_unrestricted(f) && have_familiar(f)) {
            if (numeric_modifier(f, s, 100, familiar_equipment(f)) > 0) {
                print(to_string(f));
            }
        }
    }
}
However, I keep putting in e.g. "item" instead of "item drop" when I run it, making it display results, which while not strictly speaking erroneous, isn't the ones I want. So what I wonder is if there's some simple way to match the input string against the ones found in modref?
 

Bale

Minion
numeric_modifier() isn't something intended for casual use. I'd suggest that this simply isn't an effective use of our dev's time since the programmer should simply use the correct command. We don't do fuzzy matching of cli commands either, just in case the programmer didn't get it quite right.

I suggest fixing your script to deal with user error like this,

Code:
void main(string s) {
    if(s == "item") s = "item drop";
    else if(s == "meat) s = "meat drop";
    foreach f in $familiars[] {
        if (is_unrestricted(f) && have_familiar(f)) {
            if (numeric_modifier(f, s, 100, familiar_equipment(f)) > 0) {
                print(to_string(f));
            }
        }
    }
}
 

ereinion

Member
Ah, yes, I definitely agree that this wouldn't be an effective use of dev-time, which I am asking in scripting discussion instead of in a feature request :D I was just curious whether someone already had written a fuzzy matching algorithm for ash, and if there is any easy way to extract the modifier names?

The approach you suggest in your post is what I was planning on doing if doing what's been described turned out to be too tricky. Thanks for your feedback!
 
Last edited:

Bale

Minion
Ah... Not a feature request. Yeah... I missed that. :eek: I just click the button to see new posts and I don't always notice what forum it is posted in. Jeeez. I was a little out of line. sorry. :eek:

Another option would be if (s.contains_text("item"))
 

ereinion

Member
Hehe, that's ok, I figured it was something like that :) I'll go for something like what you suggest. But is there any way to get a list of possible modifiers without hardcoding them into the ash-script?
 
Top