I am trying to create an array which references exported variables from another resource however it seems that the call to the function is actually invoked rather than being saved as a reference to the variable.
-- Array of functions we want to have a reference to, includes exported functions from other resources.
local myFunctions = {
["FUNCTION_1"] = exports.myresource:myFunction,
["FUNCTION_2"] = exports.myresource:anotherFunction,
["FUNCTION_3"] = getElementPosition,
["FUNCTION_4"] = exports.myresource:finalFunction,
}
function executeFunctions(functionList, parameter)
for i, func in ipairs(functionList) do -- For every function we need to call.
functionToInvoke = myFunctions[func] -- Get the function reference from our array.
functionToInvoke(parameter) -- Invoke the function and pass the parameter into it.
end
end
executeFunctions({"FUNCTION_1", "FUNCTION_4"}, "some parameter value") -- Call executeFunctions() to recursively execute function 1 and 4 with our parameter.
While myFunctions["FUNCTION_3"] works and references the native getElementPosition function, the references to exported functions don't work.
Is this possible at all?