diff --git a/doc/build/doctrees/environment.pickle b/doc/build/doctrees/environment.pickle index 32ab60f14..d709829ab 100644 Binary files a/doc/build/doctrees/environment.pickle and b/doc/build/doctrees/environment.pickle differ diff --git a/doc/build/doctrees/netscriptfunctions.doctree b/doc/build/doctrees/netscriptfunctions.doctree index c28d21fbe..8f995ab0d 100644 Binary files a/doc/build/doctrees/netscriptfunctions.doctree and b/doc/build/doctrees/netscriptfunctions.doctree differ diff --git a/doc/build/html/_sources/netscriptfunctions.rst.txt b/doc/build/html/_sources/netscriptfunctions.rst.txt index 2adbdab2e..3b0dd2a13 100644 --- a/doc/build/html/_sources/netscriptfunctions.rst.txt +++ b/doc/build/html/_sources/netscriptfunctions.rst.txt @@ -742,7 +742,7 @@ rm :param string fn: Filename of file to remove. Must include the extension :returns: True if it successfully deletes the file, and false otherwise - Removes the specified file from the current server. This function works for every file type except message (.msg) files. + Removes the specified file from the current server. This function works for every file type except message (.msg) files. scriptRunning ^^^^^^^^^^^^^ @@ -900,21 +900,47 @@ Functions should have some return value. Here is an example of defining and usin return res; } - print(sum([1, 2, 3, 4, 5])); - print(sum([1, 10])); + print(sum([1, 2, 3, 4, 5])); //Prints 15 + print(sum([1, 10])); //Prints 11 -The example above prints the following in its log:: +For those with experience in other languages, especially Javascript, it may be important to note that +function declarations are not hoisted and must be declared BEFORE you use them. +For example, the following will cause an error saying `variable hello not defined`:: - 15 - 11 + print(hello()); + + function hello() { + return "world"; + } + +The following will work fine:: + + function hello() { + return "world"; + } + + print(hello()); //Prints out "world" **Note about variable scope in functions:** Functions can access "global" variables declared outside of the function's scope. However, they cannot change the value of any "global" variables. -Any changes to "global" variables will only be applied locally to the function. This also means that any variable that is first defined inside a -function will NOT be accessible outside of the function. +Any changes to "global" variables will only be applied locally to the function. -For example, the following code:: +The following example shows that any change to a "global" variable +from inside a function only applies in the function's local scope:: + + function foo() { + i = 5; + return "foo"; + } + + i = 0; + print(i); //Prints 0 + foo(); + print(i); //Prints 0 + +Furthermore, this also means that any variable that is first defined inside a +function will NOT be accessible outside of the function as shown in the following example:: function sum(values) { res = 0; @@ -933,22 +959,6 @@ results in the following runtime error:: Args:[] variable res not defined -The following example shows that any change to "global" variable inside a function only applies in the function's local scope:: - - function foo() { - i = 5; - return "foo"; - } - - i = 0; - print(i); - foo(); - print(i); - -Results in the following log:: - - 0 - 0 **Other Notes about creating your own functions:** diff --git a/doc/build/html/netscriptfunctions.html b/doc/build/html/netscriptfunctions.html index 244698783..f61d66af6 100644 --- a/doc/build/html/netscriptfunctions.html +++ b/doc/build/html/netscriptfunctions.html @@ -1509,20 +1509,46 @@ false if the player clicks "No". The script's execution is halted unti return res; } -print(sum([1, 2, 3, 4, 5])); -print(sum([1, 10])); +print(sum([1, 2, 3, 4, 5])); //Prints 15 +print(sum([1, 10])); //Prints 11 -

The example above prints the following in its log:

-
15
-11
+

For those with experience in other languages, especially Javascript, it may be important to note that +function declarations are not hoisted and must be declared BEFORE you use them. +For example, the following will cause an error saying variable hello not defined:

+
print(hello());
+
+function hello() {
+    return "world";
+}
+
+
+

The following will work fine:

+
function hello() {
+    return "world";
+}
+
+print(hello());     //Prints out "world"
 

Note about variable scope in functions:

Functions can access "global" variables declared outside of the function's scope. However, they cannot change the value of any "global" variables. -Any changes to "global" variables will only be applied locally to the function. This also means that any variable that is first defined inside a -function will NOT be accessible outside of the function.

-

For example, the following code:

+Any changes to "global" variables will only be applied locally to the function.

+

The following example shows that any change to a "global" variable +from inside a function only applies in the function's local scope:

+
function foo() {
+    i = 5;
+    return "foo";
+}
+
+i = 0;
+print(i);   //Prints 0
+foo();
+print(i);   //Prints 0
+
+
+

Furthermore, this also means that any variable that is first defined inside a +function will NOT be accessible outside of the function as shown in the following example:

