At 8/30/25 11:51 PM, SumMadLad wrote:Thank you for the quick reply! I'm not entirely sure if I would be able to pull the medal list from the ng_initialize_medals_and_scoreboards() function.
Hi, you're absolutely right, I checked, and you can't interact with the JavaScript library unless you create functions to import into GameMaker.
By the way, since you're learning, Java and JavaScript are two different languages and aren't even very similar. In the context of Newgrounds.io and web scripting in general, it's JavaScript. Java is used mainly for multiplatform executable applications.
At 8/30/25 11:51 PM, SumMadLad wrote:I think I would have to create functions in java (like the GMS 2 api), then import them into Gamemaker to be read. which I have no idea where to even begin with that, since I don't have knowledge on java, or how to take the ng.io api into java to code with.
Yeah, I understand.
For me, it's the opposite; I know the JavaScript you need to call, but getting it to work with GML is the problem. :P
So I took a stab at it, and I think I managed to update the extension with two new functions:
- ng_is_connected()
- ng_check_medal(medal)
The first one is to check if you have a valid user session (it's pointless to try to get any information if the user isn't even connected yet), and the second one is what you want, check that a Newgrounds medal is already unlocked.
I didn't add anything to give you the entire list of medals from Medal.getList, because imported functions must return either string or a number, so returning a list of objects would be much trickier. But hopefully you don't have too many medals and it's okay to check them individually.
You can see the project here.
I described some steps to add new functions in the description, in case you would eventually feel confident to try. JavaScript syntax isn't too dissimilar from GML – for example, this is the entire JS I added:
function ng_is_connected() {
var username = ng_get_username();
return username != null && username.length > 0;
}
function ng_check_medal(medal_name){
// medals are not loaded yet
if (medals == undefined)
return "false";
// find the medal matching the medal_name
for (var i = 0; i < medals.length; i++) {
var medal = medals[i];
if (medal.name == medal_name || medal.id == medal_name) {
return medal.unlocked;
}
}
return "false"; // GML converts this to false. The return type must be string or double
}
Does it look like something you could read and potentially edit?
---
I still didn't want to dig into cloud saves, because it's done differently than the rest of the library, using HTTP asynchronous requests directly from GameMaker, and I'd have to spend a while learning the proper way to do it in GML to be able to help you with that.
But if you try importing the modified extension, does it work for you and help you do what you need?
Also, what would be an example of a medal that relies on other medals? Because perhaps there's a way to do it differently (e.g. if it's score-based, you could load the player's highest score at start and continue with that).