Original Source
- Original title: Achievements on Steam - How to put it on MV?
- Original author: Metthink
- Original date: August 25, 2022
- Source thread: https://forums.rpgmakerweb.com/threads/achievements-on-steam-how-to-put-it-on-mv.150780/
- Source forum path: Game Development Engines > Legacy Engine Support > RPG Maker MV Support
Summary
I'm using these Orange Greenworks plugins: Spoiler: greenworks.js // Copyright (c) 2015 Greenheart Games Pty. Ltd. All rights reserved. // Use of this source code is governed by the MIT license that can be
Archived First Post
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
// The source code can be found in https://github.com/greenheartgames/greenworks
var fs = require('fs');
var greenworks;
if (process.platform == 'darwin') {
if (process.arch == 'x64')
greenworks = require(__dirname + '/lib/greenworks-osx64');
} else if (process.platform == 'win32') {
if (process.arch == 'x64')
greenworks = require(__dirname + '/lib/greenworks-win64');
else if (process.arch == 'ia32')
greenworks = require(__dirname + '/lib/greenworks-win32');
} else if (process.platform == 'linux') {
if (process.arch == 'x64')
greenworks = require(__dirname + '/lib/greenworks-linux64');
else if (process.arch == 'ia32')
greenworks = require(__dirname + '/lib/greenworks-linux32');
}
function error_process(err, error_callback) {
if (err && error_callback)
error_callback(err);
}
greenworks.ugcGetItems = function(options, ugc_matching_type, ugc_query_type,
success_callback, error_callback) {
if (typeof options !== 'object') {
error_callback = success_callback;
success_callback = ugc_query_type;
ugc_query_type = ugc_matching_type;
ugc_matching_type = options;
options = {
'app_id': greenworks.getAppId(),
'page_num': 1
}
}
greenworks._ugcGetItems(options, ugc_matching_type, ugc_query_type,
success_callback, error_callback);
}
greenworks.ugcGetUserItems = function(options, ugc_matching_type,
ugc_list_sort_order, ugc_list, success_callback, error_callback) {
if (typeof options !== 'object') {
error_callback = success_callback;
success_callback = ugc_list;
ugc_list = ugc_list_sort_order;
ugc_list_sort_order = ugc_matching_type;
ugc_matching_type = options;
options = {
'app_id': greenworks.getAppId(),
'page_num': 1
}
}
greenworks._ugcGetUserItems(options, ugc_matching_type, ugc_list_sort_order,
ugc_list, success_callback, error_callback);
}
greenworks.ugcSynchronizeItems = function (options, sync_dir, success_callback,
error_callback) {
if (typeof options !== 'object') {
error_callback = success_callback;
success_callback = sync_dir;
sync_dir = options;
options = {
'app_id': greenworks.getAppId(),
'page_num': 1
}
}
greenworks._ugcSynchronizeItems(options, sync_dir, success_callback,
error_callback);
}
greenworks.publishWorkshopFile = function(options, file_path, image_path, title,
description, success_callback, error_callback) {
if (typeof options !== 'object') {
error_callback = success_callback;
success_callback = description;
description = title;
title = image_path;
image_path = file_path;
file_path = options;
options = {
'app_id': greenworks.getAppId(),
'tags': []
}
}
greenworks._publishWorkshopFile(options, file_path, image_path, title,
description, success_callback, error_callback);
}
greenworks.updatePublishedWorkshopFile = function(options,
published_file_handle, file_path, image_path, title, description,
success_callback, error_callback) {
if (typeof options !== 'object') {
error_callback = success_callback;
success_callback = description;
description = title;
title = image_path;
image_path = file_path;
file_path = published_file_handle;
published_file_handle = options;
options = {
'tags': [] // No tags are set
}
}
greenworks._updatePublishedWorkshopFile(options, published_file_handle,
file_path, image_path, title, description, success_callback,
error_callback);
}
// An utility function for publish related APIs.
// It processes remains steps after saving files to Steam Cloud.
function file_share_process(file_name, image_name, next_process_func,
error_callback, progress_callback) {
if (progress_callback)
progress_callback("Completed on saving files on Steam Cloud.");
greenworks.fileShare(file_name, function() {
greenworks.fileShare(image_name, function() {
next_process_func();
}, function(err) { error_process(err, error_callback); });
}, function(err) { error_process(err, error_callback); });
}
// Publishing user generated content(ugc) to Steam contains following steps:
// 1. Save file and image to Steam Cloud.
// 2. Share the file and image.
// 3. publish the file to workshop.
greenworks.ugcPublish = function(file_name, title, description, image_name,
success_callback, error_callback, progress_callback) {
var publish_file_process = function() {
if (progress_callback)
progress_callback("Completed on sharing files.");
greenworks.publishWorkshopFile(file_name, image_name, title, description,
function(publish_file_id) { success_callback(publish_file_id); },
function(err) { error_process(err, error_callback); });
};
greenworks.saveFilesToCloud([file_name, image_name], function() {
file_share_process(file_name, image_name, publish_file_process,
error_callback, progress_callback);
}, function(err) { error_process(err, error_callback); });
}
// Update publish ugc steps:
// 1. Save new file and image to Steam Cloud.
// 2. Share file and images.
// 3. Update published file.
greenworks.ugcPublishUpdate = function(published_file_id, file_name, title,
description, image_name, success_callback, error_callback,
progress_callback) {
var update_published_file_process = function() {
if (progress_callback)
progress_callback("Completed on sharing files.");
greenworks.updatePublishedWorkshopFile(published_file_id,
file_name, image_name, title, description,
function() { success_callback(); },
function(err) { error_process(err, error_callback); });
};
greenworks.saveFilesToCloud([file_name, image_name], function() {
file_share_process(file_name, image_name, update_published_file_process,
error_callback, progress_callback);
}, function(err) { error_process(err, error_callback); });
}
// Greenworks Utils APIs implmentation.
greenworks.Utils.move = function(source_dir, target_dir, success_callback,
error_callback) {
fs.rename(source_dir, target_dir, function(err) {
if (err) {
if (error_callback) error_callback(err);
return;
}
if (success_callback)
success_callback();
});
}
greenworks.init = function() {
if (this.initAPI()) return true;
if (!this.isSteamRunning())
throw new Error("Steam initialization failed. Steam is not running.");
var appId;
try {
appId = fs.readFileSync('steam_appid.txt', 'utf8');
} catch (e) {
throw new Error("Steam initialization failed. Steam is running," +
"but steam_appid.txt is missing. Expected to find it in: " +
require('path').resolve('steam_appid.txt'));
}
if (!/^\d+ *\r?\n?$/.test(appId)) {
throw new Error("Steam initialization failed. " +
"steam_appid.txt appears to be invalid; " +
"it should contain a numeric ID: " + appId);
}
throw new Error("Steam initialization failed, but Steam is running, " +
"and steam_appid.txt is present and valid." +
"Maybe that's not really YOUR app ID? " + appId.trim());
}
var EventEmitter = require('events').EventEmitter;
greenworks.__proto__ = EventEmitter.prototype;
EventEmitter.call(greenworks);
greenworks._steam_events.on = function () {
greenworks.emit.apply(greenworks, arguments);
};
process.versions['greenworks'] = greenworks._version;
module.exports = greenworks;
And I'm using this plugin too:
* Orange - Greenworks
* By Hudell - www.hudell.com
* OrangeGreenworks.js
* Version: 1.2
* Free for commercial and non commercial use.
*=============================================================================*/
/*:
* @plugindesc Steamworks Integration <OrangeGreenworks>
* @Author Hudell
*
* @Help
* ============================================================================
* Hudell's Plugins
* ============================================================================
*
* Check out my website to learn how to use this plugin:
* http://hudell.com/blog/orangegreenworks/
*
*=============================================================================*/
var Imported = Imported || {};
var Hudell = Hudell || {};
Hudell.OrangeGreenworks = Hudell.OrangeGreenworks || {};
(function($) {
"use strict";
$.getScreenName = function() {
return 'Play Test';
};
$.getUILanguage = function() {
return 'english';
};
$.getGameLanguage = function() {
return 'english';
};
$.activateAchievement = function(achievementName) {
console.log('Activate achievement ', achievementName);
};
$.getAchievement = function(achievementName) {
return false;
};
$.clearAchievement = function(achievementName) {
console.log('Clear achievement ', achievementName);
};
$.getNumberOfAchievements = function() {
return 0;
};
$.isSteamRunning = function() {
return false;
};
$.activateGameOverlay = function(option) {
};
$.isGameOverlayEnabled = function() {
return false;
};
$.activateGameOverlayToWebPage = function(url) {
console.log('Open URL');
};
$.getDLCCount = function() {
return 0;
};
$.isDLCInstalled = function(dlcAppId) {
return false;
};
$.installDLC = function(dlcAppId) {
};
$.uninstallDLC = function(dlcAppId) {
};
$.getStatInt = function(name) {
return 0;
};
$.getStatFloat = function(name) {
return 0;
};
$.setStat = function(name, value) {
console.log('Change Stat', name, value);
return false;
};
$.storeStats = function() {
console.log('Store Stats');
return false;
};
$.isSubscribedApp = function(appId) {
return false;
};
if (Utils.isNwjs()) {
$.initialized = false;
try {
$.greenworks = require('./greenworks');
}
catch(e) {
$.greenworks = false;
console.log('Greenworks failed to load. Make sure you copied all files from the Steamworks SDK to the right folders;');
console.log('http://hudell.com/blog/orange-greenworks');
console.error(e);
}
if (!!$.greenworks) {
$.initialized = $.greenworks.initAPI();
if (!$.initialized) {
console.log('Greenworks failed to initialize.');
return;
}
$.steamId = $.greenworks.getSteamId();
console.log('Steam User: ', $.steamId.screenName);
$.getScreenName = function() {
return $.steamId.screenName;
};
$.getUILanguage = function() {
return $.greenworks.getCurrentUILanguage();
};
$.getGameLanguage = function() {
return $.greenworks.getCurrentGameLanguage();
};
$.isSteamRunning = function() {
return $.greenworks.isSteamRunning();
};
$._storeStatsSuccess = function(){
console.log('Stored Stats Successfully', arguments);
};
$._storeStatsError = function(){
console.log('Failed to Store Stats', arguments);
};
$._achievementSuccess = function(){
console.log('Achievement activated', arguments);
};
$._achievementError = function(){
console.log('Achievement activation error', arguments);
};
$._clearAchievementSuccess = function(){
console.log('Successfully Cleared Achievement', arguments);
};
$._clearAchievementError = function(){
console.log('Failed to Clear Achievement', arguments);
};
$._getAchievementSuccess = function(){
};
$._getAchievementError = function(){
console.log('Failed to check Achievement', arguments);
};
$.activateAchievement = function(achievementName) {
if (!achievementName) {
console.log('Achievement name not provided.');
return;
}
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return;
}
$.greenworks.activateAchievement(achievementName, $._achievementSuccess, $._achievementError);
};
$.getAchievement = function(achievementName) {
if (!achievementName) {
console.log('Achievement name not provided.');
return false;
}
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.getAchievement(achievementName, $._getAchievementSuccess, $._getAchievementError);
};
$.clearAchievement = function(achievementName) {
if (!achievementName) {
console.log('Achievement name not provided.');
return false;
}
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
$.greenworks.clearAchievement(achievementName, $._clearAchievementSuccess, $._clearAchievementError);
};
$.getNumberOfAchievements = function() {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.getNumberOfAchievements();
};
$.activateGameOverlay = function(option) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
$.greenworks.activateGameOverlay(option);
};
$.isGameOverlayEnabled = function() {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.isGameOverlayEnabled();
};
$.activateGameOverlayToWebPage = function(url) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
$.greenworks.activateGameOverlayToWebPage(url);
};
$.isSubscribedApp = function(appId) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.isSubscribedApp(appId);
};
$.getDLCCount = function() {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return 0;
}
return $.greenworks.getDLCCount();
};
$.isDLCInstalled = function(dlcAppId) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.isDLCInstalled(dlcAppId);
};
$.installDLC = function(dlcAppId) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
$.greenworks.installDLC(dlcAppId);
};
$.uninstallDLC = function(dlcAppId) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
$.greenworks.uninstallDLC(dlcAppId);
};
$.getStatInt = function(name) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return 0;
}
return $.greenworks.getStatInt(name);
};
$.getStatFloat = function(name) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return 0;
}
return $.greenworks.getStatFloat(name);
};
$.setStat = function(name, value) {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.setStat(name, value);
};
$.storeStats = function() {
if (!$.isSteamRunning()) {
console.log('Steam isn\'t running');
return false;
}
return $.greenworks.setStat($._storeStatsSuccess, $._storeStatsError);
};
$.getFriendCount = function() {
return $.greenworks.getFriendCount($.greenworks.FriendFlags.Immediate);
};
$.isCloudEnabled = function() {
return $.greenworks.isCloudEnabled();
};
$.isCloudEnabledForUser = function() {
return $.greenworks.isCloudEnabledForUser();
};
}
}
})(Hudell.OrangeGreenworks);
OrangeGreenworks = Hudell.OrangeGreenworks;
Imported.OrangeGreenworks = 1.2;
I don't know how I start this. But I found these plugins above and they are in my game right now. What I would like to know is how can I reach to the moment that I use the command "Call Script" and put the code which makes player earns an achievement on STEAM PAGE.
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
// Use of this source code is governed by the MIT license that can be // found in the LICENSE file. // The source code can be found in https://github.com/greenheartgames/greenworks var fs = require('fs');
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...