Bitburner: Script di calcolo del tempo (come ottenere il tempo)

uno script per utilizzare l'API delle formule per calcolare quanto tempo dobbiamo aspettare per un certo livello di hacking basato solo sull'exp per i nostri script di hacking (se abbiamo l'API delle formule, i nostri script di solito ottengono più exp di qualsiasi altro metodo può essere confrontato con a quel punto)
come utilizzare

incolla il codice in un file .js o .ns

ad esempio timetohack.js

quindi per usarlo vai al tuo terminale ed eseguilo con il tuo livello di destinazione come argomento

per esempio

esegui timetohack.js 2500

stamperà quanto tempo dovrai aspettare al terminale

il codice
function timeformat(input) {
	var sec_num = parseInt(input, 10); // don't forget the second param
	var hours = Math.floor(sec_num / 3600);
	var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
	var seconds = sec_num - (hours * 3600) - (minutes * 60);

	if (hours > 24) { return Math.floor(hours / 24) + " days" }
	if (hours < 0) { hours = 0; }
	if (hours < 10) { hours = "0" + hours; }
	if (minutes < 10) { minutes = "0" + minutes; }
	if (seconds < 10) { seconds = "0" + seconds; }
	return hours + ':' + minutes + ':' + seconds;
}
/** @param {NS} ns **/
export async function main(ns) {
	var skill = ns.args[0];
	var player = ns.getPlayer();
	var mult = player.hacking_mult;
	var sk = ns.formulas.skills;
	var target = sk.calculateExp(skill, mult);
	var left = target - player.hacking_exp;
	var time = left / ns.getScriptExpGain();
	ns.tprint(timeformat(time))
}
follow-up

questa versione dello script è piuttosto semplice perché sono pigro ma è abbastanza utile da solo.

poiché è di base, puoi usarlo come esempio per creare qualcosa di più utile, alcuni dei giocatori più avanzati potrebbero probabilmente aggiungere un conto alla rovescia all'interfaccia utente o qualcosa di interessante del genere.

Altre guide:

1 pensiero su "Bitburner: Script di calcolo del tempo (come ottenere il tempo)"

Lascia un tuo commento

ArabicEnglishFrenchGermanItalianJapaneseKoreanPortugueseSpanish