Hacking API
Access the laptops functionality with the Open API.
Overview
The Hacking API allows developers to access all hacking operations within the laptop. It provides functions to create and manage hacking operations on virtual drives, alongside energy management and hardware checks.
The API is exclusively available as client side code. This may change in the future
Classes
Directory
name(string): The name of the directory or file.type('folder' | 'file' | 'executable'): The type of the directory.locked(boolean): Indicates whether this directory is locked.files(Directory[]): An array of subdirectories or files.hack('mbo' | 'linerouter' | 'ghostkey'): Specifies hack type required.onHacked(function): Function called after successful hacking.
Drive
name(string): Name of the drive.locked(boolean): Lock status of the drive.files(Directory[]): Contained directories and files.
Settings
requiredEnergy(number): Minimum energy level needed to start hacking.energyCost:success(number): Energy used on successful hack.failure(number): Energy used on failed hack.
openLaptop(boolean): Determines if the laptop should open automatically.unmountOnFail(boolean): Whether to unmount the drive after failed hack.
Accessing the API
Use the following line to access the Hacking API functions:
API Methods
Create Hack Operation
Parameters:
hack: Type of hack ('mbo', 'linerouter', 'ghostkey').drive: ADriveobject to be hacked.settings: ASettingsobject with hacking parameters.callback: Function executed after hack attempt.
Returns: A table containing:
Data: Modified drive data.Mount: Function to mount the drive. *If the settingopenLaptopis set totruethen the drive is already Mounted and this function does nothing.Cancel: Function to cancel the hack operation.
Open Laptop
Opens the hacking laptop interface if available.
Get Player Energy
Returns: Current energy level of the player.
Add Player Energy
Parameters:
amount: The amount of energy to add.
Returns: Updated energy level.
Has Laptop
Returns: Boolean indicating if the player has a laptop.
Has WiFi Transmitter
Returns: Boolean indicating if the player has a WiFi transmitter.
Notes
Ensure the main module is loaded before accessing the API.
Incorrect parameters or lack of required resources will result in errors.
Last updated