Page 2 of 2
Re: waypoint stuff
Posted: Thu Aug 13, 2015 10:07 am
by beanybabe
I got your function to run but getElements I had never seen before I searched and found a description of its use here.
http://www.solarstrike.net/phpBB3/viewt ... ents#p1476
It looks like something handy I need to learn more about.
EI_01_InTheValley_converted was the output of your function it created 527 waypoints. But not quite what I had envisioned. I was wanting to go line by line and output the non waypont lines as well, to keep the basic flow of the original that can be then cut up and reformatted.
If I am understanding this getElements the way you used it would not allow the line by line output of wp and code. But reading that url I listed it seems there is a way to us it to do line by line reading.
Instead of this
- EI_01_InTheValleypoints = {
player:moveTo(CWaypoint(31954, 3278),true)
player:moveTo(CWaypoint(31978, 3441),true)
player:moveTo(CWaypoint(31932, 3733),true)
player:moveTo(CWaypoint(31880, 4091),true)
player:moveTo(CWaypoint(31835, 4202),true)
Id like to get this:
- <?xml version="1.0" encoding="utf-8"?><waypoints type="RUN">
<!-- This is a series of waypoint files that will complete a walk-through of the entire Elven Island quest series. -->
<!-- Required userfunctions: userfunction_teleport and userfunction_questHelpers -->
<!-- EI_01_InTheValley will complete all quests inside the Valley of Perparation -->
<!-- Approximate Runtime: 35 Minutes -->
<onload>
__WPL:setWaypointIndex(1)
</onload>
player:moveTo(CWaypoint(31954, 3278),true)
player:target_NPC(112793) -- Gamunhan
AcceptQuestByName(422241) -- Getting to Know Yourself
CompleteQuestByName(422241) -- Getting to Know Yourself
AcceptQuestByName(422242) -- Elven Academy
</waypoint> <<<< --------------------- I dont know if this would be left or not but it needed removed.
player:moveTo(CWaypoint(31978, 3441),true)
player:moveTo(CWaypoint(31932, 3733),true)
player:moveTo(CWaypoint(31880, 4091),true)
player:moveTo(CWaypoint(31835, 4202),true)
Re: waypoint stuff
Posted: Thu Aug 13, 2015 10:30 am
by beanybabe
This code is from the logger function, if your wp convert code could be merged in some how it should do the trick. I am still new to file io and this is as far as I can go at this time. I looked at doing this with regix and some editor but got lost on getting the x and y z coordinates I guess it should have z coordinates also to translate the original file as close to original as possible.
This would make converting existing wp into functions a lot easier.
Code: Select all
--=== code riped from Noobbotter's logPlayer function
local logFileName = "scripts/rom/logs/BotSummary.txt" -- you can specify what filename or directory you want here.
function file_exists(_filename)
local f=io.open(_filename,"r")
if f~=nil then
io.close(f)
return true
else
return false
end
end
function logPlayer()
if not file_exists(logFileName) then
print("No file found... creating one now\n")
createLogfile(logFileName)
end
local readfile,err = io.open(logFileName,"r")
if err then
return err
end
local newfile = {}
for line in readfile:lines() do --print(line)
if not string.match(line, player.Name) then --this needs be changed some how.
table.insert(newfile, line)
end
end
readfile:close()
local newentry = string.format("%-128s",line) --this needs changed
table.insert(newfile,newentry)
local writefile,err = io.open(logFileName,"w+")
for k,v in pairs(newfile) do
--printf("%s\n",v)
writefile:write(v.."\n")
end
writefile:close()
end
Re: waypoint stuff
Posted: Thu Aug 13, 2015 12:38 pm
by beanybabe
here is example of what I am doing I converted the Extinguish More Flames daily
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="RUN">
<onload>
function dlyExtinguishMoreFlames()
questtype = "daily"
userepeat = false
questItemId = 119791;
questid = 425186;
questname = GetIdName(questid);
while true do
player:moveTo(CWaypoint(-21567,-22960), true)
player:target_NPC("Diandon")
CompleteQuestByName(questname)
local dailyQuestCount, dailyQuestsPerDay= RoMScript("Daily_count()");
if 10 == dailyQuestCount then
error("Dailys done for today. Ending script",2)
else
player:target_NPC("Diandon")
AcceptQuestByName(questname,questtype)
printf("Done "..dailyQuestCount.." of " .. dailyQuestsPerDay .. " Left " .. dailyQuestsPerDay - dailyQuestCount .. " Quests.");
end
player:moveTo(CWaypoint(-21663,-23233), true)
repeat
player:target_Object(questItemId)
until getQuestStatus(questname) == "complete"
end
end
-- End of functions
dlyExtinguishMoreFlames()
</onload>
</waypoints>
From this
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
questtype = "daily"
userepeat = false
questItemId = 119791;
questid = 425186;
questname = GetIdName(questid);
</onload>
<!-- # 1 --><waypoint x="-21567" z="-22960" y="597" type="TRAVEL">
player:target_NPC("Diandon")
CompleteQuestByName(questname)
local dailyQuestCount, dailyQuestsPerDay= RoMScript("Daily_count()");
if 10 == dailyQuestCount then
error("Dailys done for today. Ending script",2)
else
player:target_NPC("Diandon")
AcceptQuestByName(questname,questtype)
printf("Done "..dailyQuestCount.." of " .. dailyQuestsPerDay .. " Left " .. dailyQuestsPerDay - dailyQuestCount .. " Quests.");
end
__WPL:setDirection(WPT_FORWARD);
</waypoint>
<!-- # 2 --><waypoint x="-21663" z="-23233" y="597" type="TRAVEL">
repeat
player:target_Object(questItemId)
until getQuestStatus(questname) == "complete"
__WPL:setDirection(WPT_BACKWARD);
</waypoint>
</waypoints>
Re: waypoint stuff
Posted: Fri Aug 14, 2015 4:50 am
by rock5
I think you are missing some basics. The functions Lisa and Bill D Cat are providing can be put in an lua file and put into the userfunctions folder. Of course the name of the file needs to be valid. Then when the bot loads it will load those functions but all it will do is
create the functions, it wont
run them. So if you run the commandline waypoint file to start the command line then you can run those functions with the correct parameter.
If you want to run the functions without loading the bot (which is probably preferable as you don't need the bot to convert the waypoint file) then you can put the function in an lua file and place it in the scripts folder. In this case you would have to add a line after the function definition to run the function as well. Then you would run it from the mm prompt the same way you run the bot.
beanybabe wrote:If I am understanding this getElements the way you used it would not allow the line by line output of wp and code.
That's correct. It could return the contents of waypoints but I don't think it can return xml comments. But Lisa is right, it will be a bit tricky to make sure you parse the x, y and z values correctly. It should be possible though. Eg.
Code: Select all
local str = '<waypoint x="31978" z="-3441" y="1">'
local x = string.match(line,"x%s*=%s*\"(%-*%d*)")
local z = string.match(line,"z%s*=%s*\"(%-*%d*)")
local y = string.match(line,"y%s*=%s*\"(%-*%d*)")
local code = string.match(line,"<waypoint.->(.*)</waypoint>") or string.match(line,"<waypoint.->(.*)")
if x and z then
if y then
file:write("\tplayer:moveTo(CWaypoint("..x..", "..z..", "..y.."),true)\n")
else
file:write("\tplayer:moveTo(CWaypoint("..x..", "..z.."),true)\n");
end
if string.match(code,"[^%s]+") then
file:write(code)
end
else
file:write(line)
end
This should be able to handle spaces around the x, y, z and =. It then writes the moveTo command, or if it it not the waypoint line, then it writes the original line. It even writes any code on the same line as the waypoint info.
Re: waypoint stuff
Posted: Fri Aug 14, 2015 7:29 am
by rock5
Here is a more complete solution. Put it in the scripts folder.
Here is some example usage.
And here is the
test.xml file created.
Code: Select all
<waypoints>
player:moveTo(CWaypoint(-3689, -7952),true)
player:moveTo(CWaypoint(-3574, -8057),true)
player:moveTo(CWaypoint(-3478, -8003),true)
player:moveTo(CWaypoint(-3345, -7817),true)
player:restrnd(20, 2, 10);
player:moveTo(CWaypoint(-3179, -7874),true)
player:moveTo(CWaypoint(-2964, -7996),true)
player:moveTo(CWaypoint(-2754, -8183),true)
player:moveTo(CWaypoint(-2640, -7949),true)
player:harvest();
player:moveTo(CWaypoint(-2816, -7990),true)
player:moveTo(CWaypoint(-2940, -7957),true)
player:moveTo(CWaypoint(-3080, -7816),true)
player:moveTo(CWaypoint(-3207, -7829),true)
player:moveTo(CWaypoint(-3357, -7761),true)
player:moveTo(CWaypoint(-3410, -7627),true)
player:moveTo(CWaypoint(-3556, -7525),true)
player:moveTo(CWaypoint(-3670, -7448),true)
player:harvest();
player:moveTo(CWaypoint(-3750, -7594),true)
player:moveTo(CWaypoint(-3919, -7663),true)
player:moveTo(CWaypoint(-3861, -7817),true)
if( player.Level > 2 ) then
loadPaths("demo2");
end
</waypoint>
</waypoints>
Re: waypoint stuff
Posted: Fri Aug 14, 2015 8:10 am
by Bill D Cat
The script creates an output file that starts with <waypoints> but ends with </waypoint></waypoints>. This would give a run-time error.
This section probably needs to make sure that the variable "line" is not just </waypoint> before writing it to the output file.
Code: Select all
else
saveFile:write(line.."\n")
end
Re: waypoint stuff
Posted: Fri Aug 14, 2015 9:06 am
by rock5
Well I think this is what Beanybabe asked for. I don't think he expected an executable file. I think he intended to then copy and paste bits to where he needs them.
Re: waypoint stuff
Posted: Fri Aug 14, 2015 9:26 am
by Bill D Cat
True, but using it to convert a more complex file would end up making an output file that had numerous extraneous </waypoint> tags. Easy enough to do a search and replace to remove them.
Re: waypoint stuff
Posted: Fri Aug 14, 2015 9:52 am
by noobbotter
The main problem I see with this is if you use it to convert a waypoint file that has any "__WPL:setWaypointIndex()" commands in it, that wouldn't work. Also, how would it handle any waypoint reverse directions or travel types?
Re: waypoint stuff
Posted: Fri Aug 14, 2015 10:25 am
by beanybabe
Nice that worked I see the /waypoints but don't mind them they help show were routines were when I go to clean up the code.
It would have took me a year to figure that out. I spent a year getting my drill path working well.
Thanks Lisa Bill Rock now I can make some magic. some are a bit hard to convert that use reverse wp but I managed to get one done. Now to see how may different daily's I can convert. then it should it will be easy to call whichever daily is needed for any char.
Re: waypoint stuff
Posted: Fri Aug 14, 2015 10:36 am
by beanybabe
I open the files in side by side view in notepad++ and use its compare addon to help edit here is example.
Re: waypoint stuff
Posted: Thu Aug 20, 2015 11:16 pm
by beanybabe
reverse directions are pretty easy to handle.
i just use
While 1=1 do
wp 1
wp 2
i list the wp then list them again in reverse
wp 2
wp 1
and put some check if finished
end
This may not work to well for large wp but for ones with only only a few spots its easy.
Re: waypoint stuff
Posted: Thu Aug 20, 2015 11:23 pm
by beanybabe
Here is an example of Daily flameseed daily a custom version i created this if first time its been posted. original and converted it used _reverse originally
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="RUN">
<onload>
function dlyExtinguishMoreFlames()
questtype = "daily"
userepeat = false
questItemId = 119791;
questid = 425186;
questname = GetIdName(questid);
while true do
player:moveTo(CWaypoint(-21567,-22960), true)
player:target_NPC("Diandon")
CompleteQuestByName(questname)
local dailyQuestCount, dailyQuestsPerDay= RoMScript("Daily_count()");
if 10 == dailyQuestCount then
error("Dailys done for today. Ending script",2)
else
player:target_NPC("Diandon")
AcceptQuestByName(questname,questtype)
printf("Done "..dailyQuestCount.." of " .. dailyQuestsPerDay .. " Left " .. dailyQuestsPerDay - dailyQuestCount .. " Quests.");
end
player:moveTo(CWaypoint(-21663,-23233), true)
repeat
player:target_Object(questItemId)
until getQuestStatus(questname) == "complete"
end
end
-- End of functions
dlyExtinguishMoreFlames()
</onload>
</waypoints>
this is what it started as
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
questtype = "daily"
userepeat = false
questItemId = 119791;
questid = 425186;
questname = GetIdName(questid);
function doquest()
player:target_NPC("Diandon")
CompleteQuestByName(questname)
end
</onload>
<!-- # 1 --><waypoint x="-21567" z="-22960" y="597" type="TRAVEL">
doquest()
local dailyQuestCount, dailyQuestsPerDay= RoMScript("Daily_count()");
if 10 == dailyQuestCount then
error("Dailys done for today. Ending script",2)
else
player:target_NPC("Diandon")
AcceptQuestByName(questname,questtype)
printf("Done "..dailyQuestCount.." of " .. dailyQuestsPerDay .. " Left " .. dailyQuestsPerDay - dailyQuestCount .. " Quests.");
end
__WPL:setDirection(WPT_FORWARD);
</waypoint>
<!-- # 2 --><waypoint x="-21663" z="-23233" y="597" type="TRAVEL">
repeat
player:target_Object(questItemId)
until getQuestStatus(questname) == "complete"
__WPL:setDirection(WPT_BACKWARD);
</waypoint>
</waypoints>
Re: waypoint stuff
Posted: Thu Nov 26, 2015 3:18 pm
by beanybabe
Thanks again rock for this convert script. It really helps make coding easier for me.