AddFunctionExport

From Onset Developer Wiki
AddFunctionExport

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Exports a function that can later be imported from another package.

Syntax

AddFunctionExport(ExportName, ExportFunction)

Parameters

  • ExportName
    Name of the export. Commonly the name of the exported function.
  • ExportFunction
    Function to export.

Return Value

  • Returns true on success. Return false if the export already exists.

Example

Package Test1

function UsefulFunc(param1, param2)
    return param1 + param2
end
AddFunctionExport("UsefulFunc", UsefulFunc)

Package Test2

test = ImportPackage("Test1")

print(test.UsefulFunc(2, 2))

ImportPackage should only be called once in a package. The returned table is valid until package unload.

See also

ImportPackage