v1.2 Released: Thread
This thread is now closed. Please relocate to the thread linked above.
DarkSteamworks is a plugin for DarkBASIC Professional, that allows you to access the Steam API so that if and when you get your game on Steam, you will have access to Steam achievements and statistics.
This plugin is essentially complete, minus documentation and one bugfix.
Thus, I am considering this still a WIP.
Current commands (v1.1):
[
return type]
COMMAND [
parameter, ...]
boolean STEAM INIT ()
STEAM RESET
boolean STEAM IS RUNNING ()
boolean STEAM UNLOCK ACHIEVEMENT (AchievementID$ as String)
boolean STEAM LOCK ACHIEVEMENT (AchievementID$ as String)
integer STEAM GET APP ID ()
boolean STEAM IS ACHIEVED (AchievementID$ as String)
boolean STEAM RESTART APP IF NECESSARY (AppID as Integer)
integer STEAM ACHIEVEMENT COUNT ()
string STEAM GET ACHIEVEMENT (AchievementID as Integer)
boolean STEAM STATS AVAILABLE ()
boolean STEAM SET STAT INT (StatID$ as String, Value as Integer)
boolean STEAM SET STAT FLOAT (StatID$ as String, Value# as Float)
integer STEAM GET STAT INT (StatID$ as String)
float STEAM GET STAT FLOAT (StatID$ as String)
boolean STEAM REQUEST STATS ()
boolean STEAM RESET ALL STATS (IncludingAchievements as Boolean)
STEAM RUN CALLBACKS
boolean STEAM DLC OWNED (DLCAppID as Integer)
boolean STEAM DLC INSTALLED (DLCAppID as Integer)
STEAM ACTIVATE GAME OVERLAY Dialog$ as String
STEAM ACTIVATE GAME OVERLAY TO WEB PAGE WebPage$ as String
STEAM SET OVERLAY NOTIFICATION POSITION NotificationPosition as Integer
boolean STEAM IS OVERLAY ENABLED ()
Attached is the current version of the plugin (v1.1 hotfix, 11 Feb 2014). It includes an example project which should help you understand how things work while I get documentation ready.
Download
You can view the source code for the example below:
// DarkSteamworks example
// Disable sync for performance boost
sync off : sync rate 0
disable escapekey
// These are the example achievements included with Spacewar (appid 480)
// ACH_WIN_ONE_GAME = 0
// ACH_WIN_100_GAMES = 1
// ACH_HEAVY_FIRE = 2
// ACH_TRAVEL_FAR_ACCUM = 3
// ACH_TRAVEL_FAR_SINGLE = 4
// Init steam and check if it initialized successfully or not, and if it failed, we exit
if (steam init() <> 0)
print "Steam API initialized successfully."
else
print "Steam API did not initialize successfully."
errorMsg$ = ""
errorMsg$ = errorMsg$ + "Steam API failed to initialize. This could mean:"
errorMsg$ = errorMsg$ + "1. The Steam client isn't running."
errorMsg$ = errorMsg$ + "2. The Steam client couldn't determine the AppID of game."
exit prompt errorMsg$, "Error"
steam reset : end
endif
// Now we check if Steam is actually running
if (steam is running() <> 0)
print "Steam is running."
else
print "Steam is not running."
exit prompt "Please ensure Steam is running.", "Error"
steam reset : end
endif
print "App ID is: " + str$(steam get app id())
// Wait for stats to be available and then report the amount of available achievements
print "Waiting for statistics to be available..."
while (steam stats available() = 0)
steam run callbacks
endwhile
print "This app id has "+str$(steam achievement count())+" achievements associated with it."
// This function is broken at the moment, I have no idea how to send strings to DBPro from a DLL
remstart
print "Achievements:"
for i = 0 to steam achievement count(steamInstance)-1
print steam get achievement(steamInstance, i)
next i
remend
// Okay, now we can lock our test achievement just in case it's already unlocked
temp = steam lock achievement("ACH_WIN_ONE_GAME")
// Now wait for user input to unlock the achievement
print "Press any key to unlock test achievement"
wait key
// Now we unlock the achievement
temp = steam unlock achievement("ACH_WIN_ONE_GAME")
print "Achievement should now be unlocked"
print "Press escape to exit."
// User can press escape to exit
do
steam run callbacks
if (escapekey())
steam reset : end
endif
loop
Special Thanks:
Mnemonic - For the Wintermute Engine Steam plugin, it was used as a reference and base for this plugin
Paril - HUGE amount of help with C++, without Paril's help, this plugin probably wouldn't exist