Hello,
I was trying to require a file trough command prompt, which the path is "C:\Source\File.lua", but it isn't working, and I can't find a solution anywhere.
I tried this:
require("..\\..\\Source\\File")
This:
require([[..\..\Source\File]])
And this:
require([[..\..\Source\File.lua]])
None of them worked, they say it couldn't find the file, but if I move it, for example, to desktop, it works fine.
Thank you.
For require the Lua interpreter uses package.path. And when you add the path to your require in the right manner you dont need the .lua suffix for require().
Example extending package path in lua console
# cp koys.lua /tmp/
# lua5.3
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> package.path=package.path..';/tmp/?.lua'
> koys=require('koys')
> koys
table: 0x565a7120