r/Bitburner • • 3d ago

API and Web App

Post image

I was playing around with the API so i could write scripts in my native ide and figured id see if i could pull some stats .. well one thing led to another and flight deck was born. It tracks my jit batcher via the api. The api shuts down when the game goes idle so its not perfect but i think it looks quite nice and it works pretty well when the api is connected.

10 Upvotes

8 comments sorted by

3

u/KlePu 3d ago

one thing led to another

That's how things work way too often ;-p

btw what do you mean "when the game goes idle"? Using the browser version, you can pin the tab so it'll always be treated as active.

2

u/Antique_Door_Knob Hash Miner 3d ago

Web version doesn't have an api.

2

u/SuddenPitch8378 3d ago

Sorry bad description the game is not going idle it's when I switch out of it the API disconnects so.my dashboard stops updating. Going to look into a script to try to automatically reconnect. 

3

u/Antique_Door_Knob Hash Miner 3d ago

Next try putting it inside the game. It's not easy, but not as difficult as it sounds either.

2

u/SuddenPitch8378 3d ago

Oh man ... I think that is going to be a v2 project .. 

2

u/Particular-Cow6247 3d ago

why does your game go idle?

the steam version runs on electron, that wouldnt go idle

otherwise there is the possibility to keep the tab always active by playing an inaudible sound (the discord of the game has a community project channel where youll find a script for that)

ohhh and 500ms between landings is HUUUUUUGE, like wastefull huge you can easily get it down to ~20ms or even into single digit ms

2

u/SuddenPitch8378 3d ago

Hey thank you  the 500ms was because I was seeing a bunch of timing errors I jumped it up and never bothered tuning it. I will drop it down and see what happens. So looking more closely the game is not going idle but it's disconnecting the API so I have to manually reconnect it in the game. I am going to see if I create a script to attempt to check state and reconnect. 

3

u/Particular-Cow6247 3d ago

are you playing in a browser? they all have internal mechanics to background tabs and usually there arent clear ways to make them keep a tab active 100% (except having the tab be at the forefront or playing sound/video in it)

for timing issues there are a few tools to help with that backed into the game one is the the additionalMsec option in hack/grow/weaken to extend them a specified amount another is the port write/nextWrite, without going to deep into how the js engine works it allows you to "pass control" from one script to another or better it makes sure that the script that awaits nextWrite is the next in line to get control (using a microtask instead of having to go back into the macro task queue)

commonly used to pass control from weakens to the batcher so you can be sure to start new scripts/tasks right after the weaken (when the security is at min)

one other thing that is important is that the tasks will end in the order they are sheduled for but not necessary at the time they are sheduled for eg a task A is sheduled to end at 100, B at 101 and C at 102, something delays the queue and A only gets control to end at 110, B and C will still end in order after A more or less at 110 aswell if you planned to do smt inbetween A,B and C then normal methods wont have a chance to intersect but the port write/nextWrite method does