在 DCS World 的 Mods 目录下,Olympus 以插件形式加载,Lua 脚本(如 entry.lua)声明插件并初始化。
主要 Lua 脚本(如 OlympusCommand.lua)负责加载 DLL,并通过 require("olympus") 或 package.loadlib 方式调用 C++ 导出的 Lua C API。
entry.lua
local self_ID ="DCS-Olympus"declare_plugin(self_ID,{
image ="Olympus.png",
installed =true,-- if false that will be place holder , or advertising
dirName = current_mod_path,
binaries ={
-- 'Olympus',},
load_immediately =true,
displayName ="Olympus",
shortName ="Olympus",
fileMenuName ="Olympus",
version ="{
{OLYMPUS_VERSION_NUMBER}}",
state ="installed",
developerName="DCS Refugees 767 squadron",
info =_("DCS Olympus is a mod for DCS World. It allows users to spawn, control, task, group, and remove units from a DCS World server using a real-time map interface, similarly to Real Time Strategy games. The user interface also provides useful informations units, like loadouts, fuel, tasking, and so on. In the future, more features for DCS World GCI and JTAC will be available."),
Skins ={
{
name ="Olympus",
dir ="Theme"},},
Options ={
{
name ="Olympus",
nameId ="Olympus",
dir ="Options",
CLSID ="{Olympus-options}"},},})plugin_done()
DLL 导出接口
C++ 侧通过 extern "C" DllExport int luaopen_olympus(lua_State *L) 导出模块初始化函数,供 Lua 加载。