MZ [Solved (With Guide)]Need help setting Steam achievements for RMMZ game

NOTE (Dec 11, 2024): I've succeeded in activating Steam achievements with greenworks.js, and wrote a step-by-step guide here. (FYI: I'm using Windows 64-bit and my game was made executable for the same.)


And here's the original post:

I've been testing around and still cannot unlock Steam achievement. Now I'm trying to set it up simply using greenworks and create an initial plugin for it like newly mentioned in this thread: https://forums.rpgmakerweb.com/inde...evements-to-work-in-rmmz.170981/#post-1465965 but the achievements still cannot be activated. Can someone tell me what I did wrong?👋

Edit: Just found the reason, the path to greenworks.js was wrong. All other settings here stay the same!
I'm using Windows 11 (64 bit), NWjs v0.89.0 (if I need to change this I may not be able to change it to versions lower than 0.86.0 cuz there would be text glitches), Greenworks v0.17.0, Steamworks SDK 1.60.

Since I somehow cannot summon the dev tool whenever Steam's on, here's the newest Error message I got:
errorMessage.png


Here's what my files look like:
folderWithGame.png
and in /lib/ folder:
folderLib.png

And here's the code in the created plugin:
Spoiler: Code
JavaScript:
var greenworks = null;
try{
  greenworks = require('../../greenworks'); //path to your greenworks.js
  greenworks.init();
}catch(ex){
  console.log(ex);
  greenworks = null;
}

function UnlockAchievement(achievement, success_callback, error_callback){
  try{
    success_callback = success_callback||function(){};
    error_callback = error_callback||function(){};
    greenworks.activateAchievement(achievement, success_callback, error_callback);
  }catch(ex){
    console.log('failed to active achievement: ', achievement);
    console.log(ex);
  }
}


function ClearAchievement(achievement, success_callback, error_callback){
  try{
    success_callback = success_callback||function(){};
    error_callback = error_callback||function(){};
    greenworks.clearAchievement(achievement, success_callback, error_callback);
  }catch(ex){
    console.log('failed to clear achievement: ', achievement);
    console.log(ex);
  }
}

Edit: Here's the correct code, copy this one if you want:
Spoiler: Edited Code
JavaScript:
var greenworks = null;
try{
  greenworks = require('./greenworks'); //path to your greenworks.js
  greenworks.init();
}catch(ex){
  console.log(ex);
  greenworks = null;
}

function UnlockAchievement(achievement, success_callback, error_callback){
  try{
    success_callback = success_callback||function(){};
    error_callback = error_callback||function(){};
    greenworks.activateAchievement(achievement, success_callback, error_callback);
  }catch(ex){
    console.log('failed to active achievement: ', achievement);
    console.log(ex);
  }
}


function ClearAchievement(achievement, success_callback, error_callback){
  try{
    success_callback = success_callback||function(){};
    error_callback = error_callback||function(){};
    greenworks.clearAchievement(achievement, success_callback, error_callback);
  }catch(ex){
    console.log('failed to clear achievement: ', achievement);
    console.log(ex);
  }
}
And I called them in the Event by using UnlockAchievement("ACH_29");andClearAchievement("ACH_29"); I've tried 'ACH_29' instead of "ACH_29" but nothing changes.

Edit: My store page is still not online, but the achievement can be activated now!
You can press F8 to open the console I think?
You can press F8 to open the console I think?
Well, this would happen when I want to open the console now. I asked my friend to try to open my .rmmzproject with RMMZ that's not from Steam, the console opens but everything can only run locally.

FYI this is the screenshot from the console that opens:
devToolTesting Locally.png
Well obviously the path to greenworks is wrong. It should be ./greenworks
Well obviously the path to greenworks is wrong. It should be ./greenworks
OHHHHHHHH IT FINALLY WORKS!!!!!!! Thank you soooooo much!!!!!😂

But I'm a little curious (I don't know much about Javascript) that, why it should be ./greenworks not ../../greenworks ? greenworks.js is in the folder where Game.exe is and the initial plugin is in game/js/plugins folder, so I thought the plugin has to find greenworks.js in the parent folder's parent folder when functioning. 😅 Could you make some brief explanation in case others make the same mistake as me?
Well the path is relative to your current html file.
New Update Build Failed To Activate Achievements (Solved!)

Oh no here are some new issues:kaolivid:

1 - I fixed some bugs in my game with RMMZ today, after deployment, I found that the lib folder, greenworks.js, steam_appid.txt and package-lock.json didn't appear in the game folder.

↑So I manually copied them from the folder from the previous version
Edit: I tried again, and everything came along, but required me to change a path to deploy

2 - Then I upload a new build with SteamPipeGUI, just like the update on November 5. But a warning says that "steam_appid.txt shouldn't be included in Steam depots", this is the first time I saw it but I dunno how to check if everything is there.

↑So I set the new version to default

3 - Then I tested it, and found that the achievement cannot be activated!!!!!!

↑I urgently rolled back to the previous version, tested it again and the achievement successfully activated again, which means I may not be able to update???



@utunnels Hi, just want to make sure you noticed this new issue since I was managing Steam achievements following your steps👋EDIT: I just figured it out! Just don't name that file "steam_appid.txt", and update the new file name into greenworks.js, everything should be fine!
GUIDE: How to set up Steam achievements with Greenwork.js

Last Update Time: Dec. 10, 2024
​

