Pelican - v0.0.7
    Preparing search index...

    Mission Scripting Environment

    For more details about the Mission Scripting Environment (MSE), refer to the Eagle Dynamics documentation:

    https://www.digitalcombatsimulator.com/en/support/faq/1249/


    ⚠️ The MSE sanitizes the Lua environment, disabling package, require, and other functions for security reasons.

    Pelican usage in the MSE depends on when and how your Lua code runs relative to the DCS sanitization process. Choose one of the following approaches:


    Use dofile to load your script (using pelican) before DCS sanitizes the environment.

    Use Case: Ideal for scripts that should run globally across all missions—such as sidecars for data extraction, dynamic weather, or general purpose AI control.

    Example Scenario:

    • Running an HTTP backend for a web client showing player locations.
    • Implementing reusable logic across missions.

    Pros:

    • ✅ Keeps require and package disabled after setup (maintains DCS security).
    • ✅ Global effect—only needs to be set up once.
    • ✅ No modification to mission files needed.

    Cons:

    • ⚠️ Runs across all missions, which may be unnecessary for mission-specific logic.

    See option 1 documentation for details.


    Manually edit MissionScripting.lua to re-enable require and package inside mission scripts.

    Use Case: Required when Pelican is used within mission-embedded scripts that must call require.

    Example Scenario:

    • Using Pelican and SQLite for persistent mission data.

    Pros:

    • ✅ Enables full Lua module functionality within mission scripts.

    Cons:

    • ⚠️ Introduces potential security risks.
    • ⚠️ Not recommended for multiplayer or untrusted missions.

    See option 2 documentation for details.


    Regardless of the approach, your Lua script must set the DLL path correctly before requiring Pelican.

    Here’s a minimal example of a Pelican-powered Lua script that starts a JSON-RPC server:

    -- %USERPROFILE%\Saved Games\DCS\Scripts\PelicanTestMission.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
    env.error("Failed to load Pelican: " .. tostring(____pelican))
    return
    else
    env.info("Pelican loaded successfully")
    end

    local logger = ____pelican.logger

    local my_logger = logger.Logger.new("PELICAN.MISSION")

    my_logger:info("Pelican Running...")

    local jsonrpc = ____pelican.jsonrpc

    local server = jsonrpc.JsonRpcServer.new({ host = "127.0.0.1", port = 1235 })
    local router = jsonrpc.JsonRpcRouter.new()

    router:add_method(
    "ping",
    function(params)
    local param = params[1]
    return { message = "pong " .. param }
    end
    )

    timer.scheduleFunction(
    function(arg, time)
    local result, err = server:process_rpc(router)
    if not result then
    env.error("RPC error: " .. tostring(err))
    end

    return timer.getTime() + .01
    end,
    nil,
    timer.getTime() + .01
    )

    Use the following curl command to test your Pelican server:

    curl --location 'http://localhost:1235/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 verify the server is running by visiting:

    http://localhost:1235/health