ImportPackage

From Onset Developer Wiki
Revision as of 20:48, 31 July 2019 by BlueMountains (talk | contribs) (Created page with "{{Info|Function|Server & Client|1.0}} {{FuncDescription|Creates a table holding all exported functions by another package.}} {{FuncSyntax|ImportPackage(PackageName)}} {{Fun...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
ImportPackage

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

Description

Creates a table holding all exported functions by another package.

Syntax

ImportPackage(PackageName)

Parameters

  • PackageName
    Name of the package to import. Must be loaded before this one.

Return Value

  • Creates a table holding the other packages exported functions. Return nil if PackageName does not exist.

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

AddFunctionExport