luasteam

repository·master·Indexed 42 days ago

https://github.com/uspgamedev/luasteam

A library providing Lua bindings for the SteamWorks API, enabling Steam integration for games built with Lua engines such as Love2D. It includes a Rust-based generator for automatically creating C++ bindings from steam_api.json and supports interfaces like ISteamApps for managing DLC, installation status, and launch parameters.

Tokens
138.4K
Snippets
508
Records
703
Agent score
52%

What's inside luasteam

  1. Overview of available luasteam examples

    master

    The repository includes several example projects to verify different aspects of the luasteam integration:

    • basic: Verifies that luasteam can be imported without crashing and checks that basic interfaces and enums are correctly initialized. Does not require Steam to be running.
    • basic_love: Verifies luasteam import and output functionality using the LOVE2D framework. Does not require Steam to be running.
    • socket_client / socket_server: Demonstrates and tests the socket API by running a client and server pair.
    • sdk_readonly_smoke: An end-to-end smoke test for various Steam SDK functions. It uses only read-only or safe calls to avoid side effects. It covers: User, Friends, Apps, Utils, Networking, RemoteStorage, UGC, Matchmaking, and UserStats callbacks.
  2. Overview of the ISteamInput API

    master

    The ISteamInput API provides access to Steam Input functionality, allowing developers to manage controller input, action sets, haptics, and device connectivity.

    Key capabilities include:

    • Action Management: Activating/deactivating action sets and layers, and retrieving action handles (analog and digital).
    • Input Polling: Retrieving digital and analog action data, as well as motion data.
    • Haptics: Triggering vibration and haptic events.
    • Device Management: Monitoring controller connections and managing gamepad indices.
    • UI/UX: Showing the Steam binding panel and retrieving glyphs (PNG/SVG) for UI elements.

    Note: Methods in this documentation may be marked with:

    • 🤖: Automatically generated bindings.
    • ✍️: Manually implemented methods.
    • ✋: Currently not implemented.
  3. Use the ISteamController API

    master

    The ISteamController interface provides access to Steam Controller features, including action sets, input data (analog and digital), haptic feedback, and controller LED control.

    Note on method symbols:

    • 🤖: Automatically generated bindings.
    • ✍️: Manually implemented methods.
    • ✋: Currently not implemented.
  4. Reference the ISteamMatchmaking API

    master

    The Matchmaking module provides access to Steam's matchmaking services, allowing you to create and manage lobbies, search for compatible members, and handle lobby-based communication.

    Note on documentation symbols:

    • 🤖: Automatically generated bindings.
    • ✍️: Manually implemented methods.
    • ✋: Currently not implemented.

    Key functional areas include:

    • Lobby Management: Creating, joining, leaving, and setting properties (type, joinability, owner) for lobbies.
    • Lobby Data: Setting and retrieving metadata for lobbies and individual members.
    • Lobby Search: Requesting lists of lobbies and applying various filters (numerical, string, slots available, distance, etc.).
    • Communication: Sending and receiving chat messages within a lobby.
    • Favorites: Managing a user's favorite games list.
  5. Use ISteamNetworkingUtils for network utilities

    master

    The NetworkingUtils interface provides a suite of tools for managing network-related tasks in Steam, including ping estimation, relay network status, IP address manipulation, and configuration management.

    Key capabilities include:

    • Ping & Latency: Estimating ping between locations or from localhost, and checking ping data freshness.
    • Relay Networking: Initializing relay access and monitoring relay network status.
    • IP & Identity Management: Parsing and converting Steam networking IP addresses and identities to/from strings, and handling 'Fake IP' types.
    • Configuration: Setting and retrieving global or connection-specific configuration values (Float, Int32, String).
    • Callbacks: Registering for network status changes and session updates.
  6. Use Enums and Constants in v5

    master

    In v5, all C++ enum constants are exposed as plain integers directly on the Steam table using their exact C++ names. You should no longer use strings to pass enum values to functions; pass the integer constant instead.

    Access Pattern: Steam.<CppConstantName>

    Examples:

    • Steam.k_EItemStateInstalled (Value: 4)
    • Steam.k_ELeaderboardSortMethodDescending (Value: 2)
    • Steam.k_ESteamNetworkingSend_Reliable (Value: 8)

    Comparison:

    if data.m_eResult ~= Steam.k_EResultOK then
        print("Error:", data.m_eResult)
    end
  7. Understand the ISteamClient interface

    master

    The ISteamClient interface provides core Steam functionality. In luasteam, this interface is accessible via multiple accessors depending on your context. While the documentation refers to it as Client, it can also be accessed as GameServerClient (e.g., Steam.GameServerClient).

    Methods in this documentation are categorized as:

    • 🤖 Auto-generated: Automatically created bindings from SteamWorks.
    • ✍️ Manually implemented: Custom Lua implementations.
    • ✋ Not implemented: Methods that are currently blocked or unavailable (typically custom accessors like GetISteamUser).
  8. Use the ISteamHTTP interface

    master

    The ISteamHTTP interface provides methods for making HTTP requests, managing cookies, and handling HTTP responses.

    Note that this interface can be accessed through multiple accessors depending on your context (for example, a GameServer variant). While the documentation refers to it as HTTP, you may need to access it via GameServerHTTP in certain environments.

  9. Initialize Steam Structs with Constructors

    master

    Most Steam-related data structures in luasteam are provided as userdata instances. You can create a new instance of a struct using its corresponding Steam.new<StructName>_t([table]) constructor.

    Passing an optional table to the constructor allows you to set initial field values immediately upon creation.

    -- Example: Creating a struct with initial values
    local myStruct = Steam.newGameServerChangeRequested_t({
        m_rgchServer = "my_server_address",
        m_rgchPassword = "secret_password"
    })
  10. Access the ISteamNetworking interface

    master
    The ISteamNetworking interface provides networking capabilities for Steam games. Note that this interface can be accessed through multiple accessors depending on your context. While the documentation refers to it as Networking, it may also be available via GameServerNetworking (e.g., for a GameServer variant).
  11. Handle Steam Networking Messages callbacks

    master

    The ISteamNetworkingMessages interface provides two primary callbacks for managing session lifecycles:

    1. OnSteamNetworkingMessagesSessionRequest: Triggered when a remote user attempts to start a session. The data object contains m_identityRemote (the SteamNetworkingIdentity of the requester).
    2. OnSteamNetworkingMessagesSessionFailed: Triggered when a session fails. The data object contains m_info (SteamNetConnectionInfo_t), which includes the end reason (m_eEndReason).
    function Steam.NetworkingMessages.OnSteamNetworkingMessagesSessionFailed(data)
        print('Messages session failed:', data.m_info.m_eEndReason)
    end