createpath + getid + getpos together

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#141 Post by rock5 » Tue Dec 03, 2013 1:36 am

It's probably not necessary. Probably the only differences are those few I've already made for the language support.

The problem with getting on with the language support is I was really hoping I'd get some feedback from my post and I could use them to make sure I didn't miss anything and to guage the effects of any changes I made. But I haven't had any yet.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#142 Post by Bill D Cat » Tue Dec 03, 2013 1:53 am

Alas, I use an English client here in the States, so any other language support isn't a priority for me. I'm just doing my best to make createpath as language independent as possible with the latest set of changes we've added.

Oh, and congratulations on the 10K post milestone.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#143 Post by rock5 » Tue Dec 03, 2013 2:28 am

I didn't notice. Thanks.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#144 Post by Bill D Cat » Tue Dec 24, 2013 1:54 pm

Just tried to use createpath and found that the byname getInput() function isn't working correctly right now. The prompt to enter the option is displayed, but no matter what key is pressed it doesn't accept the input.

I've tried all the other options and they seem to work fine. Even the input for Numpad-0 is working correctly, so it appears to only be the single character input that is used by the byname option that is having issues.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#145 Post by rock5 » Wed Dec 25, 2013 11:09 am

Works for me. Try adding some print messages along the way to see what's happening.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#146 Post by Bill D Cat » Wed Dec 25, 2013 11:30 am

createpath.lua starting at line 395

Code: Select all

		repeat
			local ks = keyboardState()
			local stillpressed
			for k,v in pairs(ks) do
				if v then stillpressed = true print(v) end
			end
			yrest(50)
			print(stillpressed)
		until not stillpressed
As soon as I use the Numpad-6 key, stillpressed always equals true and so this loop never exits. Pressing any other key will not change the value. And print(v) always outputs true as well. If I change that to print(k) then the output alternates between 255 (no key pressed) and the key value that was pressed.

System info: Windows 8.1, MicroMacro 1.04.132, RoMBot version 3.29 Revision 769. Only files that are conflicted are addresses.lua (expected) and skills.xml (to include the missing Mage/Rogue elite "Shadow Protection").

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#147 Post by rock5 » Wed Dec 25, 2013 12:15 pm

My first idea is maybe your numkey 6 is sticking but I just did a test while repeating a key and I did not see 255 come up as true. I'd say the problem is with that 255 key but I don't know what would cause it. It's also wrong that the key pressed still shows as being pressed even when you have released it. I don't know. It could be a keyboard issue, a driver issue or a Windows issue.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#148 Post by Bill D Cat » Wed Dec 25, 2013 12:51 pm

Looks like the last Windows Update messed with my keyboard drivers or something. Did a rollback, applied the update again and reboot and now it is working fine.

freemw
Posts: 4
Joined: Tue Mar 13, 2012 11:49 pm

Re: createpath + getid + getpos together

#149 Post by freemw » Sat Nov 29, 2014 11:58 am

1. Maybe we should always add the header in files created by createpath.lua:
<onLoad>
</onLoad>

2. For the Russian game client. in order to properly selected menu correctly was recorded in files created by createpath.lua require a patch to file createpath.lua. start from line 669:
local name, typ, index = getChoice(tmp.com)
-- for russian
name=utf82oem_russian(name)
-- for russian
if name == nil then
tmp.wp_type = nil
hf_type = "<Invalid Option>"


2.1. Or right so:
local name, typ, index = getChoice(tmp.com)
if( bot.ClientLanguage == "RU" ) then
name=utf82oem_russian(name) -- language conversations for Russian Client
end
if name == nil then
tmp.wp_type = nil
hf_type = "<Invalid Option>"
Sorry for my bad English. I`m Russian

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#150 Post by rock5 » Sat Nov 29, 2014 12:21 pm

1. I'm not sure I agree.

2. I guess I could add Russian support. I'll do some testing tomorrow.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#151 Post by Bill D Cat » Sun Nov 30, 2014 10:01 am

While adding the <onload> section at the top of each file is easy to implement in the createpath file, I don't think it is necessary. My reason is, not all waypoint files will need it, and those that do will have all the included code entered manually. So adding to more lines is not that much more work, and the command itself isn't that difficult to remember the format for.

So if you want the support added for your particular createpaths file we can give you a section of code to add to the file, but I don't think it will make it into the official repository release any time soon.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#152 Post by rock5 » Sun Nov 30, 2014 10:42 am

Looks like I can't test Russian but I tested with the umlauts function in German

Code: Select all

name = utf8ToAscii_umlauts(name)
It didn't work.

Are you sure the above fix you wrote works and without it it doesn't?
  • 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

freemw
Posts: 4
Joined: Tue Mar 13, 2012 11:49 pm

Re: createpath + getid + getpos together

#153 Post by freemw » Fri Dec 05, 2014 1:06 pm

My file. For Russian Client works perfectly
I have not enough knowledge to make it versatile for different languages, but with my patch all works well for the Russian version. Hope you can make it universal for all languages
(In Russian language:
У меня нехватает знаний сделать это универсальным для разных языков, но с моими исправлениями все хорошо работает для русской версии. Надеюсь вы сможете сделать это универсальным для всех языков
)
Attachments
createpath.lua
(29.75 KiB) Downloaded 160 times
Sorry for my bad English. I`m Russian

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#154 Post by rock5 » Fri Dec 05, 2014 9:47 pm

