mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
renameServer changes
* Update doc error, regenerate docs * Update a bad error message in renamePurchasedServer@serverPurchases.ts * restore true/false return (removed in #450 due to miscommunication)
This commit is contained in:
parent
eb8bcd00e3
commit
798da75d83
@ -23,9 +23,9 @@ renamePurchasedServer(hostname: string, newName: string): boolean;
|
|||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
||||||
True if the upgrade succeeded, and false otherwise.
|
True if successful, and false otherwise.
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
|
||||||
RAM cost: 2.00 GB
|
RAM cost: 0 GB
|
||||||
|
|
||||||
|
@ -1270,7 +1270,13 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
renamePurchasedServer: (ctx) => (_hostname, _newName) => {
|
renamePurchasedServer: (ctx) => (_hostname, _newName) => {
|
||||||
const hostname = helpers.string(ctx, "hostname", _hostname);
|
const hostname = helpers.string(ctx, "hostname", _hostname);
|
||||||
const newName = helpers.string(ctx, "newName", _newName);
|
const newName = helpers.string(ctx, "newName", _newName);
|
||||||
renamePurchasedServer(hostname, newName);
|
try {
|
||||||
|
renamePurchasedServer(hostname, newName);
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
helpers.log(ctx, () => String(err));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteServer: (ctx) => (_name) => {
|
deleteServer: (ctx) => (_name) => {
|
||||||
|
3
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
3
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -6086,8 +6086,9 @@ export interface NS {
|
|||||||
*
|
*
|
||||||
* @param hostname - Current server hostname.
|
* @param hostname - Current server hostname.
|
||||||
* @param newName - New server hostname.
|
* @param newName - New server hostname.
|
||||||
|
* @returns True if successful, and false otherwise.
|
||||||
*/
|
*/
|
||||||
renamePurchasedServer(hostname: string, newName: string): void;
|
renamePurchasedServer(hostname: string, newName: string): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a purchased server.
|
* Delete a purchased server.
|
||||||
|
@ -61,7 +61,7 @@ export const upgradePurchasedServer = (hostname: string, ram: number): void => {
|
|||||||
|
|
||||||
export const renamePurchasedServer = (hostname: string, newName: string): void => {
|
export const renamePurchasedServer = (hostname: string, newName: string): void => {
|
||||||
const server = GetServer(hostname);
|
const server = GetServer(hostname);
|
||||||
if (!server) throw new Error(`Server '${newName}' doesn't exists.`);
|
if (!server) throw new Error(`Server '${hostname}' doesn't exists.`);
|
||||||
if (GetServer(newName)) throw new Error(`Server '${newName}' already exists.`);
|
if (GetServer(newName)) throw new Error(`Server '${newName}' already exists.`);
|
||||||
if (!Player.purchasedServers.includes(hostname)) throw new Error(`Server '${hostname}' is not a player server.`);
|
if (!Player.purchasedServers.includes(hostname)) throw new Error(`Server '${hostname}' is not a player server.`);
|
||||||
const replace = (arr: string[], old: string, next: string): string[] => {
|
const replace = (arr: string[], old: string, next: string): string[] => {
|
||||||
|
Loading…
Reference in New Issue
Block a user