[JW Lua] Using library functions in Console
Aaron Sherber
aaron at sherber.com
Wed Jan 3 18:22:54 CET 2024
Hi Robert,
Some of this comes down to user setup. I have the repo cloned locally, and
I have the src folder set up as an auto folder, so all of the repo scripts
show up as menu items, and they work just fine.
But the little scripts I'm writing for the console I'm keeping in a
separate folder, so in order to access library methods I need to manually
add the src folder to the package path, so that "library.general_library"
correctly resolves to the src/library folder.
(And yes, in general you can use forward slashes in paths from the Windows
command line as well.)
Thanks,
Aaron.
On Wed, Jan 3, 2024 at 11:09 AM Robert Patterson <
robert at robertgpatterson.com> wrote:
> As you mentioned, a little-known Windows fact is that you can use "/" in
> file paths, at least inside programs. (I'm not sure about the command line,
> since it uses "/" for options, which is why we have "\" to begin with.) I
> worked professionally on DOS and Windows systems for nearly 30 years and
> never knew it until a year or so ago.
>
> When you run a script in the Console, it should run in the identical
> environment that it would run from a menu. You should not need to set
> anything up differently. Let me know if that was not your experience.
>
>
>
>
>
> On Sun, Dec 31, 2023 at 2:48 PM Aaron Sherber <aaron at sherber.com> wrote:
>
>> My bad -- I neglected to double the backslashes in the path on Windows.
>> Using single forward slashes also works.
>>
>> So in my case, this lets me do what I want:
>>
>> package.path = package.path ..
>> ";c:\\users\\aaron\\documents\\projects\\lua-scripts\\src\\?.lua"
>>
>> Aaron.
>>
>>
>>
>>
>> On Sun, Dec 31, 2023 at 12:51 PM Aaron Sherber <aaron at sherber.com> wrote:
>>
>>> Hi all,
>>>
>>> What's the correct way to configure things so that I can call library
>>> functions from the Console? Ideally, I'd like to be able to use the same
>>> syntax in Console scripts that I currently do while developing scripts for
>>> the repo (e.g., local library = require("library.general_library")).
>>>
>>> I've got the repo cloned locally, and I've tried adding both the src
>>> path and the src/library path to package.path in the RGP Lua System Prefix
>>> dialog, but that hasn't worked for me.
>>>
>>> Thanks,
>>> Aaron.
>>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20240103/54ff9534/attachment.htm>
More information about the JWLua
mailing list