Page 1 of 1

Problem with player:findNearestNameOrId and fix

Posted: Sat Feb 04, 2012 8:34 am
by romaniac
Hi!

There's a problem with the player:findNearestNameOrId function. It is impossible to find anything that has a "-" in its name. Such names occur rather frequently in the German client language.

The reason is the use of the string.find() function which takes a regular expression by default. "-" is a control character in regexes and would need to be escaped.

I fixed the problem by changing line 3564 in player.lua to read

Code: Select all

if( obj.Address ~= ignore and (obj.Id == tonumber(_objnameorid) or string.find(obj.Name, _objnameorid, 1, true ) )) then
That switches off regex interpretation and everything can be found as expected.

Maybe you want to include that fix into the code.

Maniac

Re: Problem with player:findNearestNameOrId and fix

Posted: Sat Feb 04, 2012 8:47 am
by lisa
string.find (s, pattern [, init [, plain]])
A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered "magic". Note that if plain is given, then init must be given as well.
Having 4th arg as true should deffinately work better for other languages.

Thought I would add this too for the 3rd arg, nice info to have
A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative.

Re: Problem with player:findNearestNameOrId and fix

Posted: Sat Feb 04, 2012 11:24 am
by rock5
I think that was looong overdue. Well done for pointing it out. Could probably simplify the new NormaliseString function with it too.

Re: Problem with player:findNearestNameOrId and fix

Posted: Mon Feb 06, 2012 3:53 am
by Germangold
---

Re: Problem with player:findNearestNameOrId and fix

Posted: Mon Feb 06, 2012 8:36 am
by rock5
Germangold wrote:german name for Housekeeper is "Hausmädchen"
therefore if left it like this target_npc("hausm.dchen");
but now it wont work anymore and i just replaced it with the npc ID...

targeting dailiy Quest from a board wont work like before the update to SVN 495..

i had to tweak my varanas_1 routine al little bit
Nothing should have changed.

Are you saying that this doesn't work?

Code: Select all

player:target_NPC("Hausm.dchen");
I noticed you wrote it with lower case "npc" and the "h". Did you use the correct capitals?

Why doesn't targeting quest boards not work? What happens? Why are you talking about 495? I hope you meant 695. :)

Re: Problem with player:findNearestNameOrId and fix

Posted: Mon Feb 06, 2012 10:07 am
by Germangold
rock5 wrote:
Nothing should have changed.
Due to update 695 (sorry about 495.. got confussed with nummbers) targeting the dailys quest board in logar
and accepting quest by name : boars and bears wont work for me as fluent it was before.

i tried to accept all but failied again
before (wont work anymore)

Code: Select all

 --    420112  Keiler-Hauer sammeln  420129  Scharfe Baerenklauen
   -- questnames
   boars = GetIdName(420112);
   bears = GetIdName(420129); 
 -- standing right next to the quest targert and
   -- need to accept two quest 110584 blackboard id
   
   player:target_Object(110584); yrest(500);
   AcceptQuestByName(boars); yrest(500);
   player:target_Object(110584); yrest(500);
   AcceptQuestByName(bears); yrest(500);
   printf("Got the Quests\n");
after:
make sure you have previously accept all other quest on the quest board, so only those "unfinished" and not accepted quest will show to choose

Code: Select all

player:target_Object(110584); 
RoMScript("OnClick_QuestListButton(1, 1)"); 
RoMScript("SpeakFrame:Hide()"); 
yrest(1000);
player:target_Object(110584); 
RoMScript("OnClick_QuestListButton(1, 1)"); 
RoMScript("SpeakFrame:Hide()"); yrest(1000);
 
	
Are you saying that this doesn't work?

Code: Select all

player:target_NPC("Hausm.dchen");
I noticed you wrote it with lower case "npc" and the "h". Did you use the correct capitals?
[/quote]
before:

Code: Select all

player:target_NPC("hausm.dchen"); --leave the house
after:

Code: Select all

 player:target_NPC(110758); --leave the house
works now internationaly

Re: Problem with player:findNearestNameOrId and fix

Posted: Mon Feb 06, 2012 10:58 am
by rock5
Germangold wrote: i tried to accept all but failied again
before (wont work anymore)

Code: Select all

 -- 420112 Keiler-Hauer sammeln 420129 Scharfe Baerenklauen
-- questnames
boars = GetIdName(420112);
bears = GetIdName(420129); 
-- standing right next to the quest targert and
-- need to accept two quest 110584 blackboard id

player:target_Object(110584); yrest(500);
AcceptQuestByName(boars); yrest(500);
player:target_Object(110584); yrest(500);
AcceptQuestByName(bears); yrest(500);
printf("Got the Quests\n");
This works fine for me. I've looked at the code and it should work fine for german clients as well. Have you removed "userfunction_QuestByName" from the userfunctions folder?
Germangold wrote:before:

Code: Select all

player:target_NPC("hausm.dchen"); --leave the house
after:

Code: Select all

 player:target_NPC(110758); --leave the house
works now internationaly
Yes, but I'm sure this would have worked.

Code: Select all

player:target_NPC("Hausm.dchen"); --leave the house

Re: Problem with player:findNearestNameOrId and fix

Posted: Tue Feb 07, 2012 10:57 am
by rock5
Fixed in revision 696