Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Last active October 29, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dsetzer/d4b758d4130f3e2fc6c0788f2b94fa5f to your computer and use it in GitHub Desktop.
Save dsetzer/d4b758d4130f3e2fc6c0788f2b94fa5f to your computer and use it in GitHub Desktop.
Utility script for use in bustabit script simulator which outputs the number of games played within a specified duration as well as the average game count.
var config = {
duration: { type: 'number', label: 'Duration (ms)', value: (1000 * 60 * 60)} // default = 1 hour
};
// https://dsetzer.github.io/bustabit-script-simulator/
let games = 0, counts = config.duration.value, avgCounts = [];
engine.on('GAME_ENDED', ()=>{
games++;
if(userInfo.duration > counts){
counts = userInfo.duration + config.duration.value;
avgCounts.push(games);
log(`Games Counted: ${games}, Average: ${avgCounts.reduce((a,b)=>(a+b))/avgCounts.length}`);
games = 0;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment