{{tag>service steam steamworks dragonscript}} [[:start|Start Page]] >> [[:gamedev|Game Development with the Drag[en]gine]] >> [[:gamedev:servicemodules#service_listing|Service Listing]] >> **Steam SDK** ====== Steam SDK ====== The ''SteamSDK'' Service Module provides access to the Steam SDK. With this SDK SteamWorks functionality can be used if Steam is running. If Steam is not running creating the service fails. The service has the unique identifier ''SteamSDK''. Support for this service is provided in the DragonScript Script Module using the class #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1ServiceSteam,ServiceSteam~@#. This service implements the following interfaces: * #@LinkApiDocDEDS2_HTML~interfaceDragengine_1_1Services_1_1User_1_1ServiceUser,ServiceUser~@# * #@LinkApiDocDEDS2_HTML~interfaceDragengine_1_1Services_1_1Stats_1_1ServiceStats,ServiceStats~@# ====== Initialization ====== ===== Automatic ===== The #@LinkApiDocDEDS2_HTML~classDragengine_1_1BaseGameApp,BaseGameApp~@# class automatically creates the SteamSDK service instance if the following values are present in the ''configuration.ptree.xml'' file: ^ Tag ^ Value ^ | steam.appid | Steam AppId as shown in the SteamWorks game page | An example ''configuration.ptree.xml'' file looks like his: true true 12345678 If Steam is not running creating the SteamSDK service fails. This does not fail starting the application. Wait until all the services have finished initializing: func void initGame() // super call starts automatic initialize services super.initGame() // add listener called once all services have finished initialize, no matter if successfull or not getBaseGameServices().setActionInitialized(BlockActionListener.new(block ActionEvent event // services have initialized launchApplication() end)) // you can now do other things in the mean time like showing startup logos or videos end You can then check first if the SteamSDK service has been created using: if getBaseGameServices().getSteam() != null // ServiceSteam is ready to be used end ===== Manual ===== The SteamSDK service can be manually created either by using the ''new'' constructor on the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1ServiceSteam,ServiceSteam~@# class using #@LinkApiDocDEDS2_HTML~classDragengine_1_1Services_1_1ServiceSteam_1_1InitParameters,ServiceSteam.InitParameters~@# setup with the initialization data or by calling ''initSteam()'' on #@LinkApiDocDEDS2_HTML~classDragengine_1_1BaseGameApp,BaseGameApp~@#. Using ''initSteam'' is preferred if manual creation is required. ====== ServiceUser ====== The service module provides user management support. Supported is only retrieving user information and user resources. ===== Login ===== The user can not be logged in or out since a Steam user is always logged in as soon as Steam is running. ===== Authentication Provider ===== The service module provides also ''Authentication Provider'' support to other modules. The provider has the unique identifier ''steam''. This feature allows other service modules to link accounts to the logged in Steam user. For this to work you have to call ''getAuthToken()'' to asynchronously retrieve an authentication token. Once received in the listener this token can be used on other service modules supporting linking with Steam user accounts. ====== ServiceStats ====== The service module provides achievement and statistics support. Use ''setStatsAndAchievements()'' to set the value of individual statistics. Once the requirements are fulfilled server side the respective achievements will be unlocked. You can also use the same function to manually unlock achievements. Use ''getStatsAndAchievements()'' to retrieve the current stats and achievements state.