lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

 
On 30 April 2014 10:32, Thijs Schreijer <thijs@thijsschreijer.nl> wrote:

Depending on the type of system, it requires that a filesystem is present and you need to point the LUA_PATH environment variables to your USB location.

According to your example, below the module (in file_y) and program (in file_x)

file_y.lua
==========
local M = {}  -- define module table

M.func_y = function()    -- define function inside module table
   print("func_y was called")
end

return M    -- return module table

file_x.lua
==========
local file_y = require("file_y")   -- load your module

local func_x = function()
   file_y.func_y()   -- call the function in the other module
   print("func_x was called")
end

-- here is where your program starts
func_x()  -- call func_x


Your example is perfect.
I added:
 
package.path = "0:"
 
at the beginning of each file because the USB stick root, where the files
are stored, is seen as "0:".
 
By the way I get an "attempt to call a nil value" error message.
Do I have to set the LUA_PATH in a different way?
Or is there something else going wrong?
Thanks,
I.
 

--
"Don't find fault, find a remedy" (H.Ford)
-------------------------------------------------------------------------
"Beer is proof that God loves us and wants us
to be happy" (Benjamin Franklin)
-------------------------------------------------------------------------