Steam Wrapper thread 2

BlitzMax Forums/BlitzMax Programming/Steam Wrapper thread 2

Grey Alien(Posted 2015) [#1]
@Skidracer


Why are you calling StoreSteamStats? It's not even exposed...



It seems exposed and was also listed as an Extern in your steamtest.bmx

BBDECL void StoreSteamStats(){
  SteamUserStats()->StoreStats();
}



If you had looked at the c++ source in the mac thread you can see that steamstub is already calling this function.


I did look at the c++ source thoroughly and this is all that SetSteamAchievement() does. Note that it doesn't call StoreSteamStats() after setting the achievement.

BBDECL void SetSteamAchievement(const char *id){
  SteamUserStats()->SetAchievement(id);
}


Why are you calling StoreSteamStats???


Because the Steam SDK docs tell me I should do that:
Whenever one or more achievements are unlocked, call SteamUserStats->SetAchievement() for each unlocked achievement and then SteamUserStats()->StoreStats() to immediately upload them. Your game will see a UserStatsStored_t callback, plus one UserAchievementStored_t callback for each unlocked achievement. The Steam Game Overlay will display a notification panel to the user.



So there's a reason why I did everything after researching it.

Perhaps the issue in my code is that I'm calling StoreSteamStats after setting *every* achievement, and so if I set two achievements at once, StoreSteamStats gets called in rapid succession and maybe that occasionally borks things. It's probably best if I change my code to set the achievements first and then call StoreSteamStats once afterwards.


skidracer(Posted 2015) [#2]
Try logging everything you set and every non empty update from steamstub.

It should read like a single (polite) conversation where each thing said has a matching reply.


Grey Alien(Posted 2015) [#3]
Yep doing that already as per my log outputs in the other thread. I'll basically do what I said above and won't call StoreSteamStats in rapid succession and see if I still get any more reports of it screwing up.

Also I've made enough sales that I think it's worth me trying to get it working on Mac, wish me luck!


therevills(Posted 2015) [#4]
My turn for using this :)

This is how I've used Skid's Steam Wrapper:

1. Download the wrapper (steamstub4a.zip) from:
http://code.google.com/p/max-edit/downloads/list

2. Copy the following to your game folder:
* steam_appid.txt
* steamstub.dll
* steamstub.lib

3. Update steam_appid.txt to your game's id

4. Grab the latest steam_api.dll from Valve and copy that into your game folder.

5. In the Steam's partner site create your achievements and publish them, for testing I created two setting the API Name to "TEST1" and "TEST2"

6. I've altered the steamtest to run in a graphics window, press 1 to unlock Achievement TEST1 and 2 to unlock TEST2. Press 3 to unlock both of them. Press SPACE to clear them (remember to update the appid in the code too!):



7. Log into Steam using your developer account, and add a non-steam game point it to the steamtest exe

8. Run the game from Steam



Seems to work pretty well at the moment with the test code, now to add it to my main game.

Thanks Skid and GA.


Ian Martin(Posted 2015) [#5]
@Skid Just testing this and it seems to work great! Do I have your permission to use this code and distribute your steamstub.dll with my games?

I'm a Steamworks developer, my current project is here:
http://steamcommunity.com/sharedfiles/filedetails/?id=326903625

Is there a newer version of this, since the 2010 one? Are you mostly doing Monkey stuff these days?


skidracer(Posted 2015) [#6]
I take no responsibility whatsoever with what you do with that binary.


Ian Martin(Posted 2015) [#7]
OK, awesome, thanks! :D


coffeedotbean(Posted 2015) [#8]
woooh sweet, bookmarking this for future - big thanks to SKid, Rev and Grey.


coffeedotbean(Posted 2016) [#9]
*BUMP* so do I need a Greenlite (voted for) game on steam before I can use the Partner site to setup/test achievements etc? cus' I am trying to sign up after adding a test app in Green-light (unpublished ofc) but I cannot signup on the steamworks partner site as its says I need "an eligible Greenlight item in order to continue."

I have send a mail to steamworks, thought i'd ask here in the meanwhile.

** UPDATE **

Yes seems you first need to have a game greenlite before you can do any thing with steamworks, shame I just wanted to test it out.


coffeedotbean(Posted 2016) [#10]
*BUMP* so do I need a Greenlite (voted for) game on steam before I can use the Partner site to setup/test achievements etc? cus' I am trying to sign up after adding a test app in Green-light (unpublished ofc) but I cannot signup on the steamworks partner site as its says I need "an eligible Greenlight item in order to continue."

I have send a mail to steamworks, thought i'd ask here in the meanwhile.

** UPDATE **

Yes seems you first need to have a game greenlite before you can do any thing with steamworks, shame I just wanted to test it out.


Devlin(Posted 2016) [#11]
You need a fully greenlit game (and associated Steam AppID) to be able to properly test Steamworks integration.

I'm trying to get all this working and failing miserably at present


col(Posted 2016) [#12]
You guys may or may not be aware of this thread too regarding a bug in the steam overlay. I'm not sure if steam have resolved the issue just yet but until then...


Devlin(Posted 2016) [#13]
I'm having a bit of trouble launching the test app since the build process fails. I'm using the example code up written by "therevills" in BMX-NG, the only change being my AppID

Building steamtest
[ 99%] Processing:steamtest.bmx
[ 99%] Compiling:steamtest.bmx.gui.release.win32.x86.c
[100%] Linking:steamtest.exe
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x6d): undefined reference to `OpenSteam'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x136): undefined reference to `ReadSteam'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x17c): undefined reference to `GetSteamAchievement'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x1ec): undefined reference to `SetSteamAchievement'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x226): undefined reference to `ClearSteamAchievement'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x233): undefined reference to `StoreSteamStats'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x2b4): undefined reference to `ClearSteamAchievement'
C:/Users/David/Desktop/steamstub4a/.bmx/steamtest.bmx.gui.release.win32.x86.o:steamtest.bmx.gui.release.win32.x86.c:(.text+0x3f3): undefined reference to `CloseSteam'
Build Error: Failed to link C:/Users/David/Desktop/steamstub4a/steamtest.exe
Process complete


Upon testing in the vanilla client, that code seems to work just fine, but doesn't connect


Grey Alien(Posted 2016) [#14]
I see you are compiling that on your desktop. Is it possible you don't have the steamstub.lib in the same folder as the game exe or did you forget to have Import "validpath/steamstub.lib" at the top of your code?

In terms of why it works in normal BlitzMax but won't connect, have you loaded the Steam app and logged in? You need to do that.


Devlin(Posted 2016) [#15]
I'm using the code in this post >>> http://www.blitzbasic.com/Community/post.php?topic=104599&post=1275465 <<< wholesale, barring the AppID change.

Everything is present that needs to be - steamstub.lib is in the same folder, alongside steam_api.dll and steamstub.dll - the steam_appid.txt is there with my AppID set correctly.

Steam is running in the background, and after I build in BlitzMax I go into Steam and open it via a shortcut on my game list.

The result of this is that the app reports says that SteamOpen() failed because steamstate was -1


Grey Alien(Posted 2016) [#16]
So if you've changed the 480 to your appID and it should work. What happens if you just check the SteamOpen() return value in the compiler when it's running instead of running it via Steam? You only need to run it via Steam if you want to see the achievements pop up via overlay (which you should do at some point for sure). I'm just trying to rule out step 7 as a possible issue from therevills's instructions.


Devlin(Posted 2016) [#17]
It always returns -1 (cannot find/open Steam) regardless of whether Steam is open or not and it doesn't matter where/how I launch it, it still returns -1.


Rimmsy(Posted 2016) [#18]
Looooong time since I've posted here, but a game I wrote back in 2006 has just been released on Steam and I've used the steam library above (thanks guys!) to add achievements. It works!

However, I want to try leaderboards, but it seems not matter what configuration I try it always returns "no leaderboard open!"

I think I've been everywhere, but is this source for windows available so I can change and build? I suspect steam has changed some of their API calls.

Thanks!


Devlin(Posted 2016) [#19]
I'd worry about your account first. All the issues with what I was doing were because of my account not being set up right by Valve.


JoshK(Posted 2016) [#20]
FYI, the Leadwerks DLL wraps a lot of the Steam functionality. Use DLLExplore to see the functions. It handles achievements, both incremental and boolean. You need the pro version to get the C++ header.


skidracer(Posted 2016) [#21]
Rimmsy, I will locate and post the source code to steamstub tonight (NZ time).


Devlin(Posted 2016) [#22]
simonarmstrong (Posted 19 hours ago) #21
Rimmsy, I will locate and post the source code to steamstub tonight (NZ time).


does the steamstub have commands for Workshop integration? I'd like to get this in my game fairly soon.


skidracer(Posted 2016) [#23]
I forgot I no longer had a windows machine at home so there is going to be a bit of a delay. Leaderboards never worked in steamstub as I was unable to debug them with the demo app key so if you want to use steamstub, please don't plan for anything but basic functions only and use existing version.


Devlin(Posted 2016) [#24]
@simonarmstrong
Is it the same source as included here?
http://www.blitzbasic.com/Community/posts.php?topic=96950

Would this compile into a linux .so if appropriately modified?


Grey Alien(Posted 2016) [#25]
Looks like I'll also be needed a Linux version too soonish... @Devlin please stay in touch about your success with that. Thx.


Devlin(Posted 2016) [#26]
@Grey Alien

Will do, mate. I will try and build the source I found, and see what happens on my linux machine.


Devlin(Posted 2016) [#27]
I got this working on linux by doing the following:

Copied the headers in the Steamworks SDK (/sdk/public/steam) to a folder called "include"

Copying libsteam_api.so to /usr/lib (a symlink might work?) once you're done building you should make sure libsteam_api.so is actually in your game folder because Steam will look there to find libsteam_api.so when launching from Steam (this has been confirmed by testing)

Adding the following Imports to the test code(steamstub.bmx - you'll need to pull steamstub.cpp from this post too) from http://www.blitzbasic.com/Community/post.php?topic=96950&post=1123715 that post

?Linux
Import "-lsteam_api"
Import "steamstub.cpp"
?


This is a lazy ass hack job of a way of doing it but it worked in my Linux Mint installation so hopefully folks can extrapolate and make it work a bit more globally. I don't think I can offer any additional help but I imagine that skid can.

Hail me @magic_bane on Twitter and I can provide these as actual files should you wish to have code which has had all the above steps completed.


Rimmsy(Posted 2016) [#28]
Thanks Simon, take your time. I've achievements at the moment, and I'm not in a rush to add anything else, but it'd be nice.

In the meantime, I'll have a play with the code Devlin posted about.