waypoint stuff

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

waypoint stuff

#1 Post by beanybabe » Wed Aug 12, 2015 12:43 am

I got around this by making the wp into functions then just using code to detect were I was then run the function in that area make another function just for dailys if dailys are not done have it run do the daily near it or best xp daily.
function 1
fun 2
fun dly
are dailys not done then do fun dly
where am i
location 1 do fun 1
loc 2 do fun 2

Does anyone know how to make REGEX to use in Sublime Text to change this:
<!-- # 2 --><waypoint x="31978" z="-3441" y="1"> </waypoint>
----- into ----
player:moveTo(CWaypoint(31978,-3441), true)
Last edited by beanybabe on Wed Aug 12, 2015 2:03 am, edited 1 time in total.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: loadPaths() enhancement idea

#2 Post by beanybabe » Wed Aug 12, 2015 1:41 am

I have used that elf isle wp and know what you are taking about if it crashes restarting is about impossible. I got lazy and just made wp to have chars run kill all over till they got to 10 skipping all the quests if it crashed.

here is link to a script to renumber if anyone understands it it might be made to change the wp to be used in functions.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: loadPaths() enhancement idea

#3 Post by lisa » Wed Aug 12, 2015 2:21 am

beanybabe wrote: Does anyone know how to make REGEX to use in Sublime Text to change this:
<!-- # 2 --><waypoint x="31978" z="-3441" y="1"> </waypoint>
----- into ----
player:moveTo(CWaypoint(31978,-3441), true)
A little off topic but anyway.

Code: Select all

function convertWPtodatabase(_filename)

   if _filename == nil then print("Need to assign WP name.") end
   local root = xml.open(getExecutionPath() .. "/waypoints/".._filename..".xml");
   local elements = root:getElements();
   
   filename = getExecutionPath() .. "/database/".._filename..".xml";
   file, err = io.open(filename, "a+");
   file:write(_filename.."points = {\n")
   for i,v in pairs(elements) do
      local x,z,y = v:getAttribute("x"), v:getAttribute("z"), v:getAttribute("y");
      file:write("\t["..(i).."] = { X = "..x.." , Z = "..z..", Y = "..y.."},\n")
   end   
   
   file:write("}")
   file:close()
end

turns

Code: Select all

<!-- #  1 --><waypoint x="-1228" z="2314" y="251">   </waypoint>
   <!-- #  2 --><waypoint x="-1151" z="2318" y="251">   </waypoint>
   <!-- #  3 --><waypoint x="-1137" z="2167" y="250">   </waypoint>
   <!-- #  4 --><waypoint x="-1008" z="2186" y="246">   </waypoint>
into

Code: Select all

filename = {
   [1] = { X = -1228 , Z = 2314, Y = 251},
   [2] = { X = -1151 , Z = 2318, Y = 251},
   [3] = { X = -1137 , Z = 2167, Y = 250},
   [4] = { X = -1008 , Z = 2186, Y = 246},
}
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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: loadPaths() enhancement idea

#4 Post by beanybabe » Wed Aug 12, 2015 4:42 pm

lol I feel like i'm in preschool when i see such scripts. I tried few things to run it but it keep biting my hand.

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

Re: loadPaths() enhancement idea

#5 Post by Bill D Cat » Wed Aug 12, 2015 5:13 pm

You can try this variation on Lisa's code. It should do what you want.

Code: Select all

function convertWPstyle(_filename)

   if _filename == nil then print("Need to assign WP name.") end
   local root = xml.open(getExecutionPath() .. "/waypoints/".._filename..".xml");
   local elements = root:getElements();
   
   filename = getExecutionPath() .. "/waypoints/".._filename.."_converted.xml";
   file, err = io.open(filename, "a+");
   file:write(_filename.."points = {\n")
   for i,v in pairs(elements) do
      local x,z,y = v:getAttribute("x"), v:getAttribute("z"), v:getAttribute("y");
      if x ~= nil and z ~= nil then
        file:write("\tplayer:moveTo(CWaypoint("..x..", "..z.."),true)\n");
      end
   end   
   file:write("}\n")
   file:close()
end

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: loadPaths() enhancement idea

#6 Post by lisa » Wed Aug 12, 2015 6:35 pm

beanybabe wrote:lol I feel like i'm in preschool when i see such scripts. I tried few things to run it but it keep biting my hand.
ok I shall break it down for you, then maybe you will be able to use it for exactly what you are after.

function convertWPtodatabase(_filename)

if _filename == nil then print("Need to assign WP name.") end
--checks if there is anything in argument for the function.

local root = xml.open(getExecutionPath() .. "/waypoints/".._filename..".xml");
-- this will open the specified xml file and the information in that file is now called root

local elements = root:getElements();
-- this is a function in the bot which goes through root and splits up the specific details such as X Y Z values

filename = getExecutionPath() .. "/database/".._filename..".xml";
--this will open or create the file in database folder

