I'm on the European Client with german as Ingame language, but I tried it on german and on english with the full name and a short version
player:merchant(114291);
is still the only function that works
I just translated the name and see that in german it includes a hyphen '-'. Hyphens have special meaning when doing string comparisons.
Try replacing it with a period '.' A period means "any character". That should work.
In future if you have similar problems just try replacing any suspect characters with periods.
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
rock5 wrote:I just translated the name and see that in german it includes a hyphen '-'. Hyphens have special meaning when doing string comparisons.
Try replacing it with a period '.' A period means "any character". That should work.
In future if you have similar problems just try replacing any suspect characters with periods.
Is there any reason why this is needed in this particular case? Couldn't we just set the 4th parameter to true so that patterns cannot be used, or is this actually used somewhere?
Administrator wrote:Is there any reason why this is needed in this particular case? Couldn't we just set the 4th parameter to true so that patterns cannot be used, or is this actually used somewhere?
Good point. Merchant would only ever get a name for an argument. I don't see the need for any special pattern matching features. But untumately the base function is findNearestNameOrId. I don't know if it would be wise to block pattern features with such a far reaching function. I certainly couldn't say for sure that it would be safe to do so.
If we think that merchant wouldn't be used with special pattern matching, maybe we could fix the string with a general purpose string fixing function that fix all the special characters? Or does a function like that already exist?
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
rock5 wrote:If we think that merchant wouldn't be used with special pattern matching, maybe we could fix the string with a general purpose string fixing function that fix all the special characters? Or does a function like that already exist?
Not that I'm aware of. Could just use string.gsub() to replace certain characters with an escaped representation, though.
That's exactly what I mean. I know there are functions like that, to do with converting strings for differnt languages but I wasn't sure if there was one just for this purpose.
Ok, so what do we call it? ConvertName FixName FixString? What characters need to be fixed? Just ' " -? Any others?
What should it be used for? merchant, target_npc? Any others?
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
Well, obviously, the best solution would be the simplest. I can't really see any place you would need the patterns in findNearestNameOrId(). I mean, if you want to look for say "Brown Bear" and "Young Bear", you could just search for "Bear", so you wouldn't need the .* pattern.
If we really need to, I guess we could just replace the patterns. What other special characters might appear in NPC names?