From fb87385704d1dec99c7390c6369cda64a685fd78 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Fri, 20 Aug 2021 13:33:52 -0400 Subject: [PATCH] Added function definition for netscritp in typescript --- src/ScriptEditor/NetscriptDefinitions.ts | 144 +++++++++++++++++++++++ src/ScriptEditor/ui/Root.tsx | 1 + 2 files changed, 145 insertions(+) create mode 100644 src/ScriptEditor/NetscriptDefinitions.ts diff --git a/src/ScriptEditor/NetscriptDefinitions.ts b/src/ScriptEditor/NetscriptDefinitions.ts new file mode 100644 index 000000000..ea74d4311 --- /dev/null +++ b/src/ScriptEditor/NetscriptDefinitions.ts @@ -0,0 +1,144 @@ +export declare function scan(ip: string, hostnames: boolean): string[]; +export declare function hack(ip: string, threads: number, stock: boolean): Promise; +export declare function hackAnalyzeThreads(ip: string, hackAmount: number): number; +export declare function hackAnalyzePercent(ip: string): number; +export declare function hackChance(ip: string): number; +export declare function sleep(time: number): Promise; +export declare function grow(ip: string, threads: number, stock: boolean): Promise; +export declare function growthAnalyze(ip: string, growth: number): number; +export declare function weaken(ip: string, threads: boolean): Promise; +export declare function print(): void; +export declare function tprint(): void; +export declare function clearLog(): void; +export declare function disableLog(fn: string): void; +export declare function enableLog(fn: string): void; +export declare function isLogEnabled(fn: string): boolean; +export declare function getScriptLogs(fn: string, ip: string, ...scriptArgs: any[]): string[]; +export declare function tail(fn: string, ip: string, ...scriptArgs: any[]): void; +export declare function nuke(ip: string): boolean; +export declare function brutessh(ip: string): boolean; +export declare function ftpcrack(ip: string): boolean; +export declare function relaysmtp(ip: string): boolean; +export declare function httpworm(ip: string): boolean; +export declare function sqlinject(ip: string): boolean; +export declare function run(scriptname: string, threads: number): number; +export declare function exec(scriptname: string, ip: string, threads: number): number; +export declare function spawn(scriptname: string, threads: number): void; +export declare function kill(filename: string, ip: string, ...scriptArgs: any[]): boolean; +export declare function killall(ip: string): boolean; +export declare function exit(): void; +export declare function scp(scriptname: string, ip1: string, ip2: string): boolean; +export declare function ls(ip: string, grep: string): string[]; +export declare function ps(ip: string): {filename: string, threads: number, args: string[], pid: number}[]; +export declare function hasRootAccess(ip: string): boolean; +export declare function getIp(): string; +export declare function getHostname(): string; +export declare function getHackingLevel(): number; +export declare function getHackingMultipliers(): number; +export declare function getHacknetMultipliers(): number; +export declare function getBitNodeMultipliers(): number; +export declare function getServer(ip: string): any; +export declare function getServerMoneyAvailable(ip: string): number; +export declare function getServerSecurityLevel(ip: string): number; +export declare function getServerBaseSecurityLevel(ip: string): number; +export declare function getServerMinSecurityLevel(ip: string): number; +export declare function getServerRequiredHackingLevel(ip: string): number; +export declare function getServerMaxMoney(ip: string): number; +export declare function getServerGrowth(ip: string): number; +export declare function getServerNumPortsRequired(ip: string): number; +export declare function getServerRam(ip: string): number[]; +export declare function getServerMaxRam(ip: string): number; +export declare function getServerUsedRam(ip: string): number; +export declare function serverExists(ip: string): boolean; +export declare function fileExists(filename: string, ip: string): boolean; +export declare function isRunning(fn: string, ip: string, ...scriptArgs: any[]): boolean; +export declare function getStockSymbols(): string[]; +export declare function getStockPrice(symbol: string): number; +export declare function getStockAskPrice(symbol: string): number; +export declare function getStockBidPrice(symbol: string): number; +export declare function getStockPosition(symbol: string): number; +export declare function getStockMaxShares(symbol: string): number; +export declare function getStockPurchaseCost(symbol: string, shares: number, posType: string): number; +export declare function getStockSaleGain(symbol: string, shares: number, posType: string): number; +export declare function buyStock(symbol: string, shares: number): number; +export declare function sellStock(symbol: string, shares: number): number; +export declare function shortStock(symbol: string, shares: number): number; +export declare function sellShort(symbol: string, shares: number): number; +export declare function placeOrder(symbol: string, shares: number, price: number, type: string, pos: string): boolean; +export declare function cancelOrder(symbol: string, shares: number, price: number, type: string, pos: string): boolean; +export declare function getOrders(): any; +export declare function getStockVolatility(symbol: string): number; +export declare function getStockForecast(symbol: string): number; +export declare function getPurchasedServerLimit(): number; +export declare function getPurchasedServerMaxRam(): number; +export declare function getPurchasedServerCost(ram: number): number; +export declare function purchaseServer(hostname: string, ram: number): string; +export declare function deleteServer(hostname: string): boolean; +export declare function getPurchasedServers(hostname: string): string[]; +export declare function write(port: number, data: string, mode: string): boolean; +export declare function tryWrite(port: number, data: string): boolean; +export declare function read(port: number): any; +export declare function peek(port: number): any; +export declare function clear(port: number): number; +export declare function getPortHandle(port: number): any; // netscript port +export declare function rm(fn: string, ip: string): boolean; +export declare function scriptRunning(scriptname: string, ip: string): boolean; +export declare function scriptKill(scriptname: string, ip: string): boolean; +export declare function getScriptName(): string; +export declare function getScriptRam(scriptname: string, ip: string): number; +export declare function getRunningScript(fn: string, ip: string): any; // running script +export declare function getHackTime(ip: string): number; +export declare function getGrowTime(ip: string): number; +export declare function getWeakenTime(ip: string): number; +export declare function getScriptIncome(scriptname: string, ip: string): number; +export declare function getScriptExpGain(scriptname: string, ip: string): number; +export declare function nFormat(n: number, format: string): string; +export declare function tFormat(milliseconds: number, milliPrecision: boolean): string; +export declare function getTimeSinceLastAug(): number; +export declare function prompt(txt: string): Promise; +export declare function getFavorToDonate(): number; +export declare function universityCourse(universityName: string, className: string): boolean; +export declare function gymWorkout(gymName: string, stat: string): boolean; +export declare function travelToCity(cityname: string): boolean; +export declare function purchaseTor(): boolean; +export declare function purchaseProgram(programName: string): boolean; +export declare function getCurrentServer(): any; // server object +export declare function connect(hostname: string): boolean; +export declare function manualHack(): Promise; +export declare function installBackdoor(): Promise; +export declare function getStats(): any; // complex type +export declare function getCharacterInformation(): any; // complex type +export declare function getPlayer(): any; // complex type +export declare function hospitalize(): number; +export declare function isBusy(): boolean; +export declare function stopAction(): boolean; +export declare function upgradeHomeRam(): number; +export declare function getUpgradeHomeRamCost(): number; +export declare function workForCompany(companyName: string): boolean; +export declare function applyToCompany(companyName: string, field: string): boolean; +export declare function getCompanyRep(companyName: string): number; +export declare function getCompanyFavor(companyName: string): number; +export declare function getCompanyFavorGain(companyName: string): number; +export declare function checkFactionInvitations(): string[]; +export declare function joinFaction(name: string): boolean; +export declare function workForFaction(name: string, type: string): boolean; +export declare function getFactionRep(name: string): number; +export declare function getFactionFavor(name: string): number; +export declare function getFactionFavorGain(name: string): number; +export declare function donateToFaction(name: string, amt: number): boolean; +export declare function createProgram(name: string): boolean; +export declare function commitCrime(crimeRoughName: string): number; +export declare function getCrimeChance(crimeRoughName: string): boolean; +export declare function getCrimeStats(crimeRoughName: string): any; // complex type +export declare function getOwnedAugmentations(purchased: boolean): string[]; +export declare function getOwnedSourceFiles(): any; // complex type +export declare function getAugmentationsFromFaction(facname: string): string[]; +export declare function getAugmentationPrereq(name: string): string[]; +export declare function getAugmentationCost(name: string): number; +export declare function getAugmentationStats(name: string): any; // complex type +export declare function purchaseAugmentation(faction: string, name: string): boolean; +export declare function softReset(cbScript: string): void; +export declare function installAugmentations(cbScript: string): void; +export declare function exploit(): void; +export declare function bypass(doc: any): void; +export declare function flags(data: any): any; \ No newline at end of file diff --git a/src/ScriptEditor/ui/Root.tsx b/src/ScriptEditor/ui/Root.tsx index cb4ca4cba..114d18ddc 100644 --- a/src/ScriptEditor/ui/Root.tsx +++ b/src/ScriptEditor/ui/Root.tsx @@ -19,6 +19,7 @@ import { calculateRamUsage } from "../../Script/RamCalculations"; import { RamCalculationErrorCode } from "../../Script/RamCalculationErrorCodes"; import { numeralWrapper } from "../../ui/numeralFormat"; import { CursorPositions } from "../../ScriptEditor/CursorPositions"; +import * as NetscriptDefinitions from "../NetscriptDefinitions"; interface IProps { filename: string;