uspgamedev / luasteam

Bindings to connect lua with Steam API
https://luasteam.readthedocs.io/en/stable/
MIT License
116 stars 19 forks source link

Callbacks don't seem to work for me #9

Closed oniietzschan closed 5 years ago

oniietzschan commented 5 years ago

Here's my code. I would expect userStatsReceived to be called eventually, and onGameOverlayActivated to be called whenever I open and close the team overlay, but neither happen for me. Is there something I'm doing wrong? I've tested this with Steamwork SDK 1.42 and SDK 1.44, both behave identically.

Despite all this, I'm still able to execute setAchievement, getAchievement, storeStats, and resetAllStats, and they all appear to work in real time.

Thank you.

local Steam = require 'luasteam'

function love.load()
  Steam.init()
  Steam.userStats.requestCurrentStats()
end

-- This never gets triggered!!
function Steam.userStats.userStatsReceived(...)
  print('userStatsReceived')
  print(...)
end

-- Activating and Deactivating the game overlay does not trigger this.
function Steam.userStats.onGameOverlayActivated(data)
  print("Steam overlay is now " .. (data.active and "active" or "inactive"))
end

function love.update()
  Steam.runCallbacks()
end

function love.quit()
  -- prints:
  --   Setting breakpad minidump AppID = 1040490
  --   Steam_SetMinidumpSteamID:  Caching Steam ID:  76561197967143787 [API loaded no]
  Steam.shutdown()
end
yancouto commented 5 years ago

I will take a look at this tomorrow or Wednesday.

yancouto commented 5 years ago

Hello, sorry for the delay.

The problem is that the first callback is called Steam.userStats.onUserStatsReceived, and the second callback is called Steam.friends.onGameOverlayActivated(doc).

I'm so sorry, it seems like the Getting Started page is wrong for onGameOverlayActivated, that's what led to you mistake. I'll fix that.

It seems the doc is also wrong in mentioning userStatsReceived.

yancouto commented 5 years ago

I fixed these mistakes in the doc. Should show up in the next release (I'll probably make a small release with just the docs, since not much is going on here).

Please reopen this if you still have problems :)