Commit Graph

160 Commits

Author SHA1 Message Date
catloversg 90cb8a9551 MISC: Add proper type check to AST walking code (#1757) 2024-11-09 15:34:46 -08:00
catloversg 36c143b687 CODEBASE: Fix lint errors 2 (#1756) 2024-11-06 23:09:11 -08:00
catloversg f6502dd490 CODEBASE: Fix lint errors 1 (#1732) 2024-11-03 22:35:14 -08:00
G4mingJon4s 651b17739c NETSCRIPT: Add ns.self() as a free info function (#1636)
* added utility info

* moved info to running script

* fix for RAM cost

* description changes

Co-authored-by: David Walker <d0sboots@gmail.com>

* fixed wrong formatting

* Added parent to ignored fields

---------

Co-authored-by: David Walker <d0sboots@gmail.com>
2024-09-07 17:34:24 -07:00
David Walker 5b2a4eafcb MISC: Improve several things relating to PID lookups (#1594)
findRunningScriptByPid needlessly took a "server" argument. This caused
there to be a "getRunningScriptByPid" version that did *not*, and it was
looping through all servers in order to function, which is needlessly
inefficient.

By removing the parameter and the needless inefficient helper method,
the following changes:
- Many Netscript functions such as isRunning() and getScript() become faster.
- The terminal "tail" command now works by pid regardless of the current
  server. Note that "kill" already worked this way.

I also improved the docs around "tail", since the pid argument wasn't
in the help.
2024-08-17 14:03:00 -07:00
catloversg a9cb46606c DOCUMENTATION: Update documentation of Corporation API (#1587) 2024-08-16 02:02:23 -07:00
catloversg 864613c616 MISC: Support JSX, TS, TSX script files (#1216) 2024-07-14 14:47:10 -07:00
David Walker 1f2e69631e EDITOR: Use ramOverride() to set compiled script RAM (#1446)
To use this, add a line like "ns.ramOverride(2);" as the first statement
in main(). Not only will it take effect at runtime, but it will now
*also* be parsed at compile time, changing the script's static RAM
limit. Since ns.ramOverride is a 0-cost function, the call to it on
startup then becomes a no-op.

This is an often-requested feature, and allows for scripts to set their
usage without it needing to be explicitly mentioned via args or options
when being launched. This also reduces pressure on the static RAM
analysis to be perfect all the time. (But certain limits, such as
"functions names must be unique across namespaces," remain.)

This also adds a tooltip to the RAM calculation, to make this slightly
discoverable.
2024-07-05 17:32:46 -07:00
catloversg 304a918cc9 BUGFIX: Fix negative elapsed time (#1354) 2024-06-05 18:11:59 -07:00
Caldwell f40d4f8e92 BUGFIX: fix relative imports (#1305)
Relative paths work in imports, at last.
2024-06-02 17:38:01 -07:00
G4mingJon4s 08eb60d21b EDITOR: Improved infinite loop checking (#1276) 2024-05-23 00:44:15 -07:00
David Walker 384d1c1a2b NETSCRIPT: A minorly breaking change around script launch, and refactoring. (#1213) 2024-04-23 20:21:05 -04:00
catloversg 7b993f3550 MISC: Remove file-saver (#1217)
Also refactor to dedup our own download code
2024-04-19 13:38:44 -07:00
Caldwell 8c8af38a3a MISC: refactor weaken effect calculation (#1076)
so far we calculate the effect of weaken in three +1 places
ns.weaken
ns.weakenAnalyze
terminal weaken

and server.weaken where the bn mult is applied

i extracted the logic into a new netscript helper function getWeakenEffect
this gives us one place if we want to change the formula

a side effect i added the server.cpuCores to the terminal weaken to future proof it if the npc server core pr (#963) is merged
2024-02-16 17:18:16 -08:00
Caldwell 84c4dba1e2 UI: fix scripts recorded offline income (#1025) 2024-02-10 07:24:55 -05:00
Caldwell 4d551915b3 MISC: move server constants into their own constant (#1075) 2024-02-10 04:13:42 -05:00
alutman 445c0c3134 Offline hacking income now shown for scripts (#873) 2023-10-23 05:00:16 -04:00
G4mingJon4s 6bd5ce38d5 Fixed ram evaluation to include more edge-cases (#665) 2023-07-11 14:09:23 -04:00
G4mingJon4s e4d3a9020e Fix static ram calculation when exports are renamed (#664) 2023-07-09 08:08:43 -04:00
Aleksei Bezrodnov 08e3afd125 FIX: show ram calculation error reason to player (#627) 2023-06-19 03:49:32 -04:00
Snarling 6732549196 ENUMS: Initial Enum Helper rework + Reorganization (#596) 2023-06-12 00:34:20 -04:00
David Walker 0d6015104e BUGFIX: Proper default title for loaded RunningScripts (#557) 2023-06-01 06:42:55 -04:00
omuretsu ae8f26f03b More hotfix
* Fix empty solution for all valid math expressions
2023-05-28 05:25:44 -04:00
David Walker 4503da6226 UI: LogBox overhaul (#508) 2023-05-26 08:07:37 -04:00
omuretsu 00522fb8f3 Fix infinite loop detection
Also debounce it with the ram calc to improve performance
2023-05-16 11:27:11 -04:00
Snarling ebae35b1fb CODEBASE: Expand lint rules, and Aliases are stored as maps (#501) 2023-05-05 03:55:59 -04:00
omuretsu 3c996a47ea Fully remove formatCode function (trim on script save) 2023-05-03 07:21:23 -04:00
David Walker ad5a1c4bac NETSCRIPT: Revert FormattedCode type (#500) 2023-05-03 07:13:35 -04:00
David Walker aa7facd4ba NETSCRIPT: Greatly speed up script launching, and remove the limitation unique args per script (#440)
* Remove the limitation unique args per script
* Internal changes to how runningScripts are stored on the server, to make common usage faster.
2023-04-27 18:21:06 -04:00
Snarling e0272ad4af FILES: Path rework & typesafety (#479)
* Added new types for various file paths, all in the Paths folder.
* TypeSafety and other helper functions related to these types
* Added basic globbing support with * and ?. Currently only implemented for Script/Text, on nano and download terminal commands
* Enforcing the new types throughout the codebase, plus whatever rewrites happened along the way
* Server.textFiles is now a map
* TextFile no longer uses a fn property, now it is filename
* Added a shared ContentFile interface for shared functionality between TextFile and Script.
* related to ContentFile change above, the player is now allowed to move a text file to a script file and vice versa.
* File paths no longer conditionally start with slashes, and all directory names other than root have ending slashes. The player is still able to provide paths starting with / but this now indicates that the player is specifying an absolute path instead of one relative to root.
* Singularized the MessageFilename and LiteratureName enums
* Because they now only accept correct types, server.writeToXFile functions now always succeed (the only reasons they could fail before were invalid filepath).
* Fix several issues with tab completion, which included pretty much a complete rewrite
* Changed the autocomplete display options so there's less chance it clips outside the display area.
* Turned CompletedProgramName into an enum.
* Got rid of programsMetadata, and programs and DarkWebItems are now initialized immediately instead of relying on initializers called from the engine.
* For any executable (program, cct, or script file) pathing can be used directly to execute without using the run command (previously the command had to start with ./ and it wasn't actually using pathing).
2023-04-24 10:26:57 -04:00
Snarling 0df984eea0 CODEBASE: Add Jsonable Map and Set types, move player.sourceFiles to a map (#473) 2023-04-18 03:19:45 -04:00
David Walker ed9e6d5ea3 NETSCRIPT: Compiled modules will be even more shared (#468) 2023-04-07 21:08:39 -04:00
Snarling 04d49e3a6d SCRIPTS: Script modules are reused when they are imported (#461)
Also corrects some compile race conditions.
2023-04-07 00:33:51 -04:00
David Walker 98f7f473b4 NETSCRIPT: Add "temporary" as a RunOption to run/exec/spawn (#432) 2023-03-21 18:54:49 -04:00
Snarling 759f86d6e5 NETSCRIPT: Rework script ram updates (#408) 2023-03-05 22:39:42 -05:00
Snarling b4074328ec UI: Added new locale-aware and configurable number formatting (#354) 2023-02-11 13:18:50 -05:00
David Walker 4eef9eec03 NETSCRIPT: More ns Proxy changes (#297) 2023-01-05 20:41:24 -05:00
David Walker 7b5080a42b NETSCRIPT: Add undocumented function printRaw() (#277)
This is analagous to tprintRaw (enabled by ns.iKnowWhatImDoing()), but
for logs instead of the terminal. This provides a supported* method of
creating complicated UIs for scripts.

*No actual support, expressed or implied, is provided for use of this
function.
2023-01-05 20:30:34 -05:00
Snarling fb1f95c26e VARIOUS: Various changes prior to release 2.2 (#271)
See PR #271 description
2022-12-29 20:28:53 -05:00
omuretsu 1dec0d00bd Add documentation for ns.pid 2022-12-13 09:09:12 -05:00
Snarling b275f88053 NETSCRIPT: Expose more enums for player use (#198)
* Add support for enums at other ns layers
* APIWrapper: simplified wrapping algorithm and modified to just use cloneDeep to copy enums instead of recursively wrapping enums as if they were new API layers
* Improve APIWrapper typing
* Changed some typings at RamCostGenerator to allow for enums at different levels without enums needing a ram cost
* Added enums to ns.corporation, removed getter functions that were being used instead.
* Add FactionWorkType for player use
* Add ClassType and CompanyWorkPos enums
* Change netscriptDefinitions to expect members of these new enums where appropriate.
2022-11-09 13:46:21 -05:00
Olivier Gagnon cbb7f58231 Make the main player object an alias, makes it easier to import 2022-10-09 18:42:14 -04:00
Olivier Gagnon 5d4b72e1d1 Added some purchased server functions 2022-10-09 02:32:13 -04:00
Olivier Gagnon f6f023eeb4 Fix tons of typos 2022-10-09 01:25:31 -04:00
Snarling aa80cf6451 See description
Reverted ToastVariant back to an enum internally. Still exposed to player as just possible strings.
Changed all 1-line documentation comments to actually be 1-line. Moved some because they were not providing documentation for the thing they were trying to.
2022-10-04 06:40:10 -04:00
Snarling 50f14b4f58 Commit1 2022-10-03 12:12:16 -04:00
Snarling 21a2d49de7 Finish removing player passing 2022-09-27 15:35:41 -04:00
Snarling 572c68738f Unify error handling 2022-09-27 15:34:47 -04:00
Snarling 5798c4c7d3 Unify error handling 2022-09-27 15:32:09 -04:00
Snarling 445e365959 debounce updateRAM 2022-08-23 16:38:30 -04:00