createpath + getid + getpos together
Re: createpath + getid + getpos together
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.
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
- 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
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.
Oh, and congratulations on the 10K post milestone.
Re: createpath + getid + getpos together
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
- 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
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.
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.
Re: createpath + getid + getpos together
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
- 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
createpath.lua starting at line 395
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").
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
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").
Re: createpath + getid + getpos together
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
- 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
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.
Re: createpath + getid + getpos together
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>"
<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
Re: createpath + getid + getpos together
1. I'm not sure I agree.
2. I guess I could add Russian support. I'll do some testing tomorrow.
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
- 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
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.
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.
Re: createpath + getid + getpos together
Looks like I can't test Russian but I tested with the umlauts function in German
It didn't work.
Are you sure the above fix you wrote works and without it it doesn't?
Code: Select all
name = utf8ToAscii_umlauts(name)
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
Re: createpath + getid + getpos together
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:
У меня нехватает знаний сделать это универсальным для разных языков, но с моими исправлениями все хорошо работает для русской версии. Надеюсь вы сможете сделать это универсальным для всех языков
)
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
Re: createpath + getid + getpos together
What do you mean? You came up with a perfectly good versatile solution with thisfreemw wrote:I have not enough knowledge to make it versatile for different languages
Code: Select all
if( bot.ClientLanguage == "RU" ) then
name=utf82oem_russian(name) -- language conversations for Russian Client
end
- 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
- 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
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.
The relevant sections of code in createpath.lua are:
Starting at line 668:
Starting at line 730:
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
12:38am - scripts\rom/createpath.lua:737: attempt to concatenate local 'index' (a nil value)
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 ...
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
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
- 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
Well it kinda fixed things, and kinda didn't. Adding that check kept createpath from crashing, but the resulting command fails when executed.
So even though createpath found a matching text string, the bot failed to make a match at run time in the ChoiceOptionByName() function.
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
- 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
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
Re: createpath + getid + getpos together
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
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.
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.
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 fromto
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.
Code: Select all
/pr g_SpeakFrameData.option
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).Bill D Cat wrote:Code: Select all
if index == nil then <-- Would this fix things? index = num end
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
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..")")
Code: Select all
RoMCode("ChoiceOptionByName("..name..")")
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
- 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
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.
Re: createpath + getid + getpos together
Well.. it was untested.
So I take it you can't see how to fix it?
Hint: ChoiceOptionByName is not an in game function.
So I take it you can't see how to fix it?

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
Who is online
Users browsing this forum: Google [Bot] and 0 guests