Howdy! This is a branch of Easimer's SteamworksForPython in an attempt to bring a fully-functional Python module for Steam out for the public.
Feel free to fork or contribute to this module.
For a fuller tutorial, with images, on SteamworksPy please read our post: http://coaguco.tumblr.com/post/128240756897/steamworks-for-python-tutorial-linux.
While I am still tinkering away with this, here are some things to note:
- You will need the Steamworks SDK
- You will most likely need a Steamworks account, with a valid AppID, to use more advanced functions (set achievements, set stats, etc.)
- You will need to be logged into Steam for anything to function, obviously. As it assumes the game is run from Steam itself and is online.
- Steam Overlay will only work if your game is using OpenGL or D3D! Overlay will only work if the game is actually launched from Steam itself. Possible if the SteamRestart command is fired; however, this is not implemented yet in SteamworksPy.
- Add in more features from the Steamworks SDK
- Create a Mac version (I do not own a Mac, so someone who does that can help out would be greatly appreciated!)
- Download this repo and unpack
- Download and unpack the Steamworks SDK
- Move the Steam header (steam) folder from /sdk/public/ into the unpacked repo for compiling
- Move the Steam API file from /sdk/redistributable_bin into the unpacked repo
- For Linux, find libsteam_api.so
- For Windows, find steam_api.dll or steam_api64.dll as well as steam_api.lib or steam_api64.lib
- Create the new DLL or SO file
- For Linux:
- Run the makefile from the repo
- Alternately, you could just run something like:
g++ -o SteamworksPy.so -shared -fPIC SteamworksPy.cpp -lsteam_api
- For Windows:
- Create a new DLL project in Visual Studio
- New > Project
- Templates > Visual C++ > Win32 > Win32 Project
- Follow the wizard and pick the DLL Application Type
- Add SteamworksPy.cpp to Source Files and steam_api.h from /steam/ folder to Header Files
- Go to Project > Properties in the toolbar
- Under C/C++ > Precompiled Headers, turn off Precompiled Header option
- Under Linker > Input, add steam_api.lib or steam_api64.lib to Additional Dependenices
- Clean and build
- Move the steamworks.py and new compiled SteamworkPy.so or SteamworksPy.dll from the unpacked repo into your project
- You also will have to move over the libsteam_api.so or steam_api.dll as well
- Add the following to your to your main file or whichever file you plan on calling Steam from:
from steamworks import *
#Initialize Steam
Steam.Init()
From here you should be able to call various functions of the steamworks.py. A list of available functions is listed below; take a closer look at the steamworks.py for a better understanding. In addition, you should be able to read the Steamworks API documentation to see what all is available and cross-reference with the steamworks.py!
- Init()
- Starts up the Steam API
- GetDLCCount()
- Get the total number of DLC installed for this game
- IsDlcInstalled()
- Is a particular DLC installed for this game
- You must pass the DLC's AppID
- RequestAppProofOfPurchaseKey()
- Should return the game's serial number, if it exists
- GetFriendCount()
- Get the number of friends the user has
- GetPlayerName()
- Get the user's name
- GetPersonaState()
- Get the user's current state
- ActivateGameOverlay()
- This should activate the Steam Overlay
- Useful for binding keys to
- MusicIsEnabled()
- Check whether or not Steam Music is enabled
- MusicIsPlaying()
- Is Steam Music currently playing something?
- MusicGetVolume()
- Get the system's current volume level
- MusicPause()
- Pause whatever Steam Music is playing currently
- MusicPlay()
- Play whatever track Steam Music is on
- MusicPlayNext()
- Play the next track in Steam Music
- MusicPlayPrevious()
- Play the previous track in Steam Music
- MusicSetVolume()
- Set the system's volume
- Must pass a float between 0.0 and 1.0
- GetPlayerID()
- Get the user's Steam ID number
- Currently just returns 0
- GetPlayerSteamLevel()
- Should return the user's Steam level
- ClearAchievement()
- Clear the specified achievement from the user
- Must pass achievement's name in Steam (eg. STEAM_ACHIEVE_1)
- GetAchievement()
- Find whether or not the specified achievement is earned
- Must pass achievement's name in Steam (eg. STEAM_ACHIEVE_1)
- GetStatFloat()
- Get value of specified float statistic
- Must pass statistic's name in Steam (eg. TOTAL_GAMES)
- GetStatInt()
- Get value of specified integer statistic
- Must pass statistic's name in Steam (eg. TOTAL_GAMES)
- ResetAllStats()
- Resets all of the user's statistics, perhaps also achievements
- RequestCurrentStats()
- Pulls all of the user's statistics and achievements
- Should be called before calling any Get stats/achievement functions
- SetAchievement()
- Set a particular achievement for the user
- Must pass achievement's name in Steam (eg. STEAM_ACHIEVE_1)
- SetStat()
- Set a particular statistic for the user; either INT or FLOAT
- Must pass statistics's name and value in Steam (eg. TOTAL_GAMES, 4)
- StoreStats()
- Sends all the statistics and achievements to Steam servers
- GetCurrentBatteryPower()
- Get the user's battery power level
- GetIPCountry()
- Get the two-digit code for the user's IP address
- GetSecondsSinceAppActive()
- Get the number of seconds since the game started up
- GetSecondsSinceComputerActive()
- Get the number of seconds since the user's computer was started
- GetServerRealTime()
- Get the time from the server, probably
- IsOverlayEnabled()
- Is the Steam overlay enabled
- IsSteamRunningInVR()
- Is Steam's VR service running
- GetSteamUILanguage()
- Gets the user's Steam UI language (eg. English, French, etc.)
- GetAppID()
- Should return the game's App ID
I recommend trying the included tests to get an idea of how it works. Opening the test files will give you some insight on how to use it in your game, as well as looking through the Steamworks.py file itself. Also, don't hesitate to contact me for help or with questions. Or comment / open issue on GitHub.
I am still digging through the code and trying to get more functions working. Some things like controller might not be necessary as Python can usually handle these; though they may have more to do with the new Steam Controller.