function sum(values) {
     res = 0;
     for (i = 0; i < values.length; ++i) {
@@ -1541,23 +1567,6 @@ function will NOT be accessible outside of the function.

variable res not defined
-

The following example shows that any change to "global" variable inside a function only applies in the function's local scope:

-
function foo() {
-    i = 5;
-    return "foo";
-}
-
-i = 0;
-print(i);
-foo();
-print(i);
-
-
-

Results in the following log:

-
0
-0
-
-

Other Notes about creating your own functions:

Defining a function does not create a Javascript function object in the underlying game code. This means that you cannot use any function you create in functions such as Array.sort() (not yet at least, I'll try to make it work in the future).

diff --git a/doc/build/html/searchindex.js b/doc/build/html/searchindex.js index 9c3e67c52..e19e3640a 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"],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"],objects:{"":{applyToCompany:[11,2,1,""],buyStock:[6,2,1,""],cancelOrder:[6,2,1,""],checkFactionInvitations:[11,2,1,""],clearLog:[4,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,""],getCompanyRep:[11,2,1,""],getCrimeChance:[11,2,1,""],getFactionRep:[11,2,1,""],getGrowTime:[4,2,1,""],getHackTime:[4,2,1,""],getHackingLevel:[4,2,1,""],getHackingMultipliers:[4,2,1,""],getHostname:[4,2,1,""],getNextHacknetNodeCost:[4,2,1,""],getOwnedAugmentations:[11,2,1,""],getPurchasedServers:[4,2,1,""],getScriptExpGain:[4,2,1,""],getScriptIncome:[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:[4,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,""],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:{"8gb":5,"boolean":[3,4,11],"break":10,"case":[4,6,11],"class":11,"default":[4,11],"float":3,"function":[0,1,3,5,6,7,8],"import":8,"long":6,"new":[4,5,8,11],"null":[4,8],"return":[2,4,5,6,8,9,11],"short":6,"static":8,"true":[3,4,5,6,8,9,11],"try":[4,8,10,11],"var":7,"while":[4,5,7,8,11],AND:9,Adding:3,And:8,For:[2,3,4,5,7,8,9,10],IPs:4,NOT:[4,6,9,11],Not:11,One:11,The:[0,2,3,4,5,6,7,8,10,11],Their:3,Then:[5,8],These:[2,4,5,11],Use:4,Will:[4,6],Yes:4,abil:6,abl:11,about:[3,4,8],abov:[3,4,8,9],accept:11,access:[3,4,5,6,8,10,11],action:11,activ:4,actual:[4,6,8,11],add:5,added:4,addit:[4,5,9,11],address:4,advanc:[0,1],aevum:11,affect:4,afford:4,after:[3,4,6,8,11],agenc:11,agent:11,agi:11,agil:11,aid:0,aka:11,algorithm:[6,11],all:[3,4,5,6,8,11],allow:[6,8,11],almost:1,alphabet:4,alphanumer:3,alreadi:[4,11],also:[3,4,6,10,11],alwai:[],amount:[4,5,6,10,11],ani:[0,1,3,4,11],anoth:[4,10],anyth:4,anywher:4,api:[0,1],appear:4,append:4,appli:[4,11],applytocompani:[0,1],arg:[4,10],argument:[0,1,4,5,6,8,11],around:[0,11],arrai:[3,4,5,6,8,10,11],aspect:11,assign:[5,9],assum:8,attack:4,attempt:[6,8],augment:[4,6,11],augmentationmoneycost:2,augmentationrepcost:2,augnam:11,autolink:11,autom:[5,6],automat:[4,6,11],avail:[3,4,6,7,11],averag:6,avgpx:6,avgpxshort:6,back:8,base:[4,9],basic:[0,1],becaus:[2,4],becom:2,been:0,befor:8,being:4,below:4,best:10,beta:0,between:[2,4,8],billion:6,binari:[0,1],bitburn:1,bitnod:[2,11],both:4,box:4,brief:8,brutessh:[0,1,11],bui:[6,11],build:6,busi:11,buystock:[0,1],calcul:6,call:[0,4,5,8,10,11],callback:11,can:[0,3,4,5,6,7,8,10,11],cancel:[6,11],cancelord:[0,1],cannot:[4,5],capabl:3,capit:6,caus:4,caveat:7,cbscript:11,certain:[4,6],chanc:[4,11],chang:[2,3,4,9],charact:3,charisma:11,check:[4,7,11],checkfactioninvit:[0,1],chongq:11,citi:11,citynam:11,classgymexpgain:2,clear:[0,1,8],clearlog:[0,1],click:4,close:8,code:[4,6,7,8,9,10],command:[3,4,11],comment:[0,1,9],commiss:6,commit:[2,11],commitcrim:[0,1],commun:[6,8],compani:[6,11],companynam:11,companyworkexpgain:2,companyworkmonei:2,complet:4,comput:[4,11],condit:[0,1],confirm:0,constantli:4,constrain:4,consult:11,contain:[2,3,4,8,11],content:0,continu:11,contract:11,control:11,convert:4,copi:4,core:5,correct:11,correspond:5,cost:[4,5,6,11],count:4,cours:11,coursenam:11,creat:[4,6,11],createprogram:[0,1],crime:[2,11],crimeexpgain:2,crimemonei:2,crush:11,current:[0,2,4,6,11],cyberpunk:0,dark:[0,11],data:[0,1,4,8,11],date:[0,1],deal:8,decim:11,declar:[3,4,7],decreas:4,decrement:9,deepscanv1:11,deepscanv2:11,def:11,defens:11,defin:[0,1],delai:4,delet:4,deleteserv:[0,1],denot:[4,8],depend:4,describ:4,destin:4,detail:4,determin:4,develop:[0,1],dex:11,dexter:11,dialog:4,differ:[2,3,4],disabl:4,disablelog:[0,1],divis:9,document:[4,7,8,11],doe:[1,4,6,8,9],doing:[5,10],don:[8,11],doubl:[3,5],due:4,dystopian:0,each:[5,6,11],earli:0,earn:[4,5,11],ecp:6,effect:4,either:[3,4],element:[4,5,6,8,10,11],els:[7,11],embark:0,emploi:11,employe:11,empti:[4,8],enabl:4,enablelog:[0,1],encapsul:3,end:[4,5,8,11],endpoint:8,engin:11,enough:[4,6],equal:9,equival:[3,4],error:4,etc:[3,4,10,11],evalu:8,even:[4,6,8,9],everi:[4,6,8,11],exampl:[0,1,2,3,4,6,7,8,9,10,11],exce:6,exceed:4,except:4,exchang:[0,1],exe:[4,11],exec:[0,1],execut:[4,6,8],exist:[4,5,7],exit:[0,1],experi:[4,11],explain:8,extens:[4,11],facnam:11,faction:11,factionnam:11,factionpassiverepgain:2,factionworkexpgain:2,factionworkrepgain:2,fail:[4,11],failur:4,fairlyn:11,fals:[3,4,5,6,8,9,11],featur:1,fee:6,feel:1,field:11,fieldwork:11,file:[2,4,11],fileexist:[0,1],filenam:4,fill:4,find:4,findindex:8,fine:4,finish:11,first:[3,4,5,6,8,10,11],fisg:6,fit:11,fix:4,floor:8,follow:[2,3,4,5,7,8,11],foo1:4,foo2:4,foo3:4,foo:[4,8],foodnstuff:[4,7,8],form:[2,4],four:[5,6],fourth:[5,6],free:1,from:[4,6,8,10,11],ftpcrack:[0,1,11],full:8,fulli:3,futur:[2,4],gain:[0,4,11],game:[0,2,4,6,8,10,11],gener:[4,9,10],get:[4,8,10,11],getaugmentationcost:[0,1],getaugmentationsfromfact:[0,1],getbitnodemultipli:[0,1],getcompanyrep:[0,1],getcoreupgradecost:5,getcrimech:[0,1],getfactionrep:[0,1],getgrowtim:[0,1],gethackinglevel:[0,1],gethackingmultipli:[0,1],gethacktim:[0,1],gethostnam:[0,1],getlevelupgradecost:5,getnexthacknetnodecost:[0,1],getownedaugment:[0,1],getporthandl:8,getpurchasedserv:[0,1],getramupgradecost:5,getscriptexpgain:[0,1],getscriptincom:[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],global:4,greater:9,grep:4,grow:[0,1,7],grown:7,growth:4,gym:11,gymnam:11,gymworkout:[0,1],hack:[0,1,7,11],hacker:0,hackexpgain:2,hackingcontract:11,hacknet:[0,1,4],hacknetnod:[0,1],hacknetnodemonei:2,halt:4,handl:8,has:[1,2,4,5,11],hasrootaccess:[0,1],have:[1,2,4,5,6,11],helio:4,here:[0,3,4,6,7,8,11],higher:4,hold:3,home:[4,11],hope:0,hostnam:4,how:[3,4,7,8],howev:[4,7,8],httpworm:[0,1,11],hyphen:3,ident:1,identifi:4,immedi:[4,6,11],implement:[1,8],improv:1,includ:[3,4,11],incom:[4,5],increas:4,increment:[0,9],index:[0,4,5],indic:[4,11],inequ:9,inform:[0,1,4],initi:3,input:11,insid:[4,5,8],instal:[4,6,11],installaugment:[0,1],instanc:4,instead:[2,4],institut:11,instrins:4,integ:[2,3,4,5,6],intellig:11,interact:8,invalid:[4,11],invit:11,iron:11,isbusi:[0,1],ishima:11,isinteg:8,isrun:[0,1],issu:11,item:8,iter:[5,7],its:[4,6,8],itself:5,javascript:[0,1,3,4,7],job:11,joesgun:4,join:[3,11],joinfact:[0,1],jump3r:0,just:[4,8],keyword:7,kill:[0,1],killal:[0,1],know:8,label:3,languag:[1,3],last:[4,8],later:[2,3,6,11],lead:0,leadership:11,least:[4,5],length:[4,5,10],lenient:11,less:9,let:[6,7,8,10],letter:[3,6],level:[4,5,11],like:[4,8,10],limit:[4,6],limitbui:6,limitsel:6,line:8,link:4,list:[5,11],lit:4,literatur:4,local:4,locat:[4,11],log:[4,5,8],logic:9,look:[8,10],loop:[0,1],lose:8,lot:11,lower:4,made:6,make:[4,10],manag:11,mani:[1,3,11],manual:11,manualhackmonei:2,map:5,market:6,math:[0,1],max:5,maximum:4,mayb:8,mean:[0,1,2,3,4,5,8,11],member:[0,1,3,11],memori:4,messag:[0,4],method:[0,1,3,8],middl:11,millenium:11,millisecond:4,minimum:4,minut:11,miscellan:[0,1],mode:4,modifi:10,modul:[0,1],modulo:9,monei:[0,2,4,5,6,7,11],moneygainratepersecond:5,more:[3,4,7],most:3,msg:4,much:7,mult:[2,4],multi:8,multipl:[4,9],multipli:[2,4,11],must:[3,4,5,6,11],mysteri:0,name:[3,4,5,6,9,10,11],nearest:[4,5,6],necessari:0,need:4,negat:9,net:6,netscript:0,netscriptport:8,network:11,newli:4,next:4,node:[0,1,4],none:[4,5],normal:[8,10,11],notabl:4,note:[4,5,11],now:[0,8],nuke:[0,1],number:[0,1,3,4,5,6,9,10],numer:[3,6,9],numthread:[4,8],object:[2,3,4,5,11],obtain:4,obvious:11,offlin:4,omit:4,one:[4,5,7,8,11],onli:[2,4,5,6,8,9,11],onlin:4,onlinetimesecond:5,onto:3,open:[4,8,11],oper:[0,1,8,10],operand:9,option:[4,11],order:[2,4,6,11],origin:2,other:[4,8,11],otherwis:[4,5,6,7,8,11],our:8,oustand:[6,11],out:[1,4,8,11],output:4,outsid:[4,11],over:4,overwrit:4,own:[0,1,6],page:[0,2,4,8,11],param:[],paramet:4,pars:8,part:11,particular:11,pass:[4,8,10,11],peek:[0,1,8],percentag:4,perform:11,place:6,placeord:[0,1],plai:0,plan:10,player:[0,4,5,6,10,11],pop:[3,8],port:[0,1,4],pos:6,posit:[3,5,6,11],possibl:10,power:[0,4],powerhous:11,pre:9,prevent:10,price:6,primit:3,print:[0,1,2,5,8,11],process:4,produc:9,profit:6,program:[1,4,11],programnam:11,promot:11,prompt:[0,1],properti:11,protocol:6,provid:[5,6],pserv:4,purchas:[4,5,6,11],purchaseaugment:[0,1],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,rais:4,ram:[4,5,11],ramus:4,ran:[4,8],rate:4,reach:1,read:[0,1,3,5,8],reason:4,receiv:[2,11],refer:[3,7],referenc:3,reflect:6,regardless:4,relat:[4,8],relaysmtp:[0,1,11],relev:2,reload:8,rememb:[4,6],remov:[4,8],repres:[2,3,4,6,8],reput:11,request:1,requir:[2,4,9,11],res:[4,8,11],reset:[4,6,11],resolv:4,rest:3,restart:11,result:[4,9],retain:6,revert:4,right:8,role:0,room:8,root:4,rothman:[4,11],round:[4,5,6],router:11,rpg:0,run:[0,1,2,7,8,9,10,11],runtim:4,sai:10,sake:8,sale:6,same:[4,7,8,11],save:8,scan:[0,1],scienc:11,scope:4,scp:[0,1],script:[0,1,4,5,6,8,11],scripthackmonei:2,scriptkil:[0,1],scriptnam:4,scriptrun:[0,1],search:[0,4],second:[3,4,5,6,10,11],secret:0,section:[1,4],sector:11,secur:[4,11],securitywork:11,see:[4,5,7],select:4,sell:6,sellshort:[0,1],sellstock:[0,1],sensit:[4,6,11],separ:[2,4],sequenc:[3,6],serial:[4,8],server:[4,7],serverexist:[0,1],servergrowthr:2,servermaxmonei:2,serverprofil:11,serverstartingmonei:2,serverstartingsecur:2,serverweakenr:2,set:[4,11],sever:8,share:6,sharesshort:6,she:0,shortstock:[0,1],should:[4,7,11],show:[3,4,7],signatur:4,signific:4,similar:4,simpl:[7,8],simplest:4,simpli:[1,3],simplic:8,sinc:[4,8],singl:[3,4,9],singular:[0,1],skill:4,sleep:[0,1,5,8,11],slice:8,small:11,snap:11,softwar:11,sold:6,some:[4,7,8,9,11],some_valu:4,someth:0,sort:[4,8],sourc:[2,4,11],spawn:[0,1],special:[3,5,10,11],specif:4,specifi:[4,5,6,8,10,11],speed:4,splice:3,spoiler:[2,11],sprintf:[0,1],sqlinject:[0,1,11],stage:0,stai:4,start:[3,4,8,11],stat:11,statement:7,statist:6,steal:4,still:4,stock:6,stolen:4,stop:[4,6,11],stopact:[0,1],stopbui:6,stopsel:6,store:3,str:11,strategi:6,strength:11,strict:9,string:[3,4,6,11],structur:[2,4,8],strucur:11,studi:11,subject:2,subset:1,substr:4,subtract:9,success:[4,6,11],successfulli:[4,5,6,8,11],suggest:1,sum:4,summit:11,support:[3,5,6,8],suspend:4,suspicion:0,sym:6,symbol:6,syntax:[1,4,8],system:6,take:[0,4,11],target:4,technolog:11,templat:4,ten:7,term:11,termin:[4,11],test:4,text:[3,4],than:[4,7,9],thei:[1,2,4],them:[8,11],theme:0,thi:[0,1,2,3,4,5,6,8,9,10,11],third:[4,6],those:[4,5],though:[4,8],thought:3,thread:[4,10,11],three:[3,4,8],through:[4,5,8,11],time:[4,5,7,8,11],tini:1,tix:[0,1],tokyo:11,tolowercas:3,tor:11,total:[4,5],totalmoneygener:5,totalram:4,tprint:[0,1,8],trade:[0,1],train:11,transact:6,travel:11,traveltoc:[0,1],travers:7,tri:[4,5],trywrit:8,two:[4,6,9,10,11],txt:4,type:[0,1,4,6,11],typic:4,unari:[0,1],uncov:0,underli:[4,8],underscor:3,uni:4,uniqu:4,univeristi:11,univers:11,universitycours:[0,1],universitynam:11,unknown:0,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],use:[4,6,7,11],used:[1,3,4,5,6,8,11],uses:7,using:[4,5,6,7,8,10,11],usual:11,utc:8,valid:[4,8],valu:[2,3,4,5,6,8,9,11],vari:4,variabl:[0,1,4,7,9],visit:[6,11],volhaven:11,vsprintf:[0,1],wai:[4,5,8,11],wait:8,waiter:11,want:[5,10,11],warn:[9,10,11],weaken:[0,1],web:11,well:3,were:[4,11],wese:6,what:[4,5,11],whatev:11,when:[0,1,4,7,8,11],where:[0,4,8],whether:[4,6,11],which:[3,4,5,6,8,11],whitespac:4,without:4,word:4,work:[4,6,8,9,11],workforcompani:[0,1],workforfact:[0,1],worktyp:11,world:[0,1,6],would:[2,9,10,11],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],your:[0,1,5,6,11],yourself:5,zero:4},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"],titleterms:{"function":[2,4,11],advanc:2,api:[5,6],applytocompani:11,argument:10,basic:4,binari:9,bitburn:0,brutessh:4,buystock:6,cancelord:6,checkfactioninvit:11,clear:4,clearlog:4,comment:8,commitcrim:11,condit:7,createprogram:11,data:3,date:8,defin:4,deleteserv:4,disablelog:4,document:[0,1],enablelog:4,exampl:5,exchang:6,exec:4,exit:4,fileexist:4,ftpcrack:4,getaugmentationcost:11,getaugmentationsfromfact:11,getbitnodemultipli:2,getcompanyrep:11,getcrimech:11,getfactionrep:11,getgrowtim:4,gethackinglevel:4,gethackingmultipli:4,gethacktim:4,gethostnam:4,getnexthacknetnodecost:4,getownedaugment:11,getpurchasedserv:4,getscriptexpgain:4,getscriptincom: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,hacknet:5,hacknetnod:5,handl:[],hasrootaccess:4,httpworm:4,indic:0,inform:6,installaugment:11,isbusi:11,isrun:4,javascript:8,joinfact:11,kill:4,killal:4,loop:7,math:8,member:5,method:5,miscellan:8,modul:8,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,purchaseaugment:11,purchasehacknetnod:4,purchaseprogram:11,purchaseserv:4,purchasetor:11,read:4,relaysmtp:4,round:[],run:4,scan:4,scp:4,script:10,scriptkil:4,scriptrun:4,sellshort:6,sellstock:6,serverexist:4,shortstock:6,singular:11,sleep:4,spawn:4,sprintf:4,sqlinject:4,stopact:11,tabl:0,tix:6,tprint:4,trade:6,traveltoc:11,type:3,unari:9,universitycours:11,upgradehomeram:11,usag:[],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","netscriptloopsandconditionals","netscriptmisc","netscriptoperators","netscriptscriptarguments","netscriptsingularityfunctions"],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"],objects:{"":{applyToCompany:[11,2,1,""],buyStock:[6,2,1,""],cancelOrder:[6,2,1,""],checkFactionInvitations:[11,2,1,""],clearLog:[4,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,""],getCompanyRep:[11,2,1,""],getCrimeChance:[11,2,1,""],getFactionRep:[11,2,1,""],getGrowTime:[4,2,1,""],getHackTime:[4,2,1,""],getHackingLevel:[4,2,1,""],getHackingMultipliers:[4,2,1,""],getHostname:[4,2,1,""],getNextHacknetNodeCost:[4,2,1,""],getOwnedAugmentations:[11,2,1,""],getPurchasedServers:[4,2,1,""],getScriptExpGain:[4,2,1,""],getScriptIncome:[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:[4,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,""],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:{"8gb":5,"boolean":[3,4,11],"break":10,"case":[4,6,11],"class":11,"default":[4,11],"float":3,"function":[0,1,3,5,6,7,8],"import":[4,8],"long":6,"new":[4,5,8,11],"null":[4,8],"return":[2,4,5,6,8,9,11],"short":6,"static":8,"true":[3,4,5,6,8,9,11],"try":[4,8,10,11],"var":7,"while":[4,5,7,8,11],AND:9,Adding:3,And:8,For:[2,3,4,5,7,8,9,10],IPs:4,NOT:[4,6,9,11],Not:11,One:11,The:[0,2,3,4,5,6,7,8,10,11],Their:3,Then:[5,8],These:[2,4,5,11],Use:4,Will:[4,6],Yes:4,abil:6,abl:11,about:[3,4,8],abov:[3,4,8,9],accept:11,access:[3,4,5,6,8,10,11],action:11,activ:4,actual:[4,6,8,11],add:5,added:4,addit:[4,5,9,11],address:4,advanc:[0,1],aevum:11,affect:4,afford:4,after:[3,4,6,8,11],agenc:11,agent:11,agi:11,agil:11,aid:0,aka:11,algorithm:[6,11],all:[3,4,5,6,8,11],allow:[6,8,11],almost:1,alphabet:4,alphanumer:3,alreadi:[4,11],also:[3,4,6,10,11],alwai:[],amount:[4,5,6,10,11],ani:[0,1,3,4,11],anoth:[4,10],anyth:4,anywher:4,api:[0,1],appear:4,append:4,appli:[4,11],applytocompani:[0,1],arg:[4,10],argument:[0,1,4,5,6,8,11],around:[0,11],arrai:[3,4,5,6,8,10,11],aspect:11,assign:[5,9],assum:8,attack:4,attempt:[6,8],augment:[4,6,11],augmentationmoneycost:2,augmentationrepcost:2,augnam:11,autolink:11,autom:[5,6],automat:[4,6,11],avail:[3,4,6,7,11],averag:6,avgpx:6,avgpxshort:6,back:8,base:[4,9],basic:[0,1],becaus:[2,4],becom:2,been:0,befor:[4,8],being:4,below:4,best:10,beta:0,between:[2,4,8],billion:6,binari:[0,1],bitburn:1,bitnod:[2,11],both:4,box:4,brief:8,brutessh:[0,1,11],bui:[6,11],build:6,busi:11,buystock:[0,1],calcul:6,call:[0,4,5,8,10,11],callback:11,can:[0,3,4,5,6,7,8,10,11],cancel:[6,11],cancelord:[0,1],cannot:[4,5],capabl:3,capit:6,caus:4,caveat:7,cbscript:11,certain:[4,6],chanc:[4,11],chang:[2,3,4,9],charact:3,charisma:11,check:[4,7,11],checkfactioninvit:[0,1],chongq:11,citi:11,citynam:11,classgymexpgain:2,clear:[0,1,8],clearlog:[0,1],click:4,close:8,code:[4,6,7,8,9,10],command:[3,4,11],comment:[0,1,9],commiss:6,commit:[2,11],commitcrim:[0,1],commun:[6,8],compani:[6,11],companynam:11,companyworkexpgain:2,companyworkmonei:2,complet:4,comput:[4,11],condit:[0,1],confirm:0,constantli:4,constrain:4,consult:11,contain:[2,3,4,8,11],content:0,continu:11,contract:11,control:11,convert:4,copi:4,core:5,correct:11,correspond:5,cost:[4,5,6,11],count:4,cours:11,coursenam:11,creat:[4,6,11],createprogram:[0,1],crime:[2,11],crimeexpgain:2,crimemonei:2,crush:11,current:[0,2,4,6,11],cyberpunk:0,dark:[0,11],data:[0,1,4,8,11],date:[0,1],deal:8,decim:11,declar:[3,4,7],decreas:4,decrement:9,deepscanv1:11,deepscanv2:11,def:11,defens:11,defin:[0,1],delai:4,delet:4,deleteserv:[0,1],denot:[4,8],depend:4,describ:4,destin:4,detail:4,determin:4,develop:[0,1],dex:11,dexter:11,dialog:4,differ:[2,3,4],disabl:4,disablelog:[0,1],divis:9,document:[4,7,8,11],doe:[1,4,6,8,9],doing:[5,10],don:[8,11],doubl:[3,5],due:4,dystopian:0,each:[5,6,11],earli:0,earn:[4,5,11],ecp:6,effect:4,either:[3,4],element:[4,5,6,8,10,11],els:[7,11],embark:0,emploi:11,employe:11,empti:[4,8],enabl:4,enablelog:[0,1],encapsul:3,end:[4,5,8,11],endpoint:8,engin:11,enough:[4,6],equal:9,equival:[3,4],error:4,especi:4,etc:[3,4,10,11],evalu:8,even:[4,6,8,9],everi:[4,6,8,11],exampl:[0,1,2,3,4,6,7,8,9,10,11],exce:6,exceed:4,except:4,exchang:[0,1],exe:[4,11],exec:[0,1],execut:[4,6,8],exist:[4,5,7],exit:[0,1],experi:[4,11],explain:8,extens:[4,11],facnam:11,faction:11,factionnam:11,factionpassiverepgain:2,factionworkexpgain:2,factionworkrepgain:2,fail:[4,11],failur:4,fairlyn:11,fals:[3,4,5,6,8,9,11],featur:1,fee:6,feel:1,field:11,fieldwork:11,file:[2,4,11],fileexist:[0,1],filenam:4,fill:4,find:4,findindex:8,fine:4,finish:11,first:[3,4,5,6,8,10,11],fisg:6,fit:11,fix:4,floor:8,follow:[2,3,4,5,7,8,11],foo1:4,foo2:4,foo3:4,foo:[4,8],foodnstuff:[4,7,8],form:[2,4],four:[5,6],fourth:[5,6],free:1,from:[4,6,8,10,11],ftpcrack:[0,1,11],full:8,fulli:3,furthermor:4,futur:[2,4],gain:[0,4,11],game:[0,2,4,6,8,10,11],gener:[4,9,10],get:[4,8,10,11],getaugmentationcost:[0,1],getaugmentationsfromfact:[0,1],getbitnodemultipli:[0,1],getcompanyrep:[0,1],getcoreupgradecost:5,getcrimech:[0,1],getfactionrep:[0,1],getgrowtim:[0,1],gethackinglevel:[0,1],gethackingmultipli:[0,1],gethacktim:[0,1],gethostnam:[0,1],getlevelupgradecost:5,getnexthacknetnodecost:[0,1],getownedaugment:[0,1],getporthandl:8,getpurchasedserv:[0,1],getramupgradecost:5,getscriptexpgain:[0,1],getscriptincom:[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],global:4,greater:9,grep:4,grow:[0,1,7],grown:7,growth:4,gym:11,gymnam:11,gymworkout:[0,1],hack:[0,1,7,11],hacker:0,hackexpgain:2,hackingcontract:11,hacknet:[0,1,4],hacknetnod:[0,1],hacknetnodemonei:2,halt:4,handl:8,has:[1,2,4,5,11],hasrootaccess:[0,1],have:[1,2,4,5,6,11],helio:4,hello:4,here:[0,3,4,6,7,8,11],higher:4,hoist:4,hold:3,home:[4,11],hope:0,hostnam:4,how:[3,4,7,8],howev:[4,7,8],httpworm:[0,1,11],hyphen:3,ident:1,identifi:4,immedi:[4,6,11],implement:[1,8],improv:1,includ:[3,4,11],incom:[4,5],increas:4,increment:[0,9],index:[0,4,5],indic:[4,11],inequ:9,inform:[0,1,4],initi:3,input:11,insid:[4,5,8],instal:[4,6,11],installaugment:[0,1],instanc:4,instead:[2,4],institut:11,instrins:4,integ:[2,3,4,5,6],intellig:11,interact:8,invalid:[4,11],invit:11,iron:11,isbusi:[0,1],ishima:11,isinteg:8,isrun:[0,1],issu:11,item:8,iter:[5,7],its:[4,6,8],itself:5,javascript:[0,1,3,4,7],job:11,joesgun:4,join:[3,11],joinfact:[0,1],jump3r:0,just:[4,8],keyword:7,kill:[0,1],killal:[0,1],know:8,label:3,languag:[1,3,4],last:[4,8],later:[2,3,6,11],lead:0,leadership:11,least:[4,5],length:[4,5,10],lenient:11,less:9,let:[6,7,8,10],letter:[3,6],level:[4,5,11],like:[4,8,10],limit:[4,6],limitbui:6,limitsel:6,line:8,link:4,list:[5,11],lit:4,literatur:4,local:4,locat:[4,11],log:[4,5,8],logic:9,look:[8,10],loop:[0,1],lose:8,lot:11,lower:4,made:6,mai:4,make:[4,10],manag:11,mani:[1,3,11],manual:11,manualhackmonei:2,map:5,market:6,math:[0,1],max:5,maximum:4,mayb:8,mean:[0,1,2,3,4,5,8,11],member:[0,1,3,11],memori:4,messag:[0,4],method:[0,1,3,8],middl:11,millenium:11,millisecond:4,minimum:4,minut:11,miscellan:[0,1],mode:4,modifi:10,modul:[0,1],modulo:9,monei:[0,2,4,5,6,7,11],moneygainratepersecond:5,more:[3,4,7],most:3,msg:4,much:7,mult:[2,4],multi:8,multipl:[4,9],multipli:[2,4,11],must:[3,4,5,6,11],mysteri:0,name:[3,4,5,6,9,10,11],nearest:[4,5,6],necessari:0,need:4,negat:9,net:6,netscript:0,netscriptport:8,network:11,newli:4,next:4,node:[0,1,4],none:[4,5],normal:[8,10,11],notabl:4,note:[4,5,11],now:[0,8],nuke:[0,1],number:[0,1,3,4,5,6,9,10],numer:[3,6,9],numthread:[4,8],object:[2,3,4,5,11],obtain:4,obvious:11,offlin:4,omit:4,one:[4,5,7,8,11],onli:[2,4,5,6,8,9,11],onlin:4,onlinetimesecond:5,onto:3,open:[4,8,11],oper:[0,1,8,10],operand:9,option:[4,11],order:[2,4,6,11],origin:2,other:[4,8,11],otherwis:[4,5,6,7,8,11],our:8,oustand:[6,11],out:[1,4,8,11],output:4,outsid:[4,11],over:4,overwrit:4,own:[0,1,6],page:[0,2,4,8,11],param:[],paramet:4,pars:8,part:11,particular:11,pass:[4,8,10,11],peek:[0,1,8],percentag:4,perform:11,place:6,placeord:[0,1],plai:0,plan:10,player:[0,4,5,6,10,11],pop:[3,8],port:[0,1,4],pos:6,posit:[3,5,6,11],possibl:10,power:[0,4],powerhous:11,pre:9,prevent:10,price:6,primit:3,print:[0,1,2,5,8,11],process:4,produc:9,profit:6,program:[1,4,11],programnam:11,promot:11,prompt:[0,1],properti:11,protocol:6,provid:[5,6],pserv:4,purchas:[4,5,6,11],purchaseaugment:[0,1],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,rais:4,ram:[4,5,11],ramus:4,ran:[4,8],rate:4,reach:1,read:[0,1,3,5,8],reason:4,receiv:[2,11],refer:[3,7],referenc:3,reflect:6,regardless:4,relat:[4,8],relaysmtp:[0,1,11],relev:2,reload:8,rememb:[4,6],remov:[4,8],repres:[2,3,4,6,8],reput:11,request:1,requir:[2,4,9,11],res:[4,8,11],reset:[4,6,11],resolv:4,rest:3,restart:11,result:[4,9],retain:6,revert:4,right:8,role:0,room:8,root:4,rothman:[4,11],round:[4,5,6],router:11,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],save:8,scan:[0,1],scienc:11,scope:4,scp:[0,1],script:[0,1,4,5,6,8,11],scripthackmonei:2,scriptkil:[0,1],scriptnam:4,scriptrun:[0,1],search:[0,4],second:[3,4,5,6,10,11],secret:0,section:[1,4],sector:11,secur:[4,11],securitywork:11,see:[4,5,7],select:4,sell:6,sellshort:[0,1],sellstock:[0,1],sensit:[4,6,11],separ:[2,4],sequenc:[3,6],serial:[4,8],server:[4,7],serverexist:[0,1],servergrowthr:2,servermaxmonei:2,serverprofil:11,serverstartingmonei:2,serverstartingsecur:2,serverweakenr:2,set:[4,11],sever:8,share:6,sharesshort:6,she:0,shortstock:[0,1],should:[4,7,11],show:[3,4,7],shown:4,signatur:4,signific:4,similar:4,simpl:[7,8],simplest:4,simpli:[1,3],simplic:8,sinc:[4,8],singl:[3,4,9],singular:[0,1],skill:4,sleep:[0,1,5,8,11],slice:8,small:11,snap:11,softwar:11,sold:6,some:[4,7,8,9,11],some_valu:4,someth:0,sort:[4,8],sourc:[2,4,11],spawn:[0,1],special:[3,5,10,11],specif:4,specifi:[4,5,6,8,10,11],speed:4,splice:3,spoiler:[2,11],sprintf:[0,1],sqlinject:[0,1,11],stage:0,stai:4,start:[3,4,8,11],stat:11,statement:7,statist:6,steal:4,still:4,stock:6,stolen:4,stop:[4,6,11],stopact:[0,1],stopbui:6,stopsel:6,store:3,str:11,strategi:6,strength:11,strict:9,string:[3,4,6,11],structur:[2,4,8],strucur:11,studi:11,subject:2,subset:1,substr:4,subtract:9,success:[4,6,11],successfulli:[4,5,6,8,11],suggest:1,sum:4,summit:11,support:[3,5,6,8],suspend:4,suspicion:0,sym:6,symbol:6,syntax:[1,4,8],system:6,take:[0,4,11],target:4,technolog:11,templat:4,ten:7,term:11,termin:[4,11],test:4,text:[3,4],than:[4,7,9],thei:[1,2,4],them:[4,8,11],theme:0,thi:[0,1,2,3,4,5,6,8,9,10,11],third:[4,6],those:[4,5],though:[4,8],thought:3,thread:[4,10,11],three:[3,4,8],through:[4,5,8,11],time:[4,5,7,8,11],tini:1,tix:[0,1],tokyo:11,tolowercas:3,tor:11,total:[4,5],totalmoneygener:5,totalram:4,tprint:[0,1,8],trade:[0,1],train:11,transact:6,travel:11,traveltoc:[0,1],travers:7,tri:[4,5],trywrit:8,two:[4,6,9,10,11],txt:4,type:[0,1,4,6,11],typic:4,unari:[0,1],uncov:0,underli:[4,8],underscor:3,uni:4,uniqu:4,univeristi:11,univers:11,universitycours:[0,1],universitynam:11,unknown:0,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],use:[4,6,7,11],used:[1,3,4,5,6,8,11],uses:7,using:[4,5,6,7,8,10,11],usual:11,utc:8,valid:[4,8],valu:[2,3,4,5,6,8,9,11],vari:4,variabl:[0,1,4,7,9],visit:[6,11],volhaven:11,vsprintf:[0,1],wai:[4,5,8,11],wait:8,waiter:11,want:[5,10,11],warn:[9,10,11],weaken:[0,1],web:11,well:3,were:[4,11],wese:6,what:[4,5,11],whatev:11,when:[0,1,4,7,8,11],where:[0,4,8],whether:[4,6,11],which:[3,4,5,6,8,11],whitespac:4,without:4,word:4,work:[4,6,8,9,11],workforcompani:[0,1],workforfact:[0,1],worktyp:11,world:[0,1,4,6],would:[2,9,10,11],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],your:[0,1,5,6,11],yourself:5,zero:4},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"],titleterms:{"function":[2,4,11],advanc:2,api:[5,6],applytocompani:11,argument:10,basic:4,binari:9,bitburn:0,brutessh:4,buystock:6,cancelord:6,checkfactioninvit:11,clear:4,clearlog:4,comment:8,commitcrim:11,condit:7,createprogram:11,data:3,date:8,defin:4,deleteserv:4,disablelog:4,document:[0,1],enablelog:4,exampl:5,exchang:6,exec:4,exit:4,fileexist:4,ftpcrack:4,getaugmentationcost:11,getaugmentationsfromfact:11,getbitnodemultipli:2,getcompanyrep:11,getcrimech:11,getfactionrep:11,getgrowtim:4,gethackinglevel:4,gethackingmultipli:4,gethacktim:4,gethostnam:4,getnexthacknetnodecost:4,getownedaugment:11,getpurchasedserv:4,getscriptexpgain:4,getscriptincom: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,hacknet:5,hacknetnod:5,handl:[],hasrootaccess:4,httpworm:4,indic:0,inform:6,installaugment:11,isbusi:11,isrun:4,javascript:8,joinfact:11,kill:4,killal:4,loop:7,math:8,member:5,method:5,miscellan:8,modul:8,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,purchaseaugment:11,purchasehacknetnod:4,purchaseprogram:11,purchaseserv:4,purchasetor:11,read:4,relaysmtp:4,round:[],run:4,scan:4,scp:4,script:10,scriptkil:4,scriptrun:4,sellshort:6,sellstock:6,serverexist:4,shortstock:6,singular:11,sleep:4,spawn:4,sprintf:4,sqlinject:4,stopact:11,tabl:0,tix:6,tprint:4,trade:6,traveltoc:11,type:3,unari:9,universitycours:11,upgradehomeram:11,usag:[],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 diff --git a/doc/source/netscriptfunctions.rst b/doc/source/netscriptfunctions.rst index 9f78c9407..3b0dd2a13 100644 --- a/doc/source/netscriptfunctions.rst +++ b/doc/source/netscriptfunctions.rst @@ -742,7 +742,7 @@ rm :param string fn: Filename of file to remove. Must include the extension :returns: True if it successfully deletes the file, and false otherwise - Removes the specified file from the current server. This function works for every file type except message (.msg) files. + Removes the specified file from the current server. This function works for every file type except message (.msg) files. scriptRunning ^^^^^^^^^^^^^ @@ -900,40 +900,34 @@ Functions should have some return value. Here is an example of defining and usin return res; } - print(sum([1, 2, 3, 4, 5])); - print(sum([1, 10])); + print(sum([1, 2, 3, 4, 5])); //Prints 15 + print(sum([1, 10])); //Prints 11 -The example above prints the following in its log:: - - 15 - 11 - -For those with experience in other languages, especially Javascript it may be important to note that function declarations are not hoisted and must be declared BEFORE you use them. +For those with experience in other languages, especially Javascript, it may be important to note that +function declarations are not hoisted and must be declared BEFORE you use them. +For example, the following will cause an error saying `variable hello not defined`:: print(hello()); - + function hello() { return "world"; } -Will cause an error saying `variable hello not defined` whereas:: - +The following will work fine:: + function hello() { return "world"; } - - print(hello()); -Will print out - - world + print(hello()); //Prints out "world" **Note about variable scope in functions:** Functions can access "global" variables declared outside of the function's scope. However, they cannot change the value of any "global" variables. -Any changes to "global" variables will only be applied locally to the function. +Any changes to "global" variables will only be applied locally to the function. -The following example shows that any change to "global" variable inside a function only applies in the function's local scope:: +The following example shows that any change to a "global" variable +from inside a function only applies in the function's local scope:: function foo() { i = 5; @@ -941,16 +935,12 @@ The following example shows that any change to "global" variable inside a functi } i = 0; - print(i); + print(i); //Prints 0 foo(); - print(i); + print(i); //Prints 0 -Results in the following log:: - - 0 - 0 - -Furthermore, this also means that any variable that is first defined inside a function will NOT be accessible outside of the function as shown in the following example:: +Furthermore, this also means that any variable that is first defined inside a +function will NOT be accessible outside of the function as shown in the following example:: function sum(values) { res = 0; @@ -970,7 +960,6 @@ results in the following runtime error:: variable res not defined - **Other Notes about creating your own functions:** Defining a function does not create a Javascript function object in the underlying game code. This means that you cannot use any function diff --git a/license.txt b/license.txt index 67271875a..91b91dde4 100644 --- a/license.txt +++ b/license.txt @@ -24,7 +24,7 @@ contains or is derived from the Software or any part thereof: (a) The distributed Software may not be used in any way for commercial gain and must not violate any of the restrictions set forth in Section 3. -(b) If you have modified the Software, you must cause cause the modified Software to carry prominent notices stating that +(b) If you have modified the Software, you must cause the modified Software to carry prominent notices stating that you have modified the Software's files. Modifications must not alter or remove any copyright notices in the Software. (c) The distributed Software must include either a written copy of this License, or a prominent written indication that the Software is covered by this License and written instructions for printing and/or displaying the copy of the License