atom/proc/ParseMatch(Name, multi, ignorecase)
var/list/theKeywords = getKeyWords();
for(var/entry in theKeywords)
if(ignorecase)
Name = lowertext(Name)
entry = lowertext(entry)
if(multi && (Name == entry || copytext(entry,1,length(Name)+1)==Name)) return TRUE
else if(Name == entry) return TRUE
return FALSE
Problem description:
Okay so I am working on a text mud and basically there is something in AbyssDragon's parser that allows you to target mobs with just the first letter of their name but there is a bug to this if you type the command for example 'blast ' notice the space after the blast it will attack the nearest mob i am trying to make it stop doing this can anyone with some parser experience please help?
If you just want to fix the immediate problem, you can change that one line to this:
The problem is that you're getting a token that's an empty string. This token makes its way into ParseMatch() as Name. Then when it runs a copytext() it's copying entry from 1 to the length(Name)+1, which is just 1 because Name is empty. copytext() from 1 to 1 returns an empty string (because the end is exclusive, not inclusive) which is equal to, you guessed it, Name. So you just gotta check that name has a length before comparing it to the matching portion of entry.
Alternatively, you can change his tokenizer to not give you an empty token in the first place, but this may have side-effects depending on how you use his library: