Waypointlist FileName

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Waypointlist FileName

#1 Post 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)
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Waypointlist FileName

#2 Post 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.
  • 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
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Waypointlist FileName

#3 Post 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.
  • 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
dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Waypointlist FileName

#4 Post 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.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Waypointlist FileName

#5 Post 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>
  • 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
dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Waypointlist FileName

#6 Post 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
Post Reply