类型 布尔值 修订版 Release 2024.3703 关键字 steam、steamworks、isLoggedOn 另请参阅 steamworks.*
如果满足以下所有条件,此属性值为 true
config.lua
所设置的 appId
为 Steam 所接受。如果此属性为 false
,则此插件的大多数 API 将无法工作,并将返回 false
或 nil
。假定应用程序设置正确,则您必须假设用户当前未登录到 Steam 客户端并正在直接运行应用程序。在这种情况下,您应要求用户退出应用程序,登录到 Steam,然后
请注意,如果此属性返回 false
,它将永远不会在应用程序的生存期内返回 true
,即使用户在应用程序运行时登录到 Steam 客户端也是如此。用户必须退出应用程序并在登录 Steam 后重新启动应用程序。
local steamworks = require( "plugin.steamworks" ) -- Do not continue if a logged in Steam user can't be found -- This means the Steam client is not running or the user is not logged in if ( steamworks.isLoggedOn == false ) then -- Handle the native alert's result displayed below local function onAlertHandler( event ) -- If user logged in, display the Steam client via its custom URL scheme if ( event.action == "clicked" ) and ( event.index == 1 ) then system.openURL( "steam:" ) end -- Exit this app, regardless of which button was pressed -- The Steam client MUST be running when this app starts up native.requestExit() end -- Display a native alert asking the user to log into Steam local message = "You must log into Steam in order to play this game.\n" .. "After logging in, you must then relaunch this app." native.showAlert( "Alert", message, { "Log In", "Close" }, onAlertHandler ) -- Exit out of the "main.lua" file -- The screen will be black, only showing the native alert above return end -- Successfully connected to Steam print( "Successfully connected to Steam!" )