diff --git a/docs/friends.rst b/docs/friends.rst index e8f5fbf..66b650c 100644 --- a/docs/friends.rst +++ b/docs/friends.rst @@ -72,7 +72,9 @@ Callbacks Reference .. function:: friends.onGameOverlayActivated(data) - :param table data: A table with a single + :param table data: A table similar to `GameOverlayActivated_t `_ + + * **data.active** (`boolean`) -- true if it's just been activated, otherwise false. :returns: nothing :SteamWorks: `GameOverlayActivated_t `_ diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 87521ad..b888705 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -75,7 +75,7 @@ becomes Callbacks --------- -Callbacks work a little different, for example, the ``GameOverlayActivated_t`` callback in ``ISteamUserFriends`` can be used creating a function named ``onGameOverlayActivated`` inside ``userStats``. +Callbacks work a little different, for example, the ``GameOverlayActivated_t`` callback in ``ISteamUserFriends`` can be used creating a function named ``onGameOverlayActivated`` inside ``friends``. Original code: @@ -87,7 +87,7 @@ Original code: void Listener::OnGameOverlayActivated(GameOverlayActivated_t* data) { if (data->m_bActive) - printf("Steam overlay now active\n" ); + printf("Steam overlay now active\n"); else printf("Steam overlay now inactive\n"); } @@ -96,7 +96,7 @@ Code using luasteam: .. code-block:: Lua - function Steam.userStats.onGameOverlayActivated(data) + function Steam.friends.onGameOverlayActivated(data) if data.active then print("Steam overlay now active") else @@ -171,4 +171,4 @@ They can only be compared for equality or converted to strings (using the `tostr print("Your id is " .. str) local id = Steam.extra.parseUint64(str) -- equality works, even though they are different userdata instances - assert(id == original) \ No newline at end of file + assert(id == original) diff --git a/docs/user_stats.rst b/docs/user_stats.rst index 17a5915..eba1003 100644 --- a/docs/user_stats.rst +++ b/docs/user_stats.rst @@ -19,6 +19,11 @@ List of Functions * :func:`userStats.uploadLeaderboardScore` * :func:`userStats.downloadLeaderboardEntries` +List of Callbacks +----------------- + +* :func:`userStats.onUserStatsReceived` + Function Reference ------------------ @@ -130,14 +135,14 @@ Function Reference The equivalent function for other users is :func:`userStats.requestUserStats` **(missing)**. - Triggers a :func:`userStats.userStatsReceived` callback. + Triggers a :func:`userStats.onUserStatsReceived` callback. **Example**:: -- before any achievement/stats stuff Steam.userStats.requestCurrentStats() - function Steam.userStats.userStatsReceived() + function Steam.userStats.onUserStatsReceived() can_do_stats_stuff = true end @@ -328,7 +333,7 @@ Function Reference * **data[i].details** (`string`) -- Details of the entry. String is used as a byte array, so may contain a ``'\0'`` in the middle. - * **data[i].UGC** (`uint64`) -- Handle for the UGC attached to the entry. A special value if there is none. + * **data[i].UGC** (`uint64`) -- Handle for the UGC attached to the entry. A special value if there is none. * **err** (`boolean`): **true** if there was any IO error with the request. @@ -368,3 +373,33 @@ Function Reference end end end + +Callbacks Reference +------------------- + +.. warning:: + + Remember callbacks are functions that you should override in order to receive the events, and not call directly. + + Also, you **must** constantly call ``Steam.runCallbacks()`` (preferably in your game loop) in order for your callbacks to be called. + + +.. function:: userStats.onUserStatsReceived(data) + + :param table data: A table similar to `UserStatsReceived_t `_ + + * **data.gameID** (`uint64`) -- Game ID that these stats are for. + + * **data.result** (`int`) -- Returns whether the call was successful or not. If the user has no stats, this will be set to 2. + + * **data.steamIDUser** (`uint64`) -- The user whose stats were retrieved. + :returns: nothing + :SteamWorks: `UserStatsReceived_t `_ + + Called when the latest stats and achievements for a specific user (including the local user) have been received from the server. + +**Example**:: + + function Steam.userStats.onUserStatsReceived(data) + print('Result: ' .. data.result) + end