Files
The_Bitburner_Scripts/Mizzajl/home/testgang.js
2024-10-21 03:32:32 +02:00

28 lines
783 B
JavaScript

export async function main(ns) {
ns.tail();
// Get the list of all task names
let aTasks = ns.gang.getTaskNames();
// Create an array to store task stats
let oTasks = [];
// Loop through each task and get the stats
for (let i = 0; i < aTasks.length; i++) {
let taskName = aTasks[i];
let taskStats = ns.gang.getTaskStats(taskName);
// Store task name and stats in an object and push to array
oTasks.push({
name: taskName,
stats: taskStats
});
}
// Convert the object to a JSON string for easy storage
let taskStatsString = JSON.stringify(oTasks, null, 2);
// Write the task stats to a file
await ns.write("GangTaskStats.txt", taskStatsString, "w");
ns.tprint("Gang task stats have been written to GangTaskStats.txt.");
}