Netscript 2.0, or Netscript JS, is the new and improved version of Netscript that
+allows users to write (almost) full-fledged Javascript code in their scripts, while
+still being able to access the Netscript functions.
On top of having almost all of the features and capabilities of Javascript, NetscriptJS is also
+significantly faster than Netscript 1.0.
+
This documentation will not go over any of the additional features of NetscriptJS, since
+there is plenty of documentation on Javascript available on the web.
As of the time of writing this, the Mozilla Firefox browser does not support
+dynamic import functionality and therefore cannot run NetscriptJS scripts.
+
(This may be some option/method for enabling this in Firefox, but I don't know
+what is it)
Working with NetscriptJS scripts is the same as Netscript 1.0 scripts. The only difference
+is that NetscriptJS scripts use the ".ns" or ".js" extension rather than ".script". E.g.:
The caveat when using NetscriptJS to write scripts is that your code must be
+asynchronous. Furthermore, instead of using the global scope and executing your code
+sequentially, NetscriptJS uses a main() function as an entry point.
+
Furthermore, the "Netscript environment" must be passed into a NetscriptJS script through
+the main function. This environment includes all of the pre-defined Netscript functions
+(hack(), exec, etc.) as well as the arguments you pass to the script.
+
Therefore, the signature of the main() function must be:
Here is a summary of all rules you need to follow when writing Netscript JS code:
+
+
Write await before any call to the following Netscript functions:
+
+
+
hack
+
grow
+
weaken
+
sleep
+
run
+
exec
+
prompt
+
+
+
+
Any function that contains await must be declared as async
+
+
Always await any function that is marked as async
+
+
Any functions that you want to be visible from other scripts must be marked with export.
+
+
Do not write any infinite loops without using a sleep or one of the timed Netscript functions like hack. Doing so will crash your game.
+
+
Any global variable declared in a NetscriptJS script is shared between all instances of that
+script. For example, assume you write a script foo.ns and declared a global variable like so:
$ run foo.ns 1
+$ run foo.ns 1 2 3
+$ run foo.ns 1 2 3 4 5
+
+
+
Then all three instances of foo.ns will share the same instance of globalVariable.
+(In this example, the value of globalVariable will be set to 5 because the
+last instance of foo.ns to run has 5 arguments. This means that all three instances of
+the script will repeatedly print the value 5).
+
These global variables can be thought of as C++ static class members,
+where a NetscriptJS script is a class and a global variable is a static member within that class.
The NetscriptJS evaluation engine works by converting your code into a blob URL and then
+using a dynamic import to load your code as a module. Every unique NetscriptJS script
+is loaded as its own module. This means that
+making a small edit to a NetscriptJS script results in a new module being generated.
+
At this point, we have been unable to find a method for deleting modules from browsers so that
+they get garbage collected.
+
The result is that these modules from NetscriptJS scripts accumulate in your browser,
+using memory that never gets released. Over time, this results in a memory-leak type
+situation that can slow down your computer.
+
Therefore, there are two recommendations for those who decide to use NetscriptJS:
+
1. Every now and then, close and re-open the game. This will clear all of the modules.
+To be safe, I recommend completely closing the game's tab and then re-opening it.
+Depending on your browser, a refresh or page reload does not always clear the modules.
+
2. Only use NetscriptJS scripts when needed. It is very unlikely that NetscriptJS
+is needed for very simple scripts. By doing this, you will reduce the number of modules
+that are loaded.
This script shows some of the new functionality that is available in NetscriptJS,
+including objects and object constructors, changing an object's prototype, and
+importing other NetscriptJS scripts:
NetscriptJS opens up a lot of possibilities when scripting. I look forward to seeing
+the scripts that people come up with. Just remember that the power and capabilities of
+NetscriptJS come with risks. Please backup your save if you're going to experiment with
+NetscriptJS and report any serious exploits.
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/build/html/objects.inv b/doc/build/html/objects.inv
index 3327a694f..51102570a 100644
Binary files a/doc/build/html/objects.inv and b/doc/build/html/objects.inv differ
diff --git a/doc/build/html/searchindex.js b/doc/build/html/searchindex.js
index 103575010..1a9891414 100644
--- a/doc/build/html/searchindex.js
+++ b/doc/build/html/searchindex.js
@@ -1 +1 @@
-Search.setIndex({docnames:["index","netscript","netscriptadvancedfunctions","netscriptdatatypes","netscriptfunctions","netscripthacknetnodeapi","netscriptixapi","netscriptloopsandconditionals","netscriptmisc","netscriptoperators","netscriptscriptarguments","netscriptsingularityfunctions","shortcuts","terminal"],envversion:53,filenames:["index.rst","netscript.rst","netscriptadvancedfunctions.rst","netscriptdatatypes.rst","netscriptfunctions.rst","netscripthacknetnodeapi.rst","netscriptixapi.rst","netscriptloopsandconditionals.rst","netscriptmisc.rst","netscriptoperators.rst","netscriptscriptarguments.rst","netscriptsingularityfunctions.rst","shortcuts.rst","terminal.rst"],objects:{"":{applyToCompany:[11,2,1,""],buyStock:[6,2,1,""],cancelOrder:[6,2,1,""],checkFactionInvitations:[11,2,1,""],clearLog:[4,2,1,""],commitCrime:[11,2,1,""],createProgram:[11,2,1,""],deleteServer:[4,2,1,""],disableLog:[4,2,1,""],enableLog:[4,2,1,""],fileExists:[4,2,1,""],getAugmentationCost:[11,2,1,""],getAugmentationsFromFaction:[11,2,1,""],getBitNodeMultipliers:[2,2,1,""],getCompanyFavor:[11,2,1,""],getCompanyRep:[11,2,1,""],getCrimeChance:[11,2,1,""],getFactionFavor:[11,2,1,""],getFactionRep:[11,2,1,""],getGrowTime:[4,2,1,""],getHackTime:[4,2,1,""],getHackingLevel:[4,2,1,""],getHackingMultipliers:[4,2,1,""],getHacknetMultipliers:[5,2,1,""],getHostname:[4,2,1,""],getNextHacknetNodeCost:[5,2,1,""],getOwnedAugmentations:[11,2,1,""],getPurchasedServers:[4,2,1,""],getScriptExpGain:[4,2,1,""],getScriptIncome:[4,2,1,""],getScriptName:[4,2,1,""],getScriptRam:[4,2,1,""],getServerBaseSecurityLevel:[4,2,1,""],getServerGrowth:[4,2,1,""],getServerMaxMoney:[4,2,1,""],getServerMinSecurityLevel:[4,2,1,""],getServerMoneyAvailable:[4,2,1,""],getServerNumPortsRequired:[4,2,1,""],getServerRam:[4,2,1,""],getServerRequiredHackingLevel:[4,2,1,""],getServerSecurityLevel:[4,2,1,""],getStats:[11,2,1,""],getStockPosition:[6,2,1,""],getStockPrice:[6,2,1,""],getTimeSinceLastAug:[4,2,1,""],getUpgradeHomeRamCost:[11,2,1,""],getWeakenTime:[4,2,1,""],gymWorkout:[11,2,1,""],hasRootAccess:[4,2,1,""],installAugmentations:[11,2,1,""],isBusy:[11,2,1,""],isRunning:[4,2,1,""],joinFaction:[11,2,1,""],placeOrder:[6,2,1,""],purchaseAugmentation:[11,2,1,""],purchaseHacknetNode:[5,2,1,""],purchaseProgram:[11,2,1,""],purchaseServer:[4,2,1,""],purchaseTor:[11,2,1,""],scriptKill:[4,2,1,""],scriptRunning:[4,2,1,""],sellShort:[6,2,1,""],sellStock:[6,2,1,""],serverExists:[4,2,1,""],shortStock:[6,2,1,""],stopAction:[11,2,1,""],travelToCity:[11,2,1,""],universityCourse:[11,2,1,""],upgradeHomeRam:[11,2,1,""],workForCompany:[11,2,1,""],workForFaction:[11,2,1,""]},"hacknetnodes[i]":{cores:[5,1,1,""],getCoreUpgradeCost:[5,0,1,""],getLevelUpgradeCost:[5,0,1,""],getRamUpgradeCost:[5,0,1,""],level:[5,1,1,""],moneyGainRatePerSecond:[5,1,1,""],name:[5,1,1,""],onlineTimeSeconds:[5,1,1,""],ram:[5,1,1,""],totalMoneyGenerated:[5,1,1,""],upgradeCore:[5,0,1,""],upgradeLevel:[5,0,1,""],upgradeRam:[5,0,1,""]},NetscriptPort:{clear:[8,0,1,""],data:[8,1,1,""],empty:[8,0,1,""],full:[8,0,1,""],tryWrite:[8,0,1,""],write:[8,0,1,""]}},objnames:{"0":["js","method","JavaScript method"],"1":["js","attribute","JavaScript attribute"],"2":["js","function","JavaScript function"]},objtypes:{"0":"js:method","1":"js:attribute","2":"js:function"},terms:{"1e3":13,"50e3":13,"8gb":5,"boolean":[3,4,11],"break":10,"case":[4,6,11,13],"class":[11,12],"default":[4,11,12,13],"export":8,"float":3,"function":[0,1,3,5,6,7,12,13],"import":[0,1,4,13],"long":6,"new":[4,5,8,11,12,13],"null":[4,8],"return":[2,4,5,6,8,9,11,12],"short":6,"static":8,"switch":12,"true":[3,4,5,6,8,9,11],"try":[4,8,10,11],"var":7,"while":[4,5,7,8,11,13],AND:9,Ace:12,Adding:3,And:8,For:[2,3,4,5,7,8,9,10,13],IPs:4,NOT:[4,6,9,11,12,13],Not:11,One:11,The:[0,2,3,4,5,6,7,8,10,11,13],Their:3,Then:[5,8,13],There:8,These:[2,4,5,11,12,13],Use:4,Will:[4,6,12],Yes:4,_termin:[],abbrevi:13,abil:6,abl:11,about:[3,4,8,11,13],abov:[3,4,8,9,13],accept:11,access:[3,4,5,6,8,10,11,13],action:[11,12],activ:[4,12],actual:[4,6,8,11,13],add:[5,13],added:4,addit:[4,5,9,11],address:[4,13],adjac:13,advanc:[0,1],aevum:11,affect:4,afford:[4,5],after:[3,4,6,8,11,13],afterward:13,agenc:[11,12],agent:11,agi:11,agil:11,aid:0,aka:[11,12],algorithm:[6,11],alia:0,alias:13,all:[3,4,5,6,8,11,13],allow:[6,8,11,13],almost:[1,12],alphabet:[4,13],alphanumer:3,alreadi:[4,11,13],also:[3,4,6,10,11,12,13],alt:[12,13],altern:13,although:11,alwai:12,amount:[4,5,6,10,11,13],analyz:[0,12],ani:[0,1,3,4,11,12,13],anoth:[4,8,10,13],anyth:4,anytim:13,anywher:[4,13],api:[0,1],appear:4,append:4,appli:[4,11],applic:11,applytocompani:[0,1],arg:[4,8,10,13],argument:[0,1,4,5,6,8,11,13],arm:11,around:[0,11],arrai:[3,4,5,6,8,10,11],arrow:[12,13],aspect:11,assassin:11,assign:[5,9],assum:8,attack:4,attempt:[6,8,11,13],augment:[4,6,11,12],augmentationmoneycost:2,augmentationrepcost:2,augnam:11,auto:11,autocomplet:12,autolink:11,autom:[5,6],automat:[4,6,11],avail:[3,4,6,7,11,12,13],averag:6,avgpx:6,avgpxshort:6,awai:13,back:8,background:13,backspac:12,base:[4,9],bash:0,basic:[0,1,13],becaus:[2,4,11,13],becom:2,been:0,befor:[4,8],begin:12,being:[4,13],below:4,best:10,beta:0,better:12,between:[2,4,8,12,13],billion:6,binari:[0,1],bind:12,bitburn:1,bitnod:[2,11],bond:11,both:[4,11,13],box:4,brief:[8,13],browser:[11,12],brutessh:[0,1,11,13],bui:[0,6,11],build:6,busi:11,buystock:[0,1],calcul:6,call:[0,4,5,8,10,11,13],callback:11,can:[0,3,4,5,6,7,8,10,11,12,13],cancel:[6,11,12],cancelord:[0,1],cannot:[4,5,13],capabl:3,capit:6,cat:0,caus:4,caveat:7,cbscript:11,certain:[4,6,8,11],cha:11,chanc:[4,11,13],chang:[2,3,4,9,13],charact:[3,11,12],charisma:11,check:[0,4,7,11],checkfactioninvit:[0,1],chongq:11,citi:[11,12],citynam:11,classgymexpgain:2,clear:[0,1,8,12],clearlog:[0,1],click:[4,13],close:[8,12,13],cls:0,code:[4,6,7,8,9,10],color:13,come:13,command:[0,3,4,11,12],comment:[0,1,9],commiss:6,commit:[2,11],commitcrim:[0,1],commonli:13,commun:[6,8],compani:[6,11,12],companynam:11,companyworkexpgain:2,companyworkmonei:2,complet:4,comput:[4,11,13],condit:[0,1],configur:[0,12],confirm:0,connect:0,consol:13,constantli:4,constrain:4,consult:11,contain:[2,3,4,5,8,11],content:0,continu:11,contract:11,control:11,convert:4,copi:[4,13],core:[4,5,13],corecost:[4,5],correct:11,correspond:5,cosmet:13,cost:[4,5,6,11,13],could:13,count:[4,13],cours:11,coursenam:11,cpu:13,creat:[4,6,11,12,13],createprogram:[0,1],crime:[2,11],crimeexpgain:2,crimemonei:2,crush:11,ctrl:12,current:[0,2,4,6,11,12,13],cursor:12,cyberpunk:0,cycl:12,dark:[0,11,13],data:[0,1,4,8,11],date:[0,1],deal:[8,11],decim:11,declar:[3,4,7,8,13],decreas:4,decrement:9,deepscanv1:[11,13],deepscanv2:[11,13],def:11,defens:11,defin:[0,1,12,13],definit:8,delai:4,delet:[4,12,13],deleteserv:[0,1],denot:[4,8],depend:4,depth:13,describ:4,descript:13,desir:13,destin:4,detail:[4,13],determin:4,develop:[0,1],dex:11,dexter:11,dialog:4,differ:[2,3,4,12],differenti:13,digit:13,disabl:4,disablelog:[0,1],displai:13,divis:9,document:[4,7,8,11,12,13],doe:[1,4,6,8,9,12,13],doing:[5,8,10],don:[8,11],done:12,doubl:[3,5,13],down:[12,13],download:0,drug:11,due:4,dynam:13,dystopian:0,each:[5,6,11,13],earli:0,earn:[4,5,11],ecp:6,edit:[12,13],editor:[0,13],effect:4,either:[3,4,13],element:[4,5,6,8,10,11],els:[7,8,11],emac:12,embark:0,emploi:[11,12],employe:11,empti:[4,8,13],emul:[12,13],enabl:[4,12,13],enable_bash_hotkei:12,enablelog:[0,1],encapsul:3,end:[4,5,8,11,12],endpoint:8,engin:11,enough:[4,6],enter:[12,13],equal:9,equival:[3,4,5],error:4,esc:12,especi:4,estim:13,etc:[3,4,10,11,13],evalu:8,even:[4,6,8,9],everi:[4,6,8,11,13],exampl:[0,1,2,3,4,6,7,8,9,10,11,13],exce:6,exceed:4,except:[4,12,13],exchang:[0,1],exe:[4,11,13],exec:[0,1],execut:[4,6,8,13],exist:[4,5,7,13],exit:[0,1],expand:13,experi:[4,11],explain:8,extens:[4,11,13],facnam:11,faction:[11,12],factionnam:11,factionpassiverepgain:2,factionworkexpgain:2,factionworkrepgain:2,fail:[4,11,13],failur:4,fairli:11,fairlyn:11,fals:[3,4,5,6,8,9,11],far:11,favor:11,fconf:[12,13],featur:1,fee:6,feel:1,few:13,ffffff:13,field:11,fieldwork:11,file:[2,4,11,12,13],fileexist:[0,1],filenam:[4,8,13],fill:4,find:4,findindex:8,fine:4,finish:11,first:[3,4,5,6,8,10,11,13],fisg:6,fit:11,fix:4,flag:13,floor:8,fn1:8,fn2:8,follow:[2,3,4,5,7,8,11,13],foo1:[4,8],foo2:[4,8],foo3:[4,8],foo4:8,foo:[4,8,13],foodnstuff:[4,7,8,13],forgeri:11,form:[2,4,5,13],four:[5,6],fourth:[5,6],fraction:4,free:[0,1],from:[4,6,8,10,11,13],ftpcrack:[0,1,11],full:[8,13],fulli:3,furthermor:4,futur:[2,4,12],gain:[0,4,11],game:[0,2,4,6,8,10,11,13],gener:[4,9,10],get:[4,8,10,11,13],getaugmentationcost:[0,1],getaugmentationsfromfact:[0,1],getbitnodemultipli:[0,1],getcharacterinform:[0,1],getcompanyfavor:[0,1],getcompanyrep:[0,1],getcoreupgradecost:5,getcrimech:[0,1],getfactionfavor:[0,1],getfactionrep:[0,1],getgrowtim:[0,1],gethackinglevel:[0,1],gethackingmultipli:[0,1],gethacknetmultipli:[0,1,5],gethacktim:[0,1],gethostnam:[0,1],getlevelupgradecost:5,getnexthacknetnodecost:[0,1,5],getownedaugment:[0,1],getporthandl:8,getpurchasedserv:[0,1],getramupgradecost:5,getscriptexpgain:[0,1],getscriptincom:[0,1],getscriptnam:[0,1],getscriptram:[0,1],getserverbasesecuritylevel:[0,1],getservergrowth:[0,1],getservermaxmonei:[0,1],getserverminsecuritylevel:[0,1],getservermoneyavail:[0,1,7],getservernumportsrequir:[0,1],getserverram:[0,1,8],getserverrequiredhackinglevel:[0,1],getserversecuritylevel:[0,1],getstat:[0,1],getstockposit:[0,1],getstockpric:[0,1],gettimesincelastaug:[0,1],getupgradehomeramcost:[0,1],getweakentim:[0,1],give:[2,4,11],given:[4,6,11,13],global:[4,13],googl:13,grand:11,greater:9,grep:[4,13],grow:[0,1,7],grown:7,growth:4,guarante:11,gym:[11,12],gymnam:11,gymworkout:[0,1],hack:[0,1,7,11,12],hacker:0,hackexpgain:2,hackingcontract:11,hacknet:[0,1,4,12],hacknetnod:[0,1],hacknetnodemonei:2,halt:4,halv:11,hand:13,handl:8,has:[1,2,4,5,11,13],hasrootaccess:[0,1],have:[1,2,4,5,6,8,11,13],header:13,heist:11,helio:4,hello:4,help:0,here:[0,3,4,6,7,8,11,13],hex:13,higher:4,highlight:13,histori:13,hoist:4,hold:3,home:[0,4,11,12],homicid:11,hope:0,hostnam:[0,4],how:[3,4,5,7,8,13],howev:[4,7,8,13],httpworm:[0,1,11,13],hyphen:3,ident:1,identifi:[4,13],ifconfig:0,immedi:[4,6,11,13],implement:[1,8,12],importantinfo:13,improv:1,includ:[3,4,11,12,13],incom:[4,5],increas:4,increment:[0,9],incur:8,index:[0,4,5],indic:[4,11,13],individu:13,inequ:9,inform:[0,1,4,11,13],initi:3,input:[11,12],insid:[4,5,8],instal:[4,6,11],installaugment:[0,1],instanc:4,instead:[2,4,5,11],institut:11,instrins:4,integ:[2,3,4,5,6],intellig:11,interact:8,interfac:13,invalid:[4,11],invit:11,iron:11,isbusi:[0,1],ishima:11,isinteg:8,isrun:[0,1],issu:[11,13],item:8,iter:[5,7],its:[4,6,8,13],itself:5,javascript:[0,1,3,4,7],job:[11,12],jobtitl:11,joesgun:4,join:[3,11],joinfact:[0,1],jump3r:0,just:[4,8,13],kei:[12,13],keyboard:[0,13],keyword:7,kidnap:11,kill:[0,1],killal:[0,1],know:8,label:3,languag:[1,3,4],larceni:11,last:[4,8,12],later:[2,3,6,11],lead:0,leadership:11,least:[4,5],left:13,length:[4,5,10],lenient:11,less:9,let:[6,7,8,10,13],letter:[3,6],level:[4,5,11,13],levelcost:[4,5],librari:8,life:13,like:[4,8,10,12],limit:[4,6,11],limitbui:6,limitsel:6,line:[8,12],link:[4,13],list:[5,11,13],lit:[4,13],literatur:[4,13],local:4,locat:[4,11],log:[4,5,8,12,13],logic:9,look:[8,10],loop:[0,1],lose:8,lot:11,lower:4,lscpu:0,machin:13,made:[6,13],mai:[4,13],make:[4,10],manag:11,mani:[1,3,11],manual:11,manualhackmonei:2,map:5,mark:13,market:6,masterscript:13,match:13,math:[0,1],matter:13,max:5,maximum:[4,13],mayb:8,mean:[0,1,2,3,4,5,8,11],mechan:13,mem:0,member:[0,1,3,11],memori:[4,13],menu:[12,13],messag:[0,4,13],method:[0,1,3,8],middl:11,millenium:11,millisecond:4,minimum:4,minut:11,misc:0,miscellan:[0,1],mission:12,mode:[4,12],modifi:10,modul:[0,1],modulo:9,monei:[0,2,4,5,6,7,11,13],moneygainratepersecond:5,more:[3,4,7,12,13],most:3,move:12,msg:[4,13],much:[7,13],mug:11,mult:[2,4,5],multi:8,multipl:[4,9,13],multipli:[2,4,5,11],must:[3,4,5,6,8,11,12,13],mute:13,mysteri:0,name:[3,4,5,6,9,10,11,13],namespac:8,nano:[0,12],navig:[0,13],nearest:[4,5,6],necessari:[0,13],need:[4,8,13],negat:9,net:6,netscript:0,netscriptport:8,network:[11,13],newli:4,next:[4,12],node:[0,1,4,12,13],non:13,none:[4,5],normal:[8,10,11],notabl:4,note:[4,5,8,11,12,13],now:[0,8,13],nuke:[0,1,13],num:13,number:[0,1,3,4,5,6,9,10,11,13],numer:[3,6,9],numthread:[4,8],object:[2,3,4,5,11],obtain:4,obvious:11,offlin:4,omit:[4,13],onc:13,one:[4,5,7,8,11],onli:[2,4,5,6,8,9,11,12,13],onlin:4,onlinetimesecond:5,onto:3,open:[4,8,11,12,13],oper:[0,1,8,10],operand:9,option:[4,11,12,13],order:[2,4,6,11,13],origin:2,other:[4,8,11,12],otherwis:[4,5,6,7,8,11,12,13],our:8,oustand:[6,11],out:[1,4,8,11],output:4,outsid:[4,11],over:4,overrid:12,overwrit:4,own:[0,1,6,13],page:[0,2,4,8,11,12,13],param:[],paramet:[4,13],pars:8,part:[11,13],particular:11,pass:[4,8,10,11,13],path:13,pattern:13,peek:[0,1,8],percentag:[4,5],perform:11,perman:13,picker:13,place:6,placeord:[0,1],plai:0,plan:10,player:[0,4,5,6,10,11,13],pop:[3,8],port:[0,1,4,13],pos:6,posit:[3,5,6,11],possibl:10,pound:13,power:[0,4],powerhous:11,pre:9,preced:13,preset:[12,13],prevent:10,previou:12,price:6,primit:3,print:[0,1,2,5,8,11,13],process:4,produc:9,product:[4,5],profit:6,program:[1,4,11,12,13],programnam:11,promot:11,prompt:[0,1],properti:11,protocol:6,provid:[5,6],pserv:4,purchas:[0,1,4,6,11,13],purchaseaugment:[0,1],purchasecost:[4,5],purchasehacknetnod:[0,1,5],purchaseprogram:[0,1],purchaseserv:[0,1],purchasetor:[0,1],purpos:[3,4],put:[2,9],quest:0,queue:[4,8],quickli:4,quot:3,quotat:13,rais:4,ram:[4,5,8,11,13],ramcost:[4,5],ramus:4,ran:[4,8,13],rate:4,rather:13,reach:[1,13],read:[0,1,3,5,8],real:13,reason:4,receiv:[2,11],recommend:11,refer:[3,7],referenc:3,reflect:6,regardless:4,rel:13,relat:[4,5,8,13],relaysmtp:[0,1,11],relev:2,reload:8,rememb:[4,6,13],remot:13,remov:[4,8,13],replac:13,repres:[2,3,4,6,8,13],reput:11,request:1,requir:[2,4,8,9,11,13],res:[4,8,11],reset:[4,6,11],resolv:4,respect:13,rest:3,restart:11,result:[4,9],retain:6,reusabl:13,revert:4,right:8,rob:11,role:0,room:8,root:[4,13],rothman:[4,11],round:[4,5,6],router:[11,13],rpg:0,run:[0,1,2,7,8,9,10,11],runtim:4,sai:[4,10],sake:8,sale:6,same:[4,7,8,11,12,13],save:[8,12],scan:[0,1],schedul:11,scheme:13,scienc:11,scope:4,scp:[0,1],screen:[12,13],script:[0,1,4,5,6,8,11,13],scripthackmonei:2,scriptkil:[0,1],scriptnam:4,scriptrun:[0,1],search:[0,4],second:[3,4,5,6,10,11,13],secret:0,section:[1,4],sector:11,secur:[4,11],securitywork:11,see:[4,5,7,13],select:4,sell:6,sellshort:[0,1],sellstock:[0,1],sensit:[4,6,11,13],separ:[2,4,13],sequenc:[3,6],serial:[4,8],server:[4,7,13],serverexist:[0,1],servergrowthr:2,servermaxmonei:2,serverprofil:11,serverstartingmonei:2,serverstartingsecur:2,serverweakenr:2,set:[4,11,12,13],sever:8,share:6,sharesshort:6,she:0,shell:12,shoplift:11,shortcut:[0,13],shortstock:[0,1],should:[4,7,11,13],show:[3,4,7,13],shown:[4,13],side:13,sigma:13,sign:13,signatur:4,signific:4,similar:4,simpl:[7,8],simplest:4,simpli:[1,3],simplic:8,sinc:[4,8],singl:[3,4,9,13],singular:[0,1],skill:4,sleep:[0,1,5,8,11],slice:8,small:11,snap:11,softwar:11,solar:13,sold:6,some:[4,7,8,9,11],some_valu:4,someth:0,someval1:8,someval2:8,sort:[4,8],sourc:[2,4,11],space:[12,13],spawn:[0,1],special:[3,5,10,11],specif:[4,8],specifi:[4,5,6,8,10,11,13],speed:4,splice:3,spoiler:[2,11],sprintf:[0,1],sqlinject:[0,1,11],stage:0,stai:4,start:[3,4,8,11,13],stat:[11,12],statement:7,statist:[6,13],steal:4,still:[4,13],stock:6,stolen:4,stop:[4,6,11,13],stopact:[0,1],stopbui:6,stopsel:6,store:[3,11],str:11,strategi:6,strength:11,strict:9,string:[3,4,6,11,13],structur:[2,4,5,8],strucur:11,studi:11,subject:2,subset:1,substitut:13,substr:4,subtract:9,success:[4,6,11],successfulli:[4,5,6,8,11,13],sudov:0,suggest:1,sum:4,summit:11,support:[3,5,6,8,13],suppos:8,suspend:4,suspicion:0,sym:6,symbol:6,syntax:[1,4,8],system:6,tab:[12,13],tail:0,take:[0,4,11,12,13],target:[4,13],technolog:11,templat:4,ten:7,term:11,termin:[0,4,11],test:4,testlib:8,testlibrari:8,text:[3,4,13],than:[4,7,9,13],theft:11,thei:[1,2,4,12,13],them:[4,8,11],theme:0,thi:[0,1,2,3,4,5,6,8,9,10,11,12,13],thing:13,third:[4,6],those:[4,5],though:[4,8],thought:3,thread:[4,10,11,13],three:[3,4,8,12,13],through:[4,5,8,11,12,13],time:[4,5,7,8,11,13],timework:11,tini:1,tix:[0,1],todo:13,tokyo:11,tolowercas:3,top:0,tor:[11,13],total:[4,5,13],totalmoneygener:5,totalram:4,tprint:[0,1,8],trade:[0,1],traffick:11,train:[11,12],transact:6,travel:[11,12],traveltoc:[0,1],travers:7,tri:[4,5,13],trywrit:8,tutori:12,two:[4,6,8,9,10,11],txt:[4,13],type:[0,1,4,6,11,13],typic:4,unalia:0,unalias_terminal_command:[],unari:[0,1],uncov:0,underli:[4,8],underscor:3,undo:13,undon:13,uni:4,uniqu:[4,13],univeristi:11,univers:[11,12],universitycours:[0,1],universitynam:11,unknown:0,unless:12,unlock:[6,11],until:[4,5,11],untyp:3,updat:11,upgrad:[5,11],upgradecor:5,upgradehomeram:[0,1],upgradelevel:5,upgraderam:5,usag:[4,8,13],use:[4,6,7,8,11,13],used:[1,3,4,5,6,8,11,12,13],user:13,uses:7,using:[4,5,6,7,8,10,11,13],usual:11,utc:8,util:[0,1],valid:[4,8,11,13],valu:[2,3,4,5,6,8,9,11,13],vari:4,variabl:[0,1,4,7,9,13],variou:[11,12],vim:12,visit:[6,11],volhaven:11,vsprintf:[0,1],wai:[4,5,8,11,13],wait:8,waiter:11,want:[5,8,10,11,13],warn:[9,10,11,13],weaken:[0,1],web:[11,13],well:[3,12,13],were:[4,11,12,13],wese:6,what:[4,5,11,13],whatev:11,when:[0,1,4,7,8,11,13],where:[0,4,8,12],whether:[4,6,11,13],which:[3,4,5,6,8,11,13],whitespac:4,whose:13,window:12,without:[4,8,13],word:[4,12,13],work:[4,6,8,9,11,12,13],workagiexpgain:11,workchaexpgain:11,workdefexpgain:11,workdexexpgain:11,workforcompani:[0,1],workforfact:[0,1],workhackexpgain:11,workmoneygain:11,workrepgain:11,workstrexpgain:11,worktyp:11,world:[0,1,4,6],worm:13,would:[2,9,10,11,13],write:[0,1,5,6,8],written:[1,4,8],wrong:0,wrote:8,wse:6,yet:[4,11],you:[0,1,2,3,4,5,6,7,8,9,11,12,13],your:[0,1,5,6,11,12,13],yourself:5,zero:4,zip:13},titles:["Welcome to Bitburner's documentation!","Netscript Documentation","Netscript Advanced Functions","Netscript Data Types and Variables","Netscript Basic Functions","Netscript Hacknet Node API","Netscript Trade Information eXchange (TIX) API","Netscript Loops and Conditionals","Netscript Miscellaneous","Netscript Operators","Netscript Script Arguments","Netscript Singularity Functions","Keyboard Shortcuts","Terminal"],titleterms:{"function":[2,4,8,11],"import":8,advanc:2,alia:13,analyz:13,api:[5,6],applytocompani:11,argument:10,bash:12,basic:4,binari:9,bitburn:0,brutessh:4,bui:13,buystock:6,cancelord:6,cat:13,check:13,checkfactioninvit:11,clear:[4,13],clearlog:4,cls:13,command:13,comment:8,commitcrim:11,condit:7,configur:13,connect:13,createprogram:11,data:3,date:8,defin:4,deleteserv:4,disablelog:4,document:[0,1],download:13,editor:12,enablelog:4,exampl:5,exchang:6,exec:4,exit:4,fileexist:4,free:13,ftpcrack:4,game:12,getaugmentationcost:11,getaugmentationsfromfact:11,getbitnodemultipli:2,getcharacterinform:11,getcompanyfavor:11,getcompanyrep:11,getcrimech:11,getfactionfavor:11,getfactionrep:11,getgrowtim:4,gethackinglevel:4,gethackingmultipli:4,gethacknetmultipli:4,gethacktim:4,gethostnam:4,getnexthacknetnodecost:4,getownedaugment:11,getpurchasedserv:4,getscriptexpgain:4,getscriptincom:4,getscriptnam:4,getscriptram:4,getserverbasesecuritylevel:4,getservergrowth:4,getservermaxmonei:4,getserverminsecuritylevel:4,getservermoneyavail:4,getservernumportsrequir:4,getserverram:4,getserverrequiredhackinglevel:4,getserversecuritylevel:4,getstat:11,getstockposit:6,getstockpric:6,gettimesincelastaug:4,getupgradehomeramcost:11,getweakentim:4,grow:4,gymworkout:11,hack:[4,13],hacknet:5,hacknetnod:5,handl:[],hasrootaccess:4,help:13,home:13,hostnam:13,httpworm:4,ifconfig:13,indic:0,inform:6,installaugment:11,isbusi:11,isrun:4,javascript:8,joinfact:11,keyboard:12,kill:[4,13],killal:[4,13],loop:7,lscpu:13,math:8,mem:13,member:5,method:5,misc:12,miscellan:8,modul:8,nano:13,navig:12,netscript:[1,2,3,4,5,6,7,8,9,10,11],node:5,nuke:4,number:8,oper:9,own:4,peek:4,placeord:6,port:8,print:4,prompt:4,purchas:5,purchaseaugment:11,purchasehacknetnod:4,purchaseprogram:11,purchaseserv:4,purchasetor:11,read:4,relaysmtp:4,round:[],run:[4,13],scan:[4,13],scp:[4,13],script:[10,12],scriptkil:4,scriptrun:4,sellshort:6,sellstock:6,serverexist:4,shortcut:12,shortstock:6,singular:11,sleep:4,spawn:4,sprintf:4,sqlinject:4,stopact:11,sudov:13,tabl:0,tail:13,termin:[12,13],theme:13,tix:6,top:13,tprint:4,trade:6,traveltoc:11,type:3,unalia:13,unari:9,universitycours:11,upgradehomeram:11,usag:[],util:5,variabl:[3,5],vsprintf:4,weaken:4,welcom:0,what:0,workforcompani:11,workforfact:11,write:4,your:4}})
\ No newline at end of file
+Search.setIndex({docnames:["index","netscript","netscriptadvancedfunctions","netscriptdatatypes","netscriptfunctions","netscripthacknetnodeapi","netscriptixapi","netscriptjs","netscriptloopsandconditionals","netscriptmisc","netscriptoperators","netscriptscriptarguments","netscriptsingularityfunctions","shortcuts","terminal"],envversion:53,filenames:["index.rst","netscript.rst","netscriptadvancedfunctions.rst","netscriptdatatypes.rst","netscriptfunctions.rst","netscripthacknetnodeapi.rst","netscriptixapi.rst","netscriptjs.rst","netscriptloopsandconditionals.rst","netscriptmisc.rst","netscriptoperators.rst","netscriptscriptarguments.rst","netscriptsingularityfunctions.rst","shortcuts.rst","terminal.rst"],objects:{"":{applyToCompany:[12,2,1,""],buyStock:[6,2,1,""],cancelOrder:[6,2,1,""],checkFactionInvitations:[12,2,1,""],clearLog:[4,2,1,""],commitCrime:[12,2,1,""],createProgram:[12,2,1,""],deleteServer:[4,2,1,""],disableLog:[4,2,1,""],enableLog:[4,2,1,""],fileExists:[4,2,1,""],getAugmentationCost:[12,2,1,""],getAugmentationsFromFaction:[12,2,1,""],getBitNodeMultipliers:[2,2,1,""],getCompanyFavor:[12,2,1,""],getCompanyRep:[12,2,1,""],getCrimeChance:[12,2,1,""],getFactionFavor:[12,2,1,""],getFactionRep:[12,2,1,""],getGrowTime:[4,2,1,""],getHackTime:[4,2,1,""],getHackingLevel:[4,2,1,""],getHackingMultipliers:[4,2,1,""],getHacknetMultipliers:[5,2,1,""],getHostname:[4,2,1,""],getNextHacknetNodeCost:[5,2,1,""],getOwnedAugmentations:[12,2,1,""],getPurchasedServers:[4,2,1,""],getScriptExpGain:[4,2,1,""],getScriptIncome:[4,2,1,""],getScriptName:[4,2,1,""],getScriptRam:[4,2,1,""],getServerBaseSecurityLevel:[4,2,1,""],getServerGrowth:[4,2,1,""],getServerMaxMoney:[4,2,1,""],getServerMinSecurityLevel:[4,2,1,""],getServerMoneyAvailable:[4,2,1,""],getServerNumPortsRequired:[4,2,1,""],getServerRam:[4,2,1,""],getServerRequiredHackingLevel:[4,2,1,""],getServerSecurityLevel:[4,2,1,""],getStats:[12,2,1,""],getStockPosition:[6,2,1,""],getStockPrice:[6,2,1,""],getTimeSinceLastAug:[4,2,1,""],getUpgradeHomeRamCost:[12,2,1,""],getWeakenTime:[4,2,1,""],gymWorkout:[12,2,1,""],hasRootAccess:[4,2,1,""],installAugmentations:[12,2,1,""],isBusy:[12,2,1,""],isRunning:[4,2,1,""],joinFaction:[12,2,1,""],placeOrder:[6,2,1,""],purchaseAugmentation:[12,2,1,""],purchaseHacknetNode:[5,2,1,""],purchaseProgram:[12,2,1,""],purchaseServer:[4,2,1,""],purchaseTor:[12,2,1,""],scriptKill:[4,2,1,""],scriptRunning:[4,2,1,""],sellShort:[6,2,1,""],sellStock:[6,2,1,""],serverExists:[4,2,1,""],shortStock:[6,2,1,""],stopAction:[12,2,1,""],travelToCity:[12,2,1,""],universityCourse:[12,2,1,""],upgradeHomeRam:[12,2,1,""],workForCompany:[12,2,1,""],workForFaction:[12,2,1,""]},"hacknetnodes[i]":{cores:[5,1,1,""],getCoreUpgradeCost:[5,0,1,""],getLevelUpgradeCost:[5,0,1,""],getRamUpgradeCost:[5,0,1,""],level:[5,1,1,""],moneyGainRatePerSecond:[5,1,1,""],name:[5,1,1,""],onlineTimeSeconds:[5,1,1,""],ram:[5,1,1,""],totalMoneyGenerated:[5,1,1,""],upgradeCore:[5,0,1,""],upgradeLevel:[5,0,1,""],upgradeRam:[5,0,1,""]},NetscriptPort:{clear:[9,0,1,""],data:[9,1,1,""],empty:[9,0,1,""],full:[9,0,1,""],tryWrite:[9,0,1,""],write:[9,0,1,""]}},objnames:{"0":["js","method","JavaScript method"],"1":["js","attribute","JavaScript attribute"],"2":["js","function","JavaScript function"]},objtypes:{"0":"js:method","1":"js:attribute","2":"js:function"},terms:{"1e3":14,"3087e3":7,"50e3":14,"8gb":5,"boolean":[3,4,12],"break":11,"case":[4,6,12,14],"catch":7,"class":[7,12,13],"default":[4,12,13,14],"export":[7,9],"final":[0,1],"float":3,"function":[0,1,3,5,6,7,8,13,14],"import":[0,1,4,7,14],"long":6,"new":[4,5,7,9,12,13,14],"null":[4,7,9],"return":[2,4,5,6,9,10,12,13],"short":6,"static":[7,9],"switch":13,"throw":7,"true":[3,4,5,6,7,9,10,12],"try":[4,7,9,11,12],"var":8,"while":[4,5,7,8,9,12,14],AND:10,Ace:13,Adding:3,And:9,Doing:7,For:[2,3,4,5,7,8,9,10,11,14],IPs:4,NOT:[4,6,10,12,13,14],Not:12,One:12,The:[0,2,3,4,5,6,7,8,9,11,12,14],Their:3,Then:[5,7,9,14],There:9,These:[2,4,5,7,12,13,14],Use:[4,7],Will:[4,6,13],With:7,Yes:4,_termin:[],abbrevi:14,abil:6,abl:[7,12],about:[3,4,9,12,14],abov:[3,4,9,10,14],accept:12,access:[3,4,5,6,7,9,11,12,14],accumul:7,action:[12,13],activ:[4,13],actual:[4,6,9,12,14],add:[5,7,14],added:4,addit:[4,5,7,10,12],address:[4,14],adjac:14,advanc:[0,1],aevum:12,affect:4,afford:[4,5],after:[3,4,6,9,12,14],afterward:14,agenc:[12,13],agent:12,agi:12,agil:12,aid:0,aka:[12,13],algorithm:[6,12],alia:0,alias:14,all:[3,4,5,6,7,9,12,14],allow:[6,7,9,12,14],almost:[1,7,13],alphabet:[4,14],alphanumer:3,alreadi:[4,12,14],also:[3,4,6,7,11,12,13,14],alt:[13,14],alter:7,altern:14,although:12,alwai:[7,13],amount:[4,5,6,11,12,14],analyz:[0,13],ani:[0,1,3,4,7,12,13,14],anoth:[4,9,11,14],anyth:4,anytim:14,anywher:[4,14],api:[0,1],appear:4,append:4,appendchild:7,appli:[4,7,12],applic:12,applytocompani:[0,1],arg1:7,arg2:7,arg3:7,arg:[4,7,9,11,14],argument:[0,1,4,5,6,7,9,12,14],arm:12,around:[0,12],arrai:[3,4,5,6,9,11,12],arrow:[13,14],aspect:12,assassin:12,assign:[5,10],assum:[7,9],async:7,asynchron:7,attack:4,attempt:[6,9,12,14],augment:[4,6,12,13],augmentationmoneycost:2,augmentationrepcost:2,augnam:12,auto:12,autocomplet:13,autolink:12,autom:[5,6],automat:[4,6,12],avail:[3,4,6,7,8,12,13,14],averag:6,avgpx:6,avgpxshort:6,awai:14,await:7,back:9,background:14,backspac:13,backup:7,base:[4,10],bash:0,basic:[0,1,14],becaus:[2,4,7,12,14],becom:2,been:[0,7],befor:[4,7,9],begin:13,being:[4,7,14],below:4,best:11,beta:0,better:13,between:[2,4,7,9,13,14],billion:6,binari:[0,1],bind:13,bitburn:1,bitnod:[2,12],blob:7,blue:7,bond:12,both:[4,12,14],box:4,brief:[9,14],browser:[7,12,13],brutessh:[0,1,12,14],bui:[0,6,12],build:6,busi:12,buystock:[0,1],calcul:6,call:[0,4,5,7,9,11,12,14],callback:12,can:[0,3,4,5,6,7,8,9,11,12,13,14],cancel:[6,12,13],cancelord:[0,1],cannot:[4,5,7,14],capabl:[3,7],capit:6,cat:0,caus:4,caveat:[7,8],cbscript:12,cellel:7,certain:[4,6,9,12],cha:12,chanc:[4,12,14],chang:[2,3,4,7,10,14],charact:[3,12,13],charisma:12,check:[0,4,8,12],checkfactioninvit:[0,1],chongq:12,citi:[12,13],citynam:12,classgymexpgain:2,classlist:7,clear:[0,1,7,9,13],clearlog:[0,1],click:[4,14],close:[7,9,13,14],cls:0,code:[4,6,7,8,9,10,11],collect:7,color:[7,14],com:[],come:[7,14],command:[0,3,4,12,13],comment:[0,1,10],commiss:6,commit:[2,12],commitcrim:[0,1],commonli:14,commun:[6,9],compani:[6,12,13],companynam:12,companyworkexpgain:2,companyworkmonei:2,complet:[4,7],comput:[4,7,12,14],concat:7,condit:[0,1],configur:[0,13],confirm:0,connect:0,consol:14,constantli:4,constrain:4,constructor:7,consult:12,contain:[2,3,4,5,7,9,12],content:0,continu:12,contract:12,control:12,convert:[4,7],copi:[4,14],core:[4,5,14],corecost:[4,5],correct:12,correspond:5,cosmet:14,cost:[4,5,6,12,14],could:14,count:[4,14],cours:12,coursenam:12,cplusplu:[],cpp_static_memb:[],cpu:14,crash:7,creat:[4,6,12,13,14],createel:7,createprogram:[0,1],crime:[2,12],crimeexpgain:2,crimemonei:2,crush:12,ctor:7,ctrl:13,current:[0,2,4,6,12,13,14],cursor:13,cyberpunk:0,cycl:13,dai:[],dark:[0,12,14],data:[0,1,4,9,12],date:[0,1],deal:[9,12],decid:7,decim:12,declar:[3,4,7,8,9,14],decreas:4,decrement:10,deepscanv1:[12,14],deepscanv2:[12,14],def:12,defens:12,defin:[0,1,7,13,14],definit:9,delai:4,delet:[4,7,13,14],deleteserv:[0,1],denot:[4,9],depend:[4,7],depth:14,describ:4,descript:14,desir:14,destin:4,detail:[4,14],determin:4,develop:[0,1,7],dex:12,dexter:12,dialog:4,differ:[2,3,4,7,13],differenti:14,digit:14,directli:7,disabl:4,disablelog:[0,1],displai:14,divis:10,document:[4,7,8,9,12,13,14],doe:[1,4,6,7,9,10,13,14],doing:[5,7,9,11],dom:7,don:[7,9,12],done:13,doubl:[3,5,14],down:[7,13,14],download:0,drug:12,due:4,dynam:[7,14],dystopian:0,each:[5,6,12,14],earli:0,earn:[4,5,12],ecp:6,edit:[7,13,14],editor:[0,14],effect:4,either:[3,4,14],element:[4,5,6,9,11,12],els:[8,9,12],emac:13,embark:0,emploi:[12,13],employe:12,empti:[4,9,14],emul:[13,14],enabl:[4,7,13,14],enable_bash_hotkei:13,enablelog:[0,1],encapsul:3,end:[4,5,9,12,13],endpoint:9,engin:[7,12],enough:[4,6],enter:[13,14],entri:7,environ:7,equal:10,equival:[3,4,5],error:[4,7],esc:13,especi:4,estim:14,etc:[3,4,7,11,12,14],evalu:[7,9],even:[4,6,9,10],everi:[4,6,7,9,12,14],exampl:[0,1,2,3,4,6,8,9,10,11,12,14],exce:6,exceed:4,except:[4,7,13,14],exchang:[0,1],exe:[4,12,14],exec:[0,1,7],execarg:7,execut:[4,6,7,9,14],exist:[4,5,8,14],exit:[0,1],expand:14,experi:[4,7,12],explain:9,exploit:7,extens:[4,7,12,14],facnam:12,faction:[12,13],factionnam:12,factionpassiverepgain:2,factionworkexpgain:2,factionworkrepgain:2,fail:[4,12,14],failur:4,fairli:12,fairlyn:12,fals:[3,4,5,6,9,10,12],far:12,faster:7,favor:12,fconf:[13,14],featur:[1,7],fee:6,feel:1,few:14,ffffff:14,field:12,fieldwork:12,file:[2,4,12,13,14],fileexist:[0,1],filenam:[4,7,9,14],fill:4,find:[4,7],findindex:9,fine:4,finish:12,firefox:[0,1],first:[3,4,5,6,9,11,12,14],fisg:6,fit:12,fix:4,flag:14,fledg:7,floor:9,fn1:9,fn2:9,follow:[2,3,4,5,7,8,9,12,14],foo1:[4,9],foo2:[4,9],foo3:[4,9],foo4:9,foo:[4,7,9,14],foodnstuff:[4,7,8,9,14],forgeri:12,form:[2,4,5,14],forward:7,four:[5,6],fourth:[5,6],fraction:4,free:[0,1],from:[4,6,7,9,11,12,14],ftpcrack:[0,1,12],full:[7,9,14],fulli:3,furthermor:[4,7],futur:[2,4,13],gain:[0,4,12],game:[0,2,4,6,7,9,11,12,14],garbag:7,gener:[4,7,10,11],get:[4,7,9,11,12,14],getaugmentationcost:[0,1],getaugmentationsfromfact:[0,1],getbitnodemultipli:[0,1],getcharacterinform:[0,1],getcompanyfavor:[0,1],getcompanyrep:[0,1],getcoreupgradecost:5,getcrimech:[0,1],getelementbyid:7,getfactionfavor:[0,1],getfactionrep:[0,1],getgrowtim:[0,1],gethackinglevel:[0,1],gethackingmultipli:[0,1],gethacknetmultipli:[0,1,5],gethacktim:[0,1],gethostnam:[0,1,7],getlevelupgradecost:5,getnexthacknetnodecost:[0,1,5],getownedaugment:[0,1],getporthandl:9,getpurchasedserv:[0,1],getramupgradecost:5,getscriptexpgain:[0,1],getscriptincom:[0,1],getscriptnam:[0,1],getscriptram:[0,1],getserverbasesecuritylevel:[0,1],getservergrowth:[0,1],getservermaxmonei:[0,1],getserverminsecuritylevel:[0,1],getservermoneyavail:[0,1,8],getservernumportsrequir:[0,1],getserverram:[0,1,9],getserverrequiredhackinglevel:[0,1],getserversecuritylevel:[0,1],getstat:[0,1],getstockposit:[0,1],getstockpric:[0,1],gettimesincelastaug:[0,1],getupgradehomeramcost:[0,1],getweakentim:[0,1],github:7,give:[2,4,12],given:[4,6,12,14],global:[4,7,14],globalvari:7,going:7,googl:14,grand:12,great:7,greater:10,grep:[4,14],grow:[0,1,7,8],grown:8,growth:4,guarante:12,gym:[12,13],gymnam:12,gymworkout:[0,1],hack:[0,1,7,8,12,13],hacker:0,hackexpgain:2,hackingcontract:12,hacknet:[0,1,4,13],hacknetnod:[0,1],hacknetnodemonei:2,halt:4,halv:12,hand:14,handl:9,happi:7,has:[1,2,4,5,7,12,14],hasrootaccess:[0,1],have:[1,2,4,5,6,7,9,12,14],header:14,heist:12,helio:4,hello:4,help:0,here:[0,3,4,6,7,8,9,12,14],hex:[7,14],higher:4,highlight:14,histori:14,hoist:4,hold:3,home:[0,4,12,13],homicid:12,hope:0,hostnam:[0,4],how:[0,1,3,4,5,8,9,14],howev:[4,8,9,14],htm:[],http:[],httpworm:[0,1,12,14],hyphen:3,ident:1,identifi:[4,14],ifconfig:0,immedi:[4,6,12,14],implement:[1,9,13],importantinfo:14,improv:[1,7],includ:[3,4,7,12,13,14],incom:[4,5],increas:4,increment:[0,10],incur:9,index:[0,4,5],indic:[4,12,14],individu:14,inequ:10,infinit:7,inform:[0,1,4,12,14],initi:3,innertext:7,input:[7,12,13],insid:[4,5,9],instal:[4,6,12],installaugment:[0,1],instanc:[4,7],instead:[2,4,5,7,12],institut:12,instrins:4,integ:[2,3,4,5,6],intellig:12,interact:9,interfac:14,invalid:[4,12],invit:12,iron:12,isbusi:[0,1],ishima:12,isinteg:9,isrun:[0,1],issu:[12,14],item:9,iter:[5,8],its:[4,6,7,9,14],itself:5,jaguilar:7,javascript:[0,1,3,4,7,8],job:[7,12,13],jobtitl:12,joesgun:4,join:[3,12],joinfact:[0,1],jump3r:0,just:[4,7,9,14],kei:[13,14],keyboard:[0,14],keyword:8,kidnap:12,kill:[0,1],killal:[0,1],know:[7,9],label:3,languag:[1,3,4],larceni:12,last:[4,7,9,13],later:[2,3,6,12],lead:0,leadership:12,leak:7,least:[4,5],left:14,length:[4,5,7,11],lenient:12,less:10,let:[6,7,8,9,11,14],letter:[3,6],level:[4,5,12,14],levelcost:[4,5],librari:9,life:14,like:[4,7,9,11,13],limit:[4,6,12],limitbui:6,limitsel:6,line:[7,9,13],link:[4,14],list:[5,12,14],lit:[4,14],literatur:[4,14],load:7,local:4,locat:[4,12],log:[4,5,9,13,14],logic:10,look:[7,9,11],loop:[0,1,7],lose:9,lot:[7,12],lower:4,lscpu:0,machin:14,made:[6,14],mai:[4,7,14],main:7,make:[4,7,11],manag:12,mani:[1,3,12],manipul:7,manual:12,manualhackmonei:2,map:5,mark:[7,14],market:6,masterscript:14,match:14,math:[0,1],matter:14,max:5,maximum:[4,14],mayb:9,mean:[0,1,2,3,4,5,7,9,12],mechan:14,mem:0,member:[0,1,3,7,12],memori:[4,7,14],menu:[13,14],messag:[0,4,14],method:[0,1,3,7,9],middl:12,millenium:12,millisecond:4,minimum:4,minut:12,misc:0,miscellan:[0,1],mission:13,mode:[4,13],modifi:11,modul:[0,1,7],modulo:10,monei:[0,2,4,5,6,8,12,14],moneygainratepersecond:5,more:[3,4,8,13,14],most:3,move:13,mozilla:[0,1],msg:[4,14],much:[8,14],mug:12,mult:[2,4,5],multi:9,multipl:[4,7,10,14],multipli:[2,4,5,12],must:[3,4,5,6,7,9,12,13,14],mute:14,mysteri:0,name:[3,4,5,6,10,11,12,14],namespac:9,nano:[0,7,13],navig:[0,14],nearest:[4,5,6],necessari:[0,14],need:[4,7,9,14],negat:10,net:6,netscript:0,netscriptj:[0,1],netscriptport:9,network:[12,14],never:7,newli:4,next:[4,13],node:[0,1,4,13,14],non:14,none:[4,5],normal:[9,11,12],notabl:4,note:[0,1,4,5,9,12,13,14],now:[0,7,9,14],nuke:[0,1,14],num:14,number:[0,1,3,4,5,6,7,10,11,12,14],numer:[3,6,10],numthread:[4,9],object:[2,3,4,5,7,12],obtain:4,obvious:12,offlin:4,omit:[4,14],onc:14,one:[4,5,7,8,9,12],onli:[2,4,5,6,7,9,10,12,13,14],onlin:4,onlinetimesecond:5,onto:3,open:[4,7,9,12,13,14],oper:[0,1,9,11],operand:10,option:[4,7,12,13,14],order:[2,4,6,12,14],origin:2,other:[4,7,9,12,13],otherwis:[4,5,6,8,9,12,13,14],our:9,oustand:[6,12],out:[1,4,9,12],output:4,outsid:[4,12],over:[4,7],overrid:13,overwrit:4,own:[0,1,6,7,14],page:[0,2,4,7,9,12,13,14],param:7,paramet:[4,14],pars:9,part:[12,14],particular:12,pass:[4,7,9,11,12,14],path:14,pattern:14,peek:[0,1,9],peopl:7,percentag:[4,5],perform:12,perman:14,picker:14,place:6,placeord:[0,1],plai:0,plan:11,player:[0,4,5,6,11,12,14],pleas:7,plenti:7,point:7,pop:[3,9],port:[0,1,4,14],pos:6,posit:[3,5,6,12],possibl:[7,11],post:7,pound:14,power:[0,4,7],powerhous:12,pre:[7,10],preced:14,preset:[13,14],prevent:11,previou:13,price:6,primarili:7,primit:3,print:[0,1,2,5,7,9,12,14],process:4,produc:10,product:[4,5],profit:6,program:[1,4,12,13,14],programnam:12,promot:12,prompt:[0,1,7],properti:12,protocol:6,prototyp:7,provid:[5,6],pserv:4,purchas:[0,1,4,6,12,14],purchaseaugment:[0,1],purchasecost:[4,5],purchasedserver1:7,purchasehacknetnod:[0,1,5],purchaseprogram:[0,1],purchaseserv:[0,1],purchasetor:[0,1],purpos:[3,4],put:[2,10],quest:0,queue:[4,9],quickli:4,quot:3,quotat:14,rais:4,ram:[4,5,9,12,14],ramcost:[4,5],ramus:4,ran:[4,7,9,14],randomarg:7,rate:4,rather:[7,14],reach:[1,14],read:[0,1,3,5,9],real:14,reason:4,receiv:[2,12],recommend:[7,12],red:7,reduc:7,refer:[3,8],referenc:3,reflect:6,refresh:7,regardless:4,rel:14,relat:[4,5,9,14],relaysmtp:[0,1,12],releas:7,relev:2,reload:[7,9],rememb:[4,6,7,14],remot:14,remov:[4,9,14],repeatedli:7,replac:14,report:7,repres:[2,3,4,6,9,14],reput:12,request:1,requir:[2,4,9,10,12,14],res:[4,9,12],reset:[4,6,12],resolv:4,respect:14,respons:7,rest:3,restart:12,result:[4,7,10],retain:6,reusabl:14,revert:4,right:9,risk:7,rob:12,role:0,room:9,root:[4,14],rothman:[4,12],round:[4,5,6],router:[12,14],rowel:7,rpg:0,rule:7,run:[0,1,2,7,8,9,10,11,12],runarg:7,runtim:4,safe:7,sai:[4,11],sake:9,sale:6,same:[4,7,8,9,12,13,14],save:[7,9,13],scan:[0,1],schedul:[7,12],scheme:14,scienc:12,scope:[4,7],scp:[0,1,7],screen:[13,14],script:[0,1,4,5,6,7,9,12,14],scripthackmonei:2,scriptjob:7,scriptkil:[0,1],scriptnam:4,scriptrun:[0,1],scriptschedul:7,search:[0,4],second:[3,4,5,6,11,12,14],secret:0,section:[1,4],sector:12,secur:[4,12],securitywork:12,see:[4,5,7,8,14],select:4,sell:6,sellshort:[0,1],sellstock:[0,1],sensit:[4,6,12,14],separ:[2,4,14],sequenc:[3,6],sequenti:7,serial:[4,9],seriou:7,server:[4,8,14],serverexist:[0,1],servergrowthr:2,servermaxmonei:2,serverprofil:12,serverstartingmonei:2,serverstartingsecur:2,serverweakenr:2,set:[4,7,12,13,14],sever:9,share:[6,7],sharesshort:6,she:0,shell:13,shoplift:12,shortcut:[0,14],shortstock:[0,1],should:[4,8,12,14],show:[3,4,7,8,14],shown:[4,14],side:14,sigma:14,sign:14,signatur:[4,7],signific:4,significantli:7,similar:4,simpl:[7,8,9],simplest:4,simpli:[1,3],simplic:9,sinc:[4,7,9],singl:[3,4,10,14],singular:[0,1],situat:7,skill:4,sleep:[0,1,5,7,9,12],slice:9,slow:7,small:[7,12],snap:12,softwar:12,solar:14,sold:6,some:[4,7,8,9,10,12],some_valu:4,someth:0,someval1:9,someval2:9,sort:[4,9],sourc:[2,4,12],space:[13,14],spawn:[0,1],special:[3,5,11,12],specif:[4,9],specifi:[4,5,6,9,11,12,14],speed:4,splice:3,spoiler:[2,12],sprintf:[0,1],sqlinject:[0,1,12],stage:0,stai:4,start:[3,4,7,9,12,14],stat:[12,13],statement:8,statist:[6,14],steal:4,still:[4,7,14],stock:6,stolen:4,stop:[4,6,12,14],stopact:[0,1],stopbui:6,stopsel:6,store:[3,12],str:12,strategi:6,strength:12,strict:10,string:[3,4,6,12,14],structur:[2,4,5,9],strucur:12,studi:12,style:7,subject:2,subset:1,substitut:14,substr:4,subtract:10,success:[4,6,12],successfulli:[4,5,6,9,12,14],sudov:0,suggest:1,sum:4,summari:7,summit:12,support:[3,5,6,7,9,14],suppos:9,suspend:4,suspicion:0,sym:6,symbol:6,syntax:[1,4,9],system:6,tab:[7,13,14],tail:0,take:[0,4,12,13,14],target:[4,7,14],technolog:12,templat:4,ten:8,term:12,termin:[0,4,7,12],terminalinput:7,test2:[],test:[4,7],testlib:9,testlibrari:9,text:[3,4,7,14],than:[4,7,8,10,14],theft:12,thei:[1,2,4,7,13,14],them:[4,9,12],theme:0,therefor:7,thi:[0,1,2,3,4,5,6,7,9,10,11,12,13,14],thing:14,third:[4,6],those:[4,5,7],though:[4,9],thought:[3,7],thread:[4,7,11,12,14],three:[3,4,7,9,13,14],through:[4,5,7,9,12,13,14],thrown:7,time:[4,5,7,8,9,12,14],timework:12,tini:1,tix:[0,1],todo:14,tokyo:12,tolowercas:3,top:[0,7],tor:[12,14],total:[4,5,14],totalmoneygener:5,totalram:4,tprint:[0,1,7,9],tprintcolor:7,trade:[0,1],traffick:12,train:[12,13],transact:6,travel:[12,13],traveltoc:[0,1],travers:8,tri:[4,5,14],trywrit:9,tutori:13,tutorialspoint:[],two:[4,6,7,9,10,11,12],txt:[4,7,14],type:[0,1,4,6,7,12,14],typic:4,unabl:7,unalia:0,unalias_terminal_command:[],unari:[0,1],uncov:0,underli:[4,9],underscor:3,undo:14,undon:14,uni:4,uniqu:[4,7,14],univeristi:12,univers:[12,13],universitycours:[0,1],universitynam:12,unknown:0,unless:13,unlik:7,unlock:[6,12],until:[4,5,12],untyp:3,updat:12,upgrad:[5,12],upgradecor:5,upgradehomeram:[0,1],upgradelevel:5,upgraderam:5,url:7,usag:[4,9,14],use:[0,1,4,6,8,9,12,14],used:[1,3,4,5,6,9,12,13,14],user:[7,14],uses:[7,8],using:[4,5,6,7,8,9,11,12,14],usual:12,utc:9,util:[0,1],valid:[4,9,12,14],valu:[2,3,4,5,6,7,9,10,12,14],vari:4,variabl:[0,1,4,7,8,10,14],variou:[12,13],veri:7,version:7,vim:13,visibl:7,visit:[6,12],volhaven:12,vsprintf:[0,1],wai:[4,5,9,12,14],wait:9,waiter:12,want:[5,7,9,11,12,14],warn:[0,1,10,11,12,14],weaken:[0,1,7],web:[7,12,14],week:[],well:[3,7,13,14],were:[4,12,13,14],wese:6,what:[4,5,7,12,14],whatev:12,when:[0,1,4,7,8,9,12,14],where:[0,4,7,9,13],whether:[4,6,12,14],which:[3,4,5,6,9,12,14],whitespac:4,who:7,whose:14,window:13,within:7,without:[4,7,9,14],word:[4,13,14],work:[4,6,7,9,10,12,13,14],workagiexpgain:12,workchaexpgain:12,workdefexpgain:12,workdexexpgain:12,workforcompani:[0,1],workforfact:[0,1],workhackexpgain:12,workmoneygain:12,workrepgain:12,workstrexpgain:12,worktyp:12,world:[0,1,4,6],worm:14,would:[2,10,11,12,14],write:[0,1,5,6,7,9],written:[1,4,9],wrong:0,wrote:9,wse:6,www:[],yet:[4,12],you:[0,1,2,3,4,5,6,7,8,9,10,12,13,14],your:[0,1,5,6,7,12,13,14],yourself:5,zero:4,zip:14},titles:["Welcome to Bitburner's documentation!","Netscript Documentation","Netscript Advanced Functions","Netscript Data Types and Variables","Netscript Basic Functions","Netscript Hacknet Node API","Netscript Trade Information eXchange (TIX) API","NetscriptJS (Netscript 2.0)","Netscript Loops and Conditionals","Netscript Miscellaneous","Netscript Operators","Netscript Script Arguments","Netscript Singularity Functions","Keyboard Shortcuts","Terminal"],titleterms:{"final":7,"function":[2,4,9,12],"import":9,advanc:2,alia:14,analyz:14,api:[5,6],applytocompani:12,argument:11,bash:13,basic:4,binari:10,bitburn:0,brutessh:4,bui:14,buystock:6,cancelord:6,cat:14,check:14,checkfactioninvit:12,clear:[4,14],clearlog:4,cls:14,command:14,comment:9,commitcrim:12,condit:8,configur:14,connect:14,createprogram:12,data:3,date:9,defin:4,deleteserv:4,disablelog:4,document:[0,1],dom:[],download:14,editor:13,enablelog:4,exampl:[5,7],exchang:6,exec:4,exit:4,fileexist:4,firefox:7,free:14,ftpcrack:4,game:13,getaugmentationcost:12,getaugmentationsfromfact:12,getbitnodemultipli:2,getcharacterinform:12,getcompanyfavor:12,getcompanyrep:12,getcrimech:12,getfactionfavor:12,getfactionrep:12,getgrowtim:4,gethackinglevel:4,gethackingmultipli:4,gethacknetmultipli:4,gethacktim:4,gethostnam:4,getnexthacknetnodecost:4,getownedaugment:12,getpurchasedserv:4,getscriptexpgain:4,getscriptincom:4,getscriptnam:4,getscriptram:4,getserverbasesecuritylevel:4,getservergrowth:4,getservermaxmonei:4,getserverminsecuritylevel:4,getservermoneyavail:4,getservernumportsrequir:4,getserverram:4,getserverrequiredhackinglevel:4,getserversecuritylevel:4,getstat:12,getstockposit:6,getstockpric:6,gettimesincelastaug:4,getupgradehomeramcost:12,getweakentim:4,grow:4,gymworkout:12,hack:[4,14],hacknet:5,hacknetnod:5,handl:[],hasrootaccess:4,help:14,home:14,hostnam:14,how:7,httpworm:4,ifconfig:14,indic:0,inform:6,installaugment:12,isbusi:12,isrun:4,javascript:9,joinfact:12,keyboard:13,kill:[4,14],killal:[4,14],loop:8,lscpu:14,manipul:[],math:9,mem:14,member:5,method:5,misc:13,miscellan:9,modul:9,mozilla:7,nano:14,navig:13,netscript:[1,2,3,4,5,6,7,8,9,10,11,12],netscriptj:7,node:5,note:7,nuke:4,number:9,oper:10,own:4,peek:4,placeord:6,port:9,print:4,prompt:4,purchas:5,purchaseaugment:12,purchasehacknetnod:4,purchaseprogram:12,purchaseserv:4,purchasetor:12,read:4,relaysmtp:4,round:[],run:[4,14],scan:[4,14],scp:[4,14],script:[11,13],scriptkil:4,scriptrun:4,sellshort:6,sellstock:6,serverexist:4,shortcut:13,shortstock:6,singular:12,sleep:4,spawn:4,sprintf:4,sqlinject:4,stopact:12,sudov:14,tabl:0,tail:14,termin:[13,14],theme:14,tix:6,top:14,tprint:4,trade:6,traveltoc:12,type:3,unalia:14,unari:10,universitycours:12,upgradehomeram:12,usag:[],use:7,util:5,variabl:[3,5],vsprintf:4,warn:7,weaken:4,welcom:0,what:0,workforcompani:12,workforfact:12,write:4,your:4}})
\ No newline at end of file
diff --git a/doc/build/html/terminal.html b/doc/build/html/terminal.html
index d7316d46a..062013758 100644
--- a/doc/build/html/terminal.html
+++ b/doc/build/html/terminal.html
@@ -291,7 +291,7 @@ to run 'foo.script' with 50 threads.
Opens up the specified file in the Text Editor. Only scripts (.script) and
+
Opens up the specified file in the Text Editor. Only scripts (.script, .ns, .js) and
text files (.txt) can be edited. If the file does not already exist, then a new
empty file will be created.
diff --git a/doc/source/netscript.rst b/doc/source/netscript.rst
index 295b131c9..f2fca1857 100644
--- a/doc/source/netscript.rst
+++ b/doc/source/netscript.rst
@@ -14,6 +14,7 @@ to reach out to the developer!
:maxdepth: 5
:caption: Sections:
+ NetscriptJS (Netscript 2.0)
Data Types and Variables
Operators
Loops and Conditionals
diff --git a/doc/source/netscriptjs.rst b/doc/source/netscriptjs.rst
new file mode 100644
index 000000000..54947e3de
--- /dev/null
+++ b/doc/source/netscriptjs.rst
@@ -0,0 +1,202 @@
+NetscriptJS (Netscript 2.0)
+===========================
+Netscript 2.0, or Netscript JS, is the new and improved version of Netscript that
+allows users to write (almost) full-fledged Javascript code in their scripts, while
+still being able to access the Netscript functions.
+
+NetscriptJS was developed primarily by `Github user jaguilar `_
+
+On top of having almost all of the features and capabilities of Javascript, NetscriptJS is also
+significantly faster than Netscript 1.0.
+
+This documentation will not go over any of the additional features of NetscriptJS, since
+there is plenty of documentation on Javascript available on the web.
+
+NetscriptJS in Mozilla Firefox
+------------------------------
+As of the time of writing this, the Mozilla Firefox browser does not support
+dynamic import functionality and therefore cannot run NetscriptJS scripts.
+
+(This may be some option/method for enabling this in Firefox, but I don't know
+what is it)
+
+How to use NetscriptJS
+----------------------
+Working with NetscriptJS scripts is the same as Netscript 1.0 scripts. The only difference
+is that NetscriptJS scripts use the ".ns" or ".js" extension rather than ".script". E.g.::
+
+ $ nano foo.ns
+ $ run foo.ns -t 100 arg1 arg2 arg3
+ exec("foo.ns", "purchasedServer1", "100", "randomArg");
+
+The caveat when using NetscriptJS to write scripts is that your code must be
+asynchronous. Furthermore, instead of using the global scope and executing your code
+sequentially, NetscriptJS uses a :code:`main()` function as an entry point.
+
+Furthermore, the "Netscript environment" must be passed into a NetscriptJS script through
+the main function. This environment includes all of the pre-defined Netscript functions
+(:code:`hack()`, :code:`exec`, etc.) as well as the arguments you pass to the script.
+
+Therefore, the signature of the :code:`main()` function must be::
+
+ export async function main(ns) {
+ ns.print("Starting script here");
+ }
+
+Here is a summary of all rules you need to follow when writing Netscript JS code:
+
+* Write :code:`await` before any call to the following Netscript functions:
+
+ * hack
+ * grow
+ * weaken
+ * sleep
+ * run
+ * exec
+ * prompt
+
+* Any function that contains :code:`await` must be declared as :code:`async`
+
+* Always :code:`await` any function that is marked as :code:`async`
+
+* Any functions that you want to be visible from other scripts must be marked with :code:`export`.
+
+* **Do not write any infinite loops** without using a :code:`sleep` or one of the timed Netscript functions like :code:`hack`. Doing so will crash your game.
+
+* Any global variable declared in a NetscriptJS script is shared between all instances of that
+ script. For example, assume you write a script *foo.ns* and declared a global variable like so::
+
+ //foo.ns
+ let globalVariable;
+
+ export async function main(ns) {
+ globalVariable = ns.args.length;
+ while(true) {
+ tprint(globalVariable);
+ await sleep(3000);
+ }
+ }
+
+ Then, you ran multiple instances of *foo.ns*::
+
+ $ run foo.ns 1
+ $ run foo.ns 1 2 3
+ $ run foo.ns 1 2 3 4 5
+
+ Then all three instances of foo.ns will share the same instance of :code:`globalVariable`.
+ (In this example, the value of :code:`globalVariable` will be set to 5 because the
+ last instance of *foo.ns* to run has 5 arguments. This means that all three instances of
+ the script will repeatedly print the value 5).
+
+ These global variables can be thought of as `C++ static class members `_,
+ where a NetscriptJS script is a class and a global variable is a static member within that class.
+
+Warnings
+--------
+The NetscriptJS evaluation engine works by converting your code into a blob URL and then
+using a dynamic import to load your code as a module. Every unique NetscriptJS script
+is loaded as its own module. This means that
+making a small edit to a NetscriptJS script results in a new module being generated.
+
+At this point, we have been unable to find a method for deleting modules from browsers so that
+they get garbage collected.
+
+The result is that these modules from NetscriptJS scripts accumulate in your browser,
+using memory that never gets released. Over time, this results in a memory-leak type
+situation that can slow down your computer.
+
+Therefore, there are two recommendations for those who decide to use NetscriptJS:
+
+1. Every now and then, close and re-open the game. This will clear all of the modules.
+To be safe, I recommend **completely** closing the game's tab and then re-opening it.
+Depending on your browser, a refresh or page reload does not always clear the modules.
+
+2. Only use NetscriptJS scripts when needed. It is very unlikely that NetscriptJS
+is needed for very simple scripts. By doing this, you will reduce the number of modules
+that are loaded.
+
+Examples
+--------
+
+**DOM Manipulation (tprintColored.ns)**
+
+Directly alter the game's terminal and print colored text::
+
+ export function tprintColored(txt, color) {
+ let terminalInput = document.getElementById("terminal-input");
+ let rowElement = document.createElement("tr");
+ let cellElement = document.createElement("td");
+
+ rowElement.classList.add("posted");
+ cellElement.classList.add("terminal-line");
+ cellElement.style.color = color;
+ cellElement.innerText = txt;
+
+ rowElement.appendChild(cellElement);
+ terminalInput.before(rowElement);
+ }
+
+ export async function main(ns) {
+ tprintColored("Red Text!", "red");
+ tprintColored("Blue Text!", "blue");
+ tprintColored("Use Hex Codes!", "#3087E3");
+ }
+
+**Script Scheduler (scriptScheduler.ns)**
+
+This script shows some of the new functionality that is available in NetscriptJS,
+including objects and object constructors, changing an object's prototype, and
+importing other NetscriptJS scripts::
+
+ import {tprintColored} from "tprintColored.ns"; //Importing from other NetscriptJS scripts works!
+
+ function ScriptJob(params) {
+ if (params.fn == null) {
+ throw new Error("No Filename (fn) passed into ScriptJob ctor");
+ }
+
+ this.fn = params.fn;
+ this.threads = params.threads ? params.threads : 1;
+ this.args = params.args ? params.args : [];
+ }
+
+ ScriptJob.prototype.run = async function(ns) {
+ let runArgs = [this.fn, this.threads].concat(this.args);
+ await ns.run.apply(this, runArgs);
+ tprintColored("Running " + this.fn + " on " + ns.getHostname(), "blue");
+ }
+
+ ScriptJob.prototype.exec = async function(ns, target) {
+ ns.scp(this.fn, target);
+
+ let execArgs = [this.fn, target, this.threads].concat(this.args);
+ await ns.exec.apply(this, execArgs);
+
+ tprintColored("Executing " + this.fn + " on " + target, "blue");
+ }
+
+ export async function main(ns) {
+ tprintColored("Starting scriptScheduler.ns", "red");
+ try {
+ let job = new ScriptJob({
+ fn: "test.js",
+ threads: 1,
+ args: ["foodnstuff"]
+ });
+ await job.run(ns);
+ await job.exec(ns, "foodnstuff");
+ } catch (e) {
+ ns.tprint("Exception thrown in scriptScheduler.ns: " + e);
+ }
+ }
+
+Final Note
+----------
+NetscriptJS opens up a lot of possibilities when scripting. I look forward to seeing
+the scripts that people come up with. Just remember that the power and capabilities of
+NetscriptJS come with risks. Please backup your save if you're going to experiment with
+NetscriptJS and report any serious exploits.
+
+With great power comes great responsibility
+
+Happy hacking
diff --git a/doc/source/terminal.rst b/doc/source/terminal.rst
index 353d3d583..dcdd0a9c7 100644
--- a/doc/source/terminal.rst
+++ b/doc/source/terminal.rst
@@ -266,7 +266,7 @@ nano
$ nano [filename]
-Opens up the specified file in the Text Editor. Only scripts (.script) and
+Opens up the specified file in the Text Editor. Only scripts (.script, .ns, .js) and
text files (.txt) can be edited. If the file does not already exist, then a new
empty file will be created.
diff --git a/src/ActiveScriptsUI.js b/src/ActiveScriptsUI.js
index 94cd0cd79..2c9ee4aa7 100644
--- a/src/ActiveScriptsUI.js
+++ b/src/ActiveScriptsUI.js
@@ -146,7 +146,7 @@ function deleteActiveScriptsItem(workerscript) {
var server = getServer(workerscript.serverIp);
if (server == null) {
throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " +
- "you tried to delete a large number of scripts and also purchased servers at the " +
+ "you tried to delete a large number of scripts and also deleted servers at the " +
"same time. It's not a big deal, just save and refresh the game.");
return;
}
diff --git a/src/Bladeburner.js b/src/Bladeburner.js
index 219042d35..c353479be 100644
--- a/src/Bladeburner.js
+++ b/src/Bladeburner.js
@@ -506,8 +506,6 @@ Action.prototype.getSuccessChance = function(inst, params={}) {
//Tests for success. Should be called when an action has completed
// @inst - Bladeburner Object
Action.prototype.attempt = function(inst) {
- console.log("Current City Pop: " + inst.getCurrentCity().pop);
- console.log("Action.attempt success chance: " + this.getSuccessChance(inst));
return (Math.random() < this.getSuccessChance(inst));
}
diff --git a/src/Faction.js b/src/Faction.js
index 8abffd37b..08481ab92 100644
--- a/src/Faction.js
+++ b/src/Faction.js
@@ -1031,6 +1031,14 @@ function purchaseAugmentation(aug, fac, sing=false) {
var txt = "You must first purchase or install " + aug.prereqs.join(",") + " before you can " +
"purchase this one.";
if (sing) {return txt;} else {dialogBoxCreate(txt);}
+ } else if (Player.money.lt(aug.baseCost * fac.augmentationPriceMult)) {
+ let txt = "You don't have enough money to purchase " + aug.name;
+ if (sing) {return txt;}
+ dialogBoxCreate(txt);
+ } else if (fac.playerReputation < aug.baseRepRequirement) {
+ let txt = "You don't have enough faction reputation to purchase " + aug.name;
+ if (sing) {return txt;}
+ dialogBoxCreate(txt);
} else if (Player.money.gte(aug.baseCost * fac.augmentationPriceMult)) {
if (Player.firstAugPurchased === false) {
Player.firstAugPurchased = true;
@@ -1077,11 +1085,9 @@ function purchaseAugmentation(aug, fac, sing=false) {
displayFactionAugmentations(fac.name);
} else {
- if (sing) {
- return "You don't have enough money to purchase " + aug.name;
- } else {
- dialogBoxCreate("You don't have enough money to purchase this Augmentation!");
- }
+ dialogBoxCreate("Hmm, something went wrong when trying to purchase an Augmentation. " +
+ "Please report this to the game developer with an explanation of how to " +
+ "reproduce this.");
}
yesNoBoxClose();
}
diff --git a/src/NetscriptJSEvaluator.js b/src/NetscriptJSEvaluator.js
index 413b10fbe..2c5a6d01f 100644
--- a/src/NetscriptJSEvaluator.js
+++ b/src/NetscriptJSEvaluator.js
@@ -14,9 +14,10 @@ export function makeScriptBlob(code) {
// (i.e. hack, grow, etc.).
// When the promise returned by this resolves, we'll have finished
// running the main function of the script.
-export async function executeJSScript(script, scripts = [], workerScript) {
+export async function executeJSScript(scripts = [], workerScript) {
let loadedModule;
let urlStack = null;
+ let script = workerScript.getScript();
if (script.module === "") {
// The URL at the top is the one we want to import. It will
// recursively import all the other modules in the urlStack.
diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js
index c00e5f142..941464d77 100644
--- a/src/NetscriptWorker.js
+++ b/src/NetscriptWorker.js
@@ -40,6 +40,18 @@ WorkerScript.prototype.getServer = function() {
return AllServers[this.serverIp];
}
+//Returns the Script object for the underlying script
+WorkerScript.prototype.getScript = function() {
+ let server = this.getServer();
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename === this.name) {
+ return server.scripts[i];
+ }
+ }
+ console.log("ERROR: Failed to find underlying Script object in WorkerScript.getScript(). This probably means somethings wrong");
+ return null;
+}
+
//Array containing all scripts that are running across all servers, to easily run them all
let workerScripts = [];
@@ -110,8 +122,7 @@ function startJsScript(workerScript) {
// Note: the environment that we pass to the JS script only needs to contain the functions visible
// to that script, which env.vars does at this point.
- return executeJSScript(workerScript.scriptRef.scriptRef,
- workerScript.getServer().scripts,
+ return executeJSScript(workerScript.getServer().scripts,
workerScript).then(function (mainReturnValue) {
if (mainReturnValue === undefined) return workerScript;
return [mainReturnValue, workerScript];
@@ -156,13 +167,14 @@ function runScriptsLoop() {
workerScripts.splice(i, 1);
}
}
+ updateActiveScriptsItems(); //Force Update
//Run any scripts that haven't been started
for (var i = 0; i < workerScripts.length; i++) {
//If it isn't running, start the script
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
let p = null; // p is the script's result promise.
- if (workerScripts[i].name.endsWith(".js")) {
+ if (workerScripts[i].name.endsWith(".js") || workerScripts[i].name.endsWith(".ns")) {
p = startJsScript(workerScripts[i]);
} else {
try {
diff --git a/src/Script.js b/src/Script.js
index d720d7298..7ca28513a 100644
--- a/src/Script.js
+++ b/src/Script.js
@@ -46,7 +46,7 @@ var keybindings = {
};
function isScriptFilename(f) {
- return f.endsWith(".js") || f.endsWith(".script");
+ return f.endsWith(".js") || f.endsWith(".script") || f.endsWith(".ns");
}
var scriptEditorRamCheck = null, scriptEditorRamText = null;
@@ -345,6 +345,7 @@ Script.prototype.saveScript = function() {
//Calculate/update ram usage, execution time, etc.
this.updateRamUsage();
+ console.log(this.module);
this.module = "";
}
diff --git a/src/engine.js b/src/engine.js
index f6a0e2d73..e052ce137 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -1764,6 +1764,8 @@ window.onload = function() {
var db = e.target.result;
var objectStore = db.createObjectStore("savestring");
}
+
+ console.log(window.location.href);
};
export {Engine};