freemw wrote:I have not enough knowledge to make it versatile for different languages
What do you mean? You came up with a perfectly good versatile solution with this

Code: Select all

if( bot.ClientLanguage == "RU" ) then
name=utf82oem_russian(name) -- language conversations for Russian Client
end
I'll probably use that. I'll include it in my next commit.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#155 Post by Bill D Cat » Sat May 16, 2015 12:49 pm

I was trying to add a waypoint to one of my Sascilia Steppes files where I just want to talk to Snoop at Ayren Caravan to activate that transport portal. I targeted him with NUMPAD 5, then selected NUMPAD 6 for the ChoiceOptionByName and selected option 4 "Leave conversation" and createpath crashes with an error.

Code: Select all

12:38am - scripts\rom/createpath.lua:737: attempt to concatenate local 'index' (a nil value)
The relevant sections of code in createpath.lua are:

Starting at line 668:

Code: Select all

						tmp.com = getInput(true, language[507]);	-- Choose option
						local name, typ, index = getChoice(tmp.com) 			<-- This getChoice() call ...
Starting at line 730:

Code: Select all

						else
							tmp.wp_type = "COBYNAME"
							name = string.match(name,"^[> ]*(.-)[< ]*$") -- Filter >> and << added by addons.
							tmp.text = name
							hf_type = sprintf("ChoiceOptionByName \'%s\'",name)
							message(prefix..sprintf(language[516], "\'"..name.."\'" ) ); -- ChoiceOptionByName
							tmp.keystring = getKeyStrings(name, true)--, "SC_", "SP")
							RoMCode("ChoiceOption("..index..")")  			<-- Causes the crash here
						end
Not sure why this is crashing the script, but I've just worked around it by using RoMScript("CloseAllWindows()") for now. My thought was adding the lines in the function below might work to fix this, but I don't know if it would break something else.

Code: Select all