file, err = io.open(filename, "a+");
-- this opens that file in database folder and tells it to replace any info in that file (a+)

file:write(_filename.."points = {\n")
-- just adds some info to start so that a table is returned when the file is used

for i,v in pairs(elements) do
--this will go through every line in elements, which is the original xml file with the values split up

local x,z,y = v:getAttribute("x"), v:getAttribute("z"), v:getAttribute("y");
-- x,z,y are now the values of the x z y that was on that line in the original xml file

file:write("\t["..(i).."] = { X = "..x.." , Z = "..z..", Y = "..y.."},\n")
--we write thos values to the new file in the format that we want them in

end

file:write("}")
--just to finish off the table format

file:close()
-- close the new file since we are done adding to it

end
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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: loadPaths() enhancement idea

#7 Post by lisa » Wed Aug 12, 2015 6:41 pm

As for running the function, it needs to be a userfunction in the bot, start bot with commandline and then use the function in commandline with the argument as the name of the waypoint file you want to convert.

I did post this hoping it would give you an idea of how to do what it is you are actually trying to do, as opposed to just doing all the code for you ;)
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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: loadPaths() enhancement idea

#8 Post by beanybabe » Wed Aug 12, 2015 10:10 pm

Did it need to be in a certain folder I have the wp in a sub folder. I tried putting the full path to them including the name. I tried to edit it and change it without the path info you were adding. It looks lke you made it so the wp needed to be in wp folder if im reading it correct. I was asking about regex I thought it would be easy to use with the find and replace. Ive not done much with regex but renaming files.

I did this
sub()
end

sub("path/file.name.xml")

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: loadPaths() enhancement idea

#9 Post by lisa » Wed Aug 12, 2015 10:21 pm

beanybabe wrote:Did it need to be in a certain folder I have the wp in a sub folder. I tried putting the full path to them including the name. I tried to edit it and change it without the path info you were adding. It looks lke you made it so the wp needed to be in wp folder if im reading it correct. I was asking about regex I thought it would be easy to use with the find and replace. Ive not done much with regex but renaming files.
I know that you asked about REGEX but I assume this isn't a once off and you probably want to do more files later if not now. So set up a function to do it for you, that function creates a new file in database with the same name as the one in the rom/waypoints folder, you can then just open it and copy the code you wanted into your waypoint.

But as I said I was mainly trying to show you how to get the information you wanted so that you can then work out what you want to do with it. In the code I posted it literally gives you the x z y values to use how ever you wanted.
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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: loadPaths() enhancement idea

#10 Post by beanybabe » Wed Aug 12, 2015 10:26 pm

I just got the idea for this when bill was asking about his elf island scripts. If this worked I was going to see if they could be converted to functions and make them easier to crash recover. I thought if i had one file with the converted and one original then open them side by side in editor.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: waypoint stuff

#11 Post by beanybabe » Wed Aug 12, 2015 10:43 pm

2015-08-12 22:39:12 - Cannot open file 'C:/micromacro/scripts/waypoints/EI_01_In
TheValley.xml' for reading. here is what happens when I try to run it omg I think I see what im doing wrong. I've never coded for micromacro and did not understand what you were showing me.


I see it had to be in the script folder. I usually wrap the code in xml so I can just run it from rombot.

here is what i was trying now i get why it was not working.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
function convertWPtodatabase(_filename)
   if _filename == nil then print("Need to assign WP name.") end
   local root = xml.open(getExecutionPath() .. "/waypoints/".._filename..".xml");
   local elements = root:getElements();
   filename = getExecutionPath() .. "/database/".._filename..".xml";
   file, err = io.open(filename, "a+");
   file:write(_filename.."points = {\n")
   for i,v in pairs(elements) do
      local x,z,y = v:getAttribute("x"), v:getAttribute("z"), v:getAttribute("y");
      file:write("\t["..(i).."] = { X = "..x.." , Z = "..z..", Y = "..y.."},\n")
   end   
   file:write("}")
   file:close()
end
convertWPtodatabase("C:\micromacro\scripts\rom\waypoints\ElvenIsland 1-class hall\EI_01_InTheValley.xml")
</onload> 
</waypoints>

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: waypoint stuff

#12 Post by lisa » Wed Aug 12, 2015 11:10 pm

what you did could work but do this

Code: Select all

convertWPtodatabase("ElvenIsland 1-class hall\EI_01_InTheValley")
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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: waypoint stuff

#13 Post by beanybabe » Thu Aug 13, 2015 12:04 am

I still must not be understanding.

I copied the script named it convertWPtodatabase.lua and put it in the micromacro/scripts folder

i run StartCommandLine.bat

and enter convertWPtodatabase error
enter convertWPtodatabase.lua fail it says it is running but i never get a message it needs filename to run
enter convertWPtodatabase.lua EI_01_InTheValley fail i moved it to waypoints folder to get rid of extra path

