Problem with player:findNearestNameOrId and fix

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
romaniac
Posts: 79
Joined: Sat Feb 04, 2012 8:25 am

Problem with player:findNearestNameOrId and fix

#1 Post 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
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Problem with player:findNearestNameOrId and fix

#2 Post 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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Problem with player:findNearestNameOrId and fix

#3 Post by rock5 »

I think that was looong overdue. Well done for pointing it out. Could probably simplify the new NormaliseString function with it too.
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Germangold
Posts: 276
Joined: Thu Oct 22, 2009 3:58 am

Re: Problem with player:findNearestNameOrId and fix

#4 Post by Germangold »

---
Last edited by Germangold on Mon Feb 06, 2012 10:09 am, edited 1 time in total.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Problem with player:findNearestNameOrId and fix

#5 Post 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. :)
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Germangold
Posts: 276
Joined: Thu Oct 22, 2009 3:58 am

Re: Problem with player:findNearestNameOrId and fix

#6 Post 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
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Problem with player:findNearestNameOrId and fix

#7 Post 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
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Problem with player:findNearestNameOrId and fix

#8 Post by rock5 »

Fixed in revision 696
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Post Reply