I’m assuming that you have a table called data in your data module.
If you just do:
local function doSomething()
return something
end
That function is local to that module only can can’t be accessed outside of it. To make a function available in another module it has to be a member of the table that gets returned. You can do that one of two ways:
local M = {} – my module table
local function doSomething()
return something
end
M.doSomething = doSomething
In that form, you create a local function and assign the pointer to the function to the table. In the second form:
function M.doSomething()
return something
end
You directly assign the function to the table (in effect creating an anonymous function, but the result is the same to the caller).
The code you posted for the first one isn’t doing this. You create a local function but in the next line you’re assigning the function to itself:
data.returnMyDefeatedEnemies = data**.**returnMyDefeatedEnemies
At this point data.returnMyDefetedEnemies is nil since you made a function without the data. piece local above. In effect no function. I’m not sure how the second one is compiling at all. You can’t local a table method like that. Presumably you’ve already done:
local data = {}
so after that you just have to do:
data.functionName = whatever.
This should be throwing an error.
Rob