I tried it with (EI_01_InTheValley) ("EI_01_InTheValley") () ("") none worked

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: waypoint stuff

#14 Post by beanybabe » Thu Aug 13, 2015 12:22 am

I looked in the forum under micro macro and there is no explanation there were to put the scripts. this is getting to hard. if it can just open all the files inside the folder and convert them in place that would be simpler. I cannot even figure what the output file is going to be of your code it does not seem to be set. Would it be easier to make it work like the logplayer function does and just change things in place ?

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: waypoint stuff

#15 Post by beanybabe » Thu Aug 13, 2015 1:47 am

ok I've read both your code and did a compare of them to try to grasp the difference then read lisa's explanation. Now I need to sleep on it. I am just confused how that can work. i've only done sequential file i/o in Basic, trying to fit what that is doing between my ears is gonna take time.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: waypoint stuff

#16 Post by lisa » Thu Aug 13, 2015 3:17 am

ok lets try to make it "less" complicated.

Code: Select all

local str = '<waypoint x="31978" z="-3441" y="1">' 
local x = string.match(str,"x=\"(.*)\" z")
local z = string.match(str,"z=\"(.*)\" y") 

print("player:moveTo(CWaypoint("..x..", "..z.."),true)")

player:moveTo(CWaypoint(1978, -3441),true)

The trouble with this sort of coding is the format needs to be exactly the same, x=" has to be the same with no spaces or anything, then " z" has to be the same and also " y has to be the same. If the cords are made by rom/createpath then it should be exactly the same every time.

ok explanation time.
string.match('lol I love cords and I am a string,','I(.*)cords')

first argument is any string, in this case:
lol I love cords and I am a string

second argument is what you are looking for:
it first looks for I
and then the (.*) means any number of characters and any type of characters until it finds
cords

the string returned in this case is all the stuff in between I and cords

Some light reading here
http://lua-users.org/wiki/PatternsTutorial
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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: waypoint stuff

#17 Post by beanybabe » Thu Aug 13, 2015 5:17 am

tried to make this do something this is all I get. I even made it into a userfunction and called it from rom/bot with no luck It just does not seem to run.

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> convertWPtodatabase (EI_01_InTheValley)
Opening convertWPtodatabase.lua...
Starting script execution - Press CTRL+C to exit.
Press CTRL+L to cancel execution and load a new script.
----------------------------------------------------------
Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> convertWPtodatabase EI_01_InTheValley tried it without braces.
Opening convertWPtodatabase.lua...
Starting script execution - Press CTRL+C to exit.
Press CTRL+L to cancel execution and load a new script.

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> convertWPtodatabase started it with no file
Opening convertWPtodatabase.lua...
Starting script execution - Press CTRL+C to exit.
Press CTRL+L to cancel execution and load a new script

looking at the code no file should have gave a error message but I see none

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

Re: waypoint stuff

#18 Post by Bill D Cat » Thu Aug 13, 2015 6:13 am

To use the script I provided, you put it in the rom/userfunctions/ folder and name it whatever you want. It's the function name that matters. Then, start the commandline.lua and enter something like this:

Code: Select all

convertWPstyle("ElvenIsland/EI_01_InTheGrove")
The script will append the RoMBot execution path and waypoints folder name to the beginning, and the .xml extension to the end to form the complete path and filename.

Code: Select all

local root = xml.open(getExecutionPath() .. "/waypoints/".._filename..".xml");

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

Re: waypoint stuff

#19 Post by Bill D Cat » Thu Aug 13, 2015 6:15 am

beanybabe wrote:tried to make this do something this is all I get. I even made it into a userfunction and called it from rom/bot with no luck It just does not seem to run.

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> convertWPtodatabase (EI_01_InTheValley)
Opening convertWPtodatabase.lua...
Starting script execution - Press CTRL+C to exit.
Press CTRL+L to cancel execution and load a new script.
In this case, since you did not include the quotes around EI_01_InTheValey, the script was trying to interpret it as a variable and not a literal string.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: waypoint stuff

#20 Post by beanybabe » Thu Aug 13, 2015 9:34 am

I did this with lisa's code to try to run it as a userfunction I added the file close and shortened the name, but this did not seem to work. I will give your's a try I tried it as script with no luck.

Code: Select all

function convertwp(_filename)
	if _filename == nil then print("Need to assign WP name.") end
		local root = xml.open(getExecutionPath() .. "/waypoints/".._filename..".xml");
		local elements = root:getElements();
   		filename = getExecutionPath() .. "/database/".._filename..".xml";
		file, err = io.open(filename, "a+");
		file:write(_filename.."points = {\n")
		for i,v in pairs(elements) do
			local x,z,y = v:getAttribute("x"), v:getAttribute("z"), v:getAttribute("y");
			file:write("\t["..(i).."] = { X = "..x.." , Z = "..z..", Y = "..y.."},\n")
		end   
   		file:close()
end

Post Reply

Who is online

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