Page 1 of 1

Waypointlist FileName

Posted: Thu Apr 19, 2012 9:05 am
by dx876234
Hi, I'm suggesting a minor change to classes/waypointlist.lua.

Currently the waypointlist store the filename only in the FileName field, this works as long as u put all your waypoints in the waypoints directory but I like to organize in subdirectories for my larger boots.

So Id like to suggest to include the subdirectories below the waypoints directory, i.e. instead of just storing "mywaypoint.xml" we store "mysubdir/mywaypoint.xml" when subdirectories is used.

The change is in classes/waypointlist.lua approx line 44, use:

Code: Select all

self.FileName = filename:gsub(getExecutionPath() .. "/waypoints/", "")
instead of

Code: Select all

self.FileName = getFileName(filename)

Re: Waypointlist FileName

Posted: Thu Apr 19, 2012 9:30 am
by rock5
So let me see if I understand. The problem is when you use

Code: Select all

loadPaths(__WPL.FileName)
for instance, like I've started doing in some of my files, it looks in the wrong folder?

Good catch.

Does your solution mean that it will have the whole path in the FileName variable? Not sure I like that. Wonder why it doesn't save the folder already. I'll look into.

Re: Waypointlist FileName

Posted: Thu Apr 19, 2012 10:06 am
by rock5
BTW I didn't know you could use gsub as a function of a variable like that. Interesting.

Anyway, I was just thinking we could just as easily use

Code: Select all

self.FileName = filename
to get the same results.

But what I would prefer is a result like "mysubdir/mywaypoint.xml". The problem is getFileName (which I can find no other reference to) extracts just the file name. I guess we could parse the filename variable to extract everything between "waypoints/" and the end of file.

This seems to work.

Code: Select all

self.FileName = string.match(filename,"waypoints/(.*)");
I'm happy with that.

Re: Waypointlist FileName

Posted: Thu Apr 19, 2012 3:23 pm
by dx876234
The waypointlist load function is called from loadPaths in functions.lua which converts the filename from a name relative to the waypoints directory with:

Code: Select all

local filename = getExecutionPath() .. "/waypoints/" .. _wp_path;
So, if u use

Code: Select all

self.FileName = filename
you will end up will a full path in the FileName field which is not compatible with any1 using this field.

The current

Code: Select all

self.FileName = getFileName(filename)
makes a filename relative to the waypoints directory, and my suggested

Code: Select all

self.FileName = filename:gsub(getExecutionPath() .. "/waypoints/", "")
will do the same, i.e. a path relative to waypoints directory but including any subdirectories in the waypoints directory.

regards
DX

P.S the getFileName is from micromacro and strips the path from the argument, i.e. returns only filename.

P.S the function of a variable isnt much more than a shorthand of writing

Code: Select all

string.gsub(filename,....)
the colon specifies that first argument is the variable itself which is used to have a objectoriented call syntax.

Re: Waypointlist FileName

Posted: Fri Apr 20, 2012 12:04 am
by rock5
If I print filename:gsub(getExecutionPath() .. "/waypoints/", "") I get

Code: Select all

C:/Program Files (x86)/micromacro/scripts/645/waypoints/test/test.xml
If I print filename I get

Code: Select all

C:/Program Files (x86)/micromacro/scripts/645/waypoints/test/test.xml
They look the same to me and your right neither of them work.

This on the other hand this works fine. :D

Code: Select all

string.match(filename,"waypoints/(.*)")
This is what I used to test it with by the way,

Code: Select all

<waypoints>
<onLoad>
	print(__WPL.FileName)
	loadPaths(__WPL.FileName)
</onLoad>
</waypoints>

Re: Waypointlist FileName

Posted: Fri Apr 20, 2012 12:21 am
by dx876234
Hehe, damn good u take time to QA - your solution is excactly what I intended and actually works which mine didn't quite do :)

This will enable subdirectories used in waypoints directory and reflected in the FileName field.

regards
DX