How to make a simple cat viewer program in BitBurner!
Making the .ns File
Open the editor with
nano GetCat.ns
and then paste the following code:
export async function main(ns) { await ns.wget("https://api.thecatapi.com/v1/images/search" - [] , "json.txt"); var content = await ns.read("json.txt"); var url = JSON.parse(content)[0]["url"]; await ns.write(ns.args[0], `<html><body><img src=\"${url}\"></img></body></html>`, "w"); };
Make sure to save with Ctrl+B!
Using the File
To get your cat images, simply run
run GetCat.ns img.txt; cat img.txt
Alternatively, you can use a different file name to store the cat image.
NOTE: Due to file write time delays, the first time you run the script will likely cause an error. Just run it again.
This is all about Bitburner – How to Create Cat Viewer Program; I hope you enjoy reading the Guide! If you feel like we should add more information or we forget/mistake, please let us know via commenting below, and thanks! See you soon!
- All Bitburner Posts List
Leave a Reply