Someone gifted MetalSlayer69 supporter status!
We need you on the team, too.
Support Newgrounds and get tons of perks for just $2.99!
Create a Free Account and then..
Become a Supporter!Also, please update the demo, It's medals[i], not medal[i]. As well as my problem where the asynchronous call (ngio.callComponent) was slower than the for loop. Here's my corrected code:
if (ngio.user) { console.log('Get', medal_name, 'ID...'); for (var i = 0; i < medals.length; i++) { medal = medals[i]; /* look for a matching medal name */ if (medal.name == medal_name) { console.log('Medal Found!', medal_name, '=', medal.id); break; } } if (medal === null) { console.log('No Medal found'); return; } /* we can skip unlocking a medal that's already been earned */ if (!medal.unlocked) { console.log('Unlock', medal.name); /* unlock the medal from the server */ ngio.callComponent('Medal.unlock', {id:medal.id}); } else { console.log('Have medal:', medal); } } else { console.log('Error@ngio.getValidSession') }
Also, please update the demo, It's medals[i], not medal[i]. As well as my problem where the asynchronous call (ngio.callComponent) was slower than the for loop. Here's my corrected code:
if (ngio.user) { console.log('Get', medal_name, 'ID...'); for (var i = 0; i < medals.length; i++) { medal = medals[i]; /* look for a matching medal name */ if (medal.name == medal_name) { console.log('Medal Found!', medal_name, '=', medal.id); break; } } if (medal === null) { console.log('No Medal found'); return; } /* we can skip unlocking a medal that's already been earned */ if (!medal.unlocked) { console.log('Unlock', medal.name); /* unlock the medal from the server */ ngio.callComponent('Medal.unlock', {id:medal.id}); } else { console.log('Have medal:', medal); } } else { console.log('Error@ngio.getValidSession') }
The issue might be related to this, too.