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
➜ General
➜ Looking in the wrong directory.
Looking in the wrong directory.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Daved
(12 posts) Bio
|
Date
| Wed 08 Dec 2010 03:08 AM (UTC) |
Message
| So for over a year now I've had this filepath in the Start in: field on my MUSHClient shortcut:
"C:\Users\David Volin\Documents\Aetolia\AMTS"
It's been working perfectly. Today, I started working on a new module. As soon as I went to require said module, this happened:
Run-time error
World: AMTS
Immediate execution
.\main.lua:13: module 'queue' not found:
no field package.preload['queue']
no file '.\queue.lua'
no file 'C:\Program Files\MUSHclient\lua\queue.lua'
no file 'C:\Program Files\MUSHclient\lua\queue\init.lua'
no file 'C:\Program Files\MUSHclient\queue.lua'
no file 'C:\Program Files\MUSHclient\queue\init.lua'
Why did it suddenly start looking in the wrong directory on me? The filepath in Start in: is still the same | Top |
|
Posted by
| Seriley
(42 posts) Bio
|
Date
| Reply #1 on Wed 08 Dec 2010 04:01 AM (UTC) |
Message
| There is probably an easier solution, but I use the following two lines at the top of each main script file:
Dir, _ = string.gsub (GetInfo (35),"[%a_]+%.lua","")
package.path = package.path .. ";" .. Dir .. "?.lua"
It adds the directory that my script file resides in to the search path, which may be different that the directory MushClient is starting in.
Of course it requires that I put the files I want to require in the main script file's directory. | Top |
|
Posted by
| Daved
(12 posts) Bio
|
Date
| Reply #2 on Wed 08 Dec 2010 04:30 AM (UTC) |
Message
| Do I just add that to the top of the file I see when I enter the scripts menu? | Top |
|
Posted by
| Seriley
(42 posts) Bio
|
Date
| Reply #3 on Wed 08 Dec 2010 04:35 AM (UTC) |
Message
| Yes.
If you use anything in your script file name except letters and the underscore then the pattern, "[%a_]+ will need to be modified. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #4 on Wed 08 Dec 2010 05:00 AM (UTC) |
Message
| You should be fine with [%d_ ]+ . It just allows for digits and spaces too. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Daved
(12 posts) Bio
|
Date
| Reply #5 on Wed 08 Dec 2010 05:16 AM (UTC) |
Message
| I put
Dir, _ = string.gsub (GetInfo (35),"[%d_]+%.lua","")
package.path = package.path .. ";" .. Dir .. "?.lua"
and got this error now:
no file 'C:\Users\David Volin\Documents\Aetolia\AMTS\Aevon.luaqueue.lua'
The main script file is called Aevon.lua and it is at
'C:\Users\David Volin\Documents\Aetolia\AMTS\Aevon.lua'
looks like it just concatenated queue.lua to its name, queue.lua is at
'C:\Users\David Volin\Documents\Aetolia\AMTS\queue.lua'
| Top |
|
Posted by
| Seriley
(42 posts) Bio
|
Date
| Reply #6 on Wed 08 Dec 2010 05:26 AM (UTC) |
Message
| That should be [%a_]+. What it's doing is getting rid of the filename so you just have the path. [%d_]+ would only remove something like 3_45678.lua. I'm leaving off the rest of the pattern there... the full pattern has %.lua attached.
Sorry if I confused you earlier. | Top |
|
Posted by
| Seriley
(42 posts) Bio
|
Date
| Reply #7 on Wed 08 Dec 2010 05:29 AM (UTC) |
Message
| You may want to look at the output of GetInfo(35) so you can see what you are trying to do.
On my muds, I use / to denote a script command on the command line so I would enter /Note(GetInfo(35)) at the command line.
All we are trying to do is to remove the last bit of the path so we only have the directory, then add that direction to our 'search path'. | Top |
|
Posted by
| Seriley
(42 posts) Bio
|
Date
| Reply #8 on Wed 08 Dec 2010 05:48 AM (UTC) |
Message
| If your script file name also has spaces and/or digits, then
just use [%w%s_]+. '%w' is alphanumeric (letters and digits), %s is spaces, and the _ underscore. | Top |
|
Posted by
| Daved
(12 posts) Bio
|
Date
| Reply #9 on Wed 08 Dec 2010 05:50 AM (UTC) |
Message
| Got it, works now, thank you :) | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #10 on Wed 08 Dec 2010 07:00 AM (UTC) |
Message
| Yeah, oops, that was my fault. I meant %w, as you can tell by my original explanation. %d only matches digits. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | 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.
29,342 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top