local function getChoice(num)
	local text, typ, index = RoMCode("n="..num.." c=0 for k,v in pairs(g_SpeakFrameData.option) do if v.objtype~=1 then c=c+1 if c==n then a={v.title,v.type,v.id} break end end end")
	-- Fix title
	if text ~= nil then
		text = string.gsub(text,"|c%x*","") -- Remove color info
		text = string.gsub(text,"%[.*%]","") -- Remove added info in square brackets
		text = string.gsub(text,"%(.*%)","") -- Remove added info in normal brackets
		local acceptQuest = getTEXT("SYS_ACCEPT_QUEST")
		if string.find(string.lower(text),string.lower(acceptQuest)) then
			text = string.sub(text,#acceptQuest+2) -- Remove "Accept quest: "
		end
		text = trim(text) -- Trim leading and trailing spaces
	end
	if index == nil then			<-- Would this fix things?
		index = num
	end

	return text, typ, index
end

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#156 Post by Bill D Cat » Sat May 16, 2015 5:51 pm

Well it kinda fixed things, and kinda didn't. Adding that check kept createpath from crashing, but the resulting command fails when executed.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<!-- #  1 --><waypoint x="-38729" z="1555" y="2">
			player:target_NPC(111256) -- Snoop the Stubborn
			ChoiceOptionByName(getTEXT("HOUSE_MAID_LEAVE_TALK")) -- 'Leave conversation'
			error("Done",0)
	</waypoint>
</waypoints>

Code: Select all

We use the normal waypoint path test.xml now.
Clearing target.
Moving to waypoint #1, (-38730, 1553)
We try to find NPC 111256:
We successfully target NPC Snoop the Stubborn and try to open the dialog window.

Option "Leave conversation" not found.
The game client did not crash.
5:47pm - Done
So even though createpath found a matching text string, the bot failed to make a match at run time in the ChoiceOptionByName() function.

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#157 Post by Bill D Cat » Sat May 16, 2015 6:51 pm

Okay, I got it figured out now. Adding the fix in createpath to the getChoice() function fixes the first issue. And making the following change to the functions.lua file for the ChoiceOptionByName() function fixes the bot at runtime.

Code: Select all

function ChoiceOptionByName(optiontext)
------------------------------------------------
-- Select Option By Name
-- optiontext = option text or part of
-- NPC option dialog should already be open
------------------------------------------------
	if not RoMScript("SpeakFrame:IsVisible()") then
		printf("Please open a dialog before using \"ChoiceOptionByName\".\n")
		return
	end

    local counter = 1
	local option
    repeat
		option = RoMScript("GetSpeakOption("..counter..")")
		if option and FindNormalisedString(option,optiontext) then
			-- First try "ChoiceOption"
            RoMCode("ChoiceOption("..counter..");"); yrest(1000);

			-- If SpeakFrame is still open and option is still there then try "SpeakFrame_ListDialogOption"
			option = RoMScript("GetSpeakOption("..counter..")")
			if option and FindNormalisedString(option,optiontext) and RoMScript("SpeakFrame:IsVisible()") then
				RoMCode("SpeakFrame_ListDialogOption(1,"..counter..");"); yrest(1000);
			end
            return true
        end
		if option == nil and optiontext == getTEXT("HOUSE_MAID_LEAVE_TALK") then -- Should be the "Leave conversation" option
			RoMCode("CloseAllWindows()"); yrest(1000);
			return true
		end
        counter = counter + 1
    until not option
	printf("Option \"%s\" not found.\n",optiontext)
    return false
end

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#158 Post by rock5 » Sun May 17, 2015 6:06 am

Firstly, the problem with the "Leave conversion" option is that it has no "index"/"id" number. If you look at the getChoice function in createpaths you'll see that it iterates through the in-game table g_SpeakFrameData.option. If you print that in-game

Code: Select all

/pr g_SpeakFrameData.option
You'll see that the "Leave Conversion" option is the only one that doesn't have an 'id' value. Consequently you can't use GetChoiceOption or ChoiceOption functions on it. I think I never handled it because I assumed no one would bother selecting that option to close the dialog. It's usually not necessary after all.
Bill D Cat wrote:

Code: Select all

   if index == nil then         <-- Would this fix things?
      index = num
   end
This is incorrect for 2 reasons. Firstly if you select "Leave conversion" then there is no point in giving it a number because it can't use it for the above reasons. Secondly the logic is wrong because index is not necessarily the same as num. For instance if you have a dialog with 2 quests and 1 normal dialog option then the dialog option will have a num value of 3 but an index of 1 (because it's the first 'choice' option).

I'm pretty sure the "Leave Conversation" option is the only one that has no index so the best way to deal with it is to just deal with it separatly, eg.

Code: Select all

if index == nil then
   -- add command to close the dialog box
end
On second thought it's probably best to fix ChoiceOptionByName to be able to handle it and then just use ChoiceOptionByName on line 737 of createpath.

In regards to fixing ChoiceOptionByName, if optiontext == getTEXT("HOUSE_MAID_LEAVE_TALK") then it will equal it from the beginning of the function. No need to check it in each loop, just check it at the start of the function.

Then with that working the easiest fix for createpath is to change line 737 from

Code: Select all

							RoMCode("ChoiceOption("..index..")")
to

Code: Select all

							RoMCode("ChoiceOptionByName("..name..")")
I followed the game code and it looks like it uses SpeakFrame_Hide() when you click the "Leave Conversation" option so that's what I would use instead of CloseAllWindows.

Hope that's helpful.
  • 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
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: createpath + getid + getpos together

#159 Post by Bill D Cat » Sun May 17, 2015 9:43 am

Nope, that doesn't work either. I get this error message from createpath when I make the change on line 737 as you suggested.

Code: Select all

9:41am - IGF:\} ChoiceOptionByName(Leave conversation) if type(a)~="table" then a={a} end z={\:IGF Error in command sent to IGF.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: createpath + getid + getpos together

#160 Post by rock5 » Sun May 17, 2015 10:44 am

Well.. it was untested.

So I take it you can't see how to fix it? :P

Hint: ChoiceOptionByName is not an in game function.
  • 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

Who is online

Users browsing this forum: Google [Bot] and 0 guests