For more details about the GUI environment, refer to the Eagle Dynamics documentation:
C:\Program Files\Eagle Dynamics\DCS World\API\DCS_ControlAPI.md
To use Pelican in the GUI environment, create a Lua script in the following directory:
%USERPROFILE%\Saved Games\DCS\Scripts\Hooks
This script must include the DLL path in Lua’s package.cpath
so it can load the Pelican module.
DCS World will automatically run all Lua scripts in this folder at startup.
Create a Lua file named PelicanTestGameGUI.lua
with the following content:
-- %USERPROFILE%\Saved Games\DCS\Scripts\Hooks\PelicanTestGameGUI.lua
package.cpath = package.cpath .. ";" .. lfs.writedir() .. "\\Mods\\tech\\Pelican\\bin\\?.dll"
PELICAN = { logger_level = "debug" }
local status, ____pelican = pcall(require, "pelican")
if not status then
log.write("PELICAN", log.ERROR, "Failed to load Pelican: " .. tostring(____pelican))
return
else
log.write("PELICAN", log.INFO, "Pelican loaded successfully")
end
local logger = ____pelican.logger
local my_logger = logger.Logger.new("PELICAN.GUI")
my_logger:info("Pelican Running...")
local jsonrpc = ____pelican.jsonrpc
local server = jsonrpc.JsonRpcServer.new({ host = "127.0.0.1", port = 1234 })
local router = jsonrpc.JsonRpcRouter.new()
router:add_method(
"ping",
function(params)
local param = params[1]
return { message = "pong " .. param }
end
)
local user_callbacks = {}
function user_callbacks.onSimulationFrame()
local result, err = server:process_rpc(router)
if not result then
log.error("PELICAN", log.INFO, "RPC error: " .. tostring(err))
end
end
log.write("PELICAN", log.INFO, "Scheduling user callbacks for simulation frame processing...")
DCS.setUserCallbacks(user_callbacks)
To test the RPC server, run this command in the terminal:
curl --location 'http://localhost:1234/rpc' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "ping",
"params": [1],
"id": "1"
}'
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"message": "pong 1"
}
}
You can also check the server's health endpoint at:
http://localhost:1234/health