In case some people might need a step-by-step guide, I'll put the one I've written before here, explaining how I got everything to work (unless you're looking for additional features beyond just activating achievements).:elhappy:

FYI: If you wanna test the achievements before putting them to the public, the better choice is to create a playtest version of your game on Steam (you can make the playtest invisible to others so you can test it alone safely). Just remember the playtest has a different app ID (you need to pay attention to it in a .txt file mentioned in Step 12 down below), and you have to set up the achievements twice on Steam (one for the playtest and one for the official version)


Phase 0: Set up all the achievements on the Steam manager's page


Phase 1: Download the needed files

1. Download Steamworks SDK 1.60 from the link on this page: https://partner.steamgames.com/doc/sdk

2. Download Greenworks v0.17.0 from this page: https://github.com/greenheartgames/greenworks/releases/tag/v0.17.0

3. Download NWjs v0.89.0 from this page: https://nwjs.io/blog/v0.89.0/


Phase 2: Manage the NWjs

4. Update RMMZ's NWjs to v0.89.0 (Following this guide from the forum, there's someone mentioned how to do with MZ there. Or follow my guide below🙂

4.1 Find the folder \Steam\steamapps\common\RPG Maker MZ\nwjs-win at where RPG Maker MZ is downloaded.

4.2 IMPORTANT: Back this folder up somewhere safe first! (I simply copied it to the Desktop.)

4.3 Copy everything from the folder (NWjs v0.89.0) downloaded from Step 3. to \Steam\steamapps\common\RPG Maker MZ\nwjs-win, click "replace" whenever the window popped out.



Phase 3: Create a Steam achievement plugin

5. Create a .txt file in game\js\plugins folder of the game project.

6. Copy the code I've put in the thread in this .txt file:
JavaScript:
function UnlockAchievement(achievement, success_callback, error_callback){
 try{
success_callback = success_callback||function(){};
error_callback = error_callback||function(){};
greenworks.activateAchievement(achievement, success_callback, error_callback);
}catch(ex){
console.log('failed to active achievement: ', achievement);
console.log(ex);
}
}


function ClearAchievement(achievement, success_callback, error_callback){
 try{
success_callback = success_callback||function(){};
error_callback = error_callback||function(){};
greenworks.clearAchievement(achievement, success_callback, error_callback);
}catch(ex){
console.log('failed to clear achievement: ', achievement);
console.log(ex);
}
}

7. Save it and rename the file from ".txt" to ".js".


Phase 4: Prepare a lib folder & other related files

8. Create a folder named "lib" in the game project folder (where the .rmmzproject lies).

9. Copy listed files from Steamworks SDK 1.60 folder to game\lib\
(NOTE: I'm using Windows 64-bit and the game deployed is only for 64-bit. You can find related files for other operating environments near these files down below if you need.)

9.1 Files needed to be copied from steamworks_sdk_160\win64:
  1. steam_api64.dll
  2. steam_api64.lib
9.2 Files needed to be copied from steamworks_sdk_160\public\steam\lib\win64:
  1. sdkencryptedappticket64.dll
  2. sdkencryptedappticket64.lib

10. Copy this file from Greenworks v0.17.0 folder to game\lib\
From greenworks-v0.17.0-nw-v0.89.0-win-64\lib:
  • greenworks-win64.node

Now the \lib\ file should be like this:
1733875052041.png


11. Copy this file from Greenworks v0.17.0 folder to game project folder (where the .rmmzproject lies)
From greenworks-v0.17.0-nw-v0.89.0-win-64:
  • greenworks.js

12. Create an appid.txt file (Not "steam_appid.txt" !) in the game project folder (where the .rmmzproject lies) and copy the app ID into it (It should only contain a string of numbers ending with a "0").

IMPORTANT: Since SteamPipe GUI from Steamworks SDK no longer allows users to contain a file named "steam_appid.txt" in their project, you can rename the .txt file (e.g., "appid.txt") and make sure Greenworks.js can call it.

12.5 Open the greenworks.js file in your game folder using Notepad or any text editor. Use the in-page search function (Ctrl+F in Windows, Command+F in Mac) to find "txt", then replace all "steam_appid.txt" with "appid.txt" and save it. (Make sure it still is "greenworks.js" in your folder!)


Phase 5: Manage the settings in the game project

13. Open the game project with MZ and activate the plugin made in Phase 3.

14. Wherever you want to activate an achievement, add a Script Call command in the Event, copy UnlockAchievement("YourAchieveName"); in its box, and change YourAchieveName into the actual achievement names (API Name) you set on Steam.

14.1 (During testing) When you want to lock an achievement in order to re-activate it again, use ClearAchievement("YourAchieveName"); in another Script Call.


Phase 6: Deploy the game and upload it to Steam

15. Deploy it with MZ, all the files and folders prepared from Phase 2-4 would come along 😉

Then the deployed file should be like this:
1733876036662.png


16. Then, run SteamPipeGUI.exe from steamworks_sdk_160\tools\SteamPipeGUI to upload your game.

The End: The achievement system is done!

That's all that I've done to make the Steam achievement system work with RMMZ.😊 Still not an expert, let me know if this doesn't work with your game (or worked eventually), so I can see if it is because I've missed something when writing this guide!😍
This thread is closed due to being marked solved. Report it next time so we can see! If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-with-guide-need-help-setting-steam-achievements-for-rmmz-game.171374/