REQUIRE
Module: _require
The _script.Run function runs another Lua file and returns whatever that file returns.
Paths are relative to the plugin directory but you can import from other plugins using @pluginName/
See example
Consider we have these scripts:
./MyPlugin/
-| _init.lua
-| data.lua
---| dirA/
-----| dirB/
-------| plugin.lua
-------| worker.lua
./lib/
-| _init.lua
-| common.lua
Example:
ProjectGWN/mods/scripts/MyPlugin/dirA/dirB/plugin.lua
-- Load "./MyPlugin/data.lua"
local data = _require.Script("data")
-- Load "./MyPlugin/dirA/dirB/worker"
local worker = _require.Script("dirA/dirB/worker")
local worker.start()
-- Load files from other plugins ./lib/common
local lib = _require.Script("@lib/common")
lib.doWork()
Import(Data:
)
()
2
)
() _require.Import(Data: any) ->
Export(Data:
)
()
3
)
() _require.Export(Data: any) ->
GetResourceName()
(ReturnValue:
)
4
(ReturnValue:
) _require.GetResourceName() -> ReturnValue: any
Run(Filename:
)
(Content:
)
5
)
(Content:
) --[=[Path without extension
Run file and return content]=]
_require.Run(Filename: string) -> Content: any