Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ Lua: making require work as one might expect
|
Lua: making require work as one might expect
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Worstje
Netherlands (899 posts) Bio
|
| Date
| Tue 16 Sep 2008 07:36 PM (UTC) Amended on Wed 17 Sep 2008 05:46 AM (UTC) by Worstje
|
| Message
| For a while I've been bothered by Lua. When I require something, I generally want it to check the directory with my plugin.xml first, and other directories at a later stage. The 'current directory' is rather useless due to the fact that it changes depending on user activity and can't garantuee any relationship to the files you are including. I was finally bothered enough to find out how to solve this little annoyance of mine, and hopefully other people will find it useful too.
-- Adjusted to match WillFa's improvement comment below.
plugin_path = string.match(world.GetPluginInfo(world.GetPluginID(), 6), "(.*\\).*$")
package.path = plugin_path .. "?;" .. plugin_path .. "?.lua;" .. package.path
require "something"
| | Top |
|
| Posted by
| WillFa
USA (525 posts) Bio
|
| Date
| Reply #1 on Wed 17 Sep 2008 04:59 AM (UTC) |
| Message
| A RegExp of "^(.+\\).-$" should cleaner and not require the concatenation op.
Thanks! I was irked by this too and never gave the thought on how to fix it. :) | | Top |
|
| Posted by
| Worstje
Netherlands (899 posts) Bio
|
| Date
| Reply #2 on Wed 17 Sep 2008 05:43 AM (UTC) |
| Message
| Bah, just noticed the forums unescaped my backslashes. I'll try to fix that in my original post in a moment.
And yeah, true. Don't know why I didn't do the regular expression like that - probably because I figured Lua's expressions wouldn't like it for some reason. Thanks for minor improvement. ^_^ | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
11,049 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top