Bitburner

Bitburner

View Stats:
formulas.exe
what is the formulas API and how do I use it?
< >
Showing 1-9 of 9 comments
player144 Dec 29, 2021 @ 10:25am 
https://github.com/danielyxie/bitburner/blob/dev/markdown/bitburner.md

Formulas is in that list as well as a whole bunch of other stuff..
Lord Honk Dec 29, 2021 @ 10:26am 
It's a collection of functions meant to make some calculations for you, for example the function "hackTime()" tells you how long it would take to hack a specific server; it's mainly used to automate things, for example if you wanted to estimate how long your scripts would have to run, stuff like that.

The documentation[github.com] can help you find which functions are available and how to use them, but to give a basic example:
/** @param {NS} ns **/ export async function main(ns) { var time = ns.formulas.hacking.growTime(ns.getServer("n00dles"), ns.getPlayer()) * 1000; //the *1000 might not be necessary?? ns.print("Sleeping for "+time+" milliseconds"); sleep(time); }

In the important bit, the variable time, ns is the namespace for netscript, formulas the one for, well, the formulas, hacking the one that has all the hacking-related formulas, and finally growTime() is the function that gets the time to grow the server "noodles"; the getPlayer part is important because the hacking time includes your multipliers, like you get from augments.

This example isn't very useful, but I hope together with the docs you can make out how to use the formulas API. Good luck, and I hope you come up with some interesting scripts :)
joshskateboarding Dec 29, 2021 @ 11:42am 
Originally posted by Lord Honk:
It's a collection of functions meant to make some calculations for you, for example the function "hackTime()" tells you how long it would take to hack a specific server; it's mainly used to automate things, for example if you wanted to estimate how long your scripts would have to run, stuff like that.

The documentation[github.com] can help you find which functions are available and how to use them, but to give a basic example:
/** @param {NS} ns **/ export async function main(ns) { var time = ns.formulas.hacking.growTime(ns.getServer("n00dles"), ns.getPlayer()) * 1000; //the *1000 might not be necessary?? ns.print("Sleeping for "+time+" milliseconds"); sleep(time); }

In the important bit, the variable time, ns is the namespace for netscript, formulas the one for, well, the formulas, hacking the one that has all the hacking-related formulas, and finally growTime() is the function that gets the time to grow the server "noodles"; the getPlayer part is important because the hacking time includes your multipliers, like you get from augments.

This example isn't very useful, but I hope together with the docs you can make out how to use the formulas API. Good luck, and I hope you come up with some interesting scripts :)

thanks so much!
joshskateboarding Dec 29, 2021 @ 11:42am 
Originally posted by player144:
https://github.com/danielyxie/bitburner/blob/dev/markdown/bitburner.md

Formulas is in that list as well as a whole bunch of other stuff..

thanks for the link!
tclord Dec 29, 2021 @ 2:07pm 
The formula stuff isn't really that useful most of the time. There are a lot of functions to get similar sort of information. One thing that it can do, though, is do calculations on theoretical servers. Most of the normal free functions work on a actual server. With these functions you can run calculation on a server object you provide, which you can set the details to whatever you want. So like comparing all the servers to see which is best, you probably want to analyze them based on their minimum security values, rather than their current security values. So you can get a copy of the server data object, change the current security to equal it's minimum security and pass that to the formula functions and get the values you really want, without having to go through and actually weaken every server out there first. Things like that make the formula module useful but otherwise you don't really need it.
Veldrin Dec 29, 2021 @ 3:46pm 
It is most useful for determining a sequence of actions to perform when you take advantage of doing calculations on a theoretical player as well. Action A may be better than action B in a direct comparison but if you did action B first you could get a better result from action A.
VoidByte Jun 8, 2022 @ 9:58am 
Mh... it seems like this should be avaible from the first game start. Not something you will just enter after you finish the whole game.
n0n0 Oct 24, 2023 @ 11:19pm 
2
Originally posted by player144:
https://github.com/danielyxie/bitburner/blob/dev/markdown/bitburner.md

Formulas is in that list as well as a whole bunch of other stuff..

Since this post is the first result when searching "bitburner formulas.exe" in DuckDuckGo, the updated github link is https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.md
Originally posted by VoidByte:
Mh... it seems like this should be avaible from the first game start. Not something you will just enter after you finish the whole game.
according to discord everything before finnishing fl1ght.exe is considered "early-game", then until "seeing the truth" midgame
< >
Showing 1-9 of 9 comments
Per page: 1530 50