extension-steam icon indicating copy to clipboard operation
extension-steam copied to clipboard

Cannot detect if Steam initialised correctly

Open Domarius opened this issue 4 months ago • 3 comments

Given the following code (a variation on what is provided in the documentation):

	local status, error = pcall(steam.init)
	if not status then
		print("Steam Error: " .. error)
		return
	else
		print("Steam init success")
	end

When Steam is not running, the following is output to the console

[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
[S_API] SteamAPI_Init(): Loaded '/home/domarius/.local/share/Steam/linux64/steamclient.so' OK.
DEBUG:SCRIPT: Steam init success

Domarius avatar Oct 15 '25 21:10 Domarius

You shouldn't do a pcall here. steam.init() will not throw a Lua error but instead return two values, the first is a boolean which indicates if steam was successfully initialized, and the other is nil on success and an error message if init failed.

https://github.com/defold/extension-steam/blob/master/examples/menu/menu.gui_script#L4-L10

britzl avatar Oct 15 '25 21:10 britzl

Oh, can we correct the documentation then? This is the documentation;

function init(self)
	-- initialize the Steamworks SDK
	local status, error = pcall(steam.init)
	if not status then
		print("Error: " .. error)
		return
	end

	steam.set_listener(on_steam_event)
end

See here

Domarius avatar Oct 16 '25 03:10 Domarius

Oh, sure, could you please submit a pull request with the fix for the docs?

https://github.com/defold/extension-steam/tree/master/docs

britzl avatar Oct 16 '25 06:10 britzl