Has anyone been able to unlock a Steam achievement from code?
Note: I’m not talking about achievements tied to stats, those unlock fine for me automatically when the stat hits the target value.
What I don’t get is why steamworks.setAchievementUnlocked() won’t unlock an achievement that’s not stat-based. My code looks solid (as far as I can tell), but it just won’t fire. Any ideas?
Hi,
The only extra care I take is save the unlocked achievements into a file so I can synchronize it with the server later even if the first unlock request will fail.
Since your stats successfully updates (and I guess they are multiple calls), I’m moved to think 1 call may fail for some reasons but a later attempt would succeed?
This or maybe the achievements aren’t configured/exposed properly.
Try to log it and see if it gives you a error or anything
My issue is that achievements not tied to stats won’t unlock from my code, while the stat-based ones unlock just fine when the stat hits the configured value.
The code is straightforward (I’ve checked it multiple times) and I also keep variable references/flags for unlocked achievements to track them. Still, several users report that those non–stat-based achievements don’t unlock for them either. That’s why I’m starting to think steamworks.setAchievementUnlocked() might not be working perfectly, especially since it was added to the Steamworks plugin fairly recently.
So maybe the issue is with having both types mixed together?
We can compare our set-up inside Steam if you want.
Just confirm those achievements have been 100% published and tell me what the log says about those calls, so we can exclude obvious reasons before we start
It’s been some time since I worked on the steam version of our apps but the achievements are still working fine and the code that I have is basically the same function call as yours:
--function that unlocks the specified achievement
function steamManager.unlockAchievement(achievementName)
local hasSucceeded=steamworks.setAchievementUnlocked(achievementName)--returns true if the achievement is successfully unlocked
if(hasSucceeded)then
-- debugStmt.print("Steam Manager: Achievement Unlocked!!")
else
-- debugStmt.print("Steam Manager: Error!")
end
end
I don’t know if the achievements have a name AND and ID but I should clarify that I am passing the full string name to the function and they unlock alright.