ltsteamplugin Lua Plugin

repository·main·Indexed 42 days ago

https://github.com/madoiscool/ltsteamplugin

A Lua plugin for the Millennium loader that provides an RPC bridge to the LuaTools desktop application. It manages the injection of luatools.js and steamdb-webkit.css into the browser context and implements lifecycle hooks including on_load, on_unload, and on_frontend_loaded.

Tokens
627
Snippets
2
Records
3
Agent score
5%

What's inside ltsteamplugin

  1. RPC Bridge: How to call Lua backend methods from JavaScript

    main

    When using the Millennium loader, the Lua backend exposes several global functions that act as an RPC bridge to the LuaTools desktop application (running at http://127.0.0.1:6767).

    To call these methods from the injected luatools.js page context, use the Millennium bridge API:

    window.Millennium.callServerMethod("luatools", "<MethodName>", args)

    Important: Millennium looks up these methods as GLOBAL Lua functions, not as members of the table returned by the plugin entrypoint. Any new RPC method added to the JavaScript side must have a corresponding global function defined in the Lua backend.

  2. Plugin Lifecycle: on_load, on_unload, and on_frontend_loaded

    main

    The plugin implements the standard Millennium lifecycle hooks to manage the injector stub:

    • on_load: Initializes the plugin. It ensures the LuaTools backend is running, copies necessary Webkit files (luatools.js, steamdb-webkit.css), injects them into the browser context, and calls millennium.ready().
    • on_unload: Performs cleanup when the plugin is unloaded.
    • on_frontend_loaded: Triggered when the frontend is loaded. It re-runs the file copying process to ensure any updated luatools.js files are picked up by the browser context.
    return {
        on_load            = on_load,
        on_unload          = on_unload,
        on_frontend_loaded = on_frontend_loaded,
    }
  3. Reference: Lua backend RPC methods

    main

    The following global functions are available via the luatools RPC bridge. They relay requests to the LuaTools HTTP API. Most methods accept an appid (string/number) as a parameter.

    -- App management
    HasLuaToolsForApp(appid)
    DeleteLuaToolsForApp(appid)
    CheckApisForApp(appid)
    
    -- Installation/Downloading
    StartAddViaLuaToolsFromUrl(appid, source)
    GetAddViaLuaToolsStatus(appid)
    CancelAddViaLuaTools()
    StartLuaToolsAdd(appid)
    GetLuaToolsAddStatus(appid)
    PickLuaToolsAddSource(appid, source)
    
    -- UI & Steam
    RestartSteam()
    OpenSettings()
    OpenFix(appid)
    
    -- Loaded Apps Popup
    ReadLoadedApps()
    DismissLoadedApps()