update rtd a little.

This commit is contained in:
Olivier Gagnon 2021-11-03 20:27:32 -04:00
parent 14150d3e33
commit 7b950bd7d9
3 changed files with 6 additions and 144 deletions

@ -24,7 +24,6 @@ secrets that you've been searching for.
Basic Gameplay <basicgameplay> Basic Gameplay <basicgameplay>
Advanced Gameplay <advancedgameplay> Advanced Gameplay <advancedgameplay>
Keyboard Shortcuts <shortcuts> Keyboard Shortcuts <shortcuts>
Script Editors <scripteditors>
Game Frozen or Stuck? <gamefrozen> Game Frozen or Stuck? <gamefrozen>
Guides & Tips <guidesandtips> Guides & Tips <guidesandtips>
Tools & Resources <toolsandresources> Tools & Resources <toolsandresources>

@ -2,8 +2,8 @@
NetscriptJS (Netscript 2.0) NetscriptJS (Netscript 2.0)
=========================== ===========================
Netscript 2.0, or Netscript JS, is the new and improved version of Netscript that Netscript 2.0, or Netscript JS, is the improved version of Netscript that
allows users to write (almost) full-fledged Javascript code in their scripts, while allows users to write full-fledged Javascript code in their scripts, while
still being able to access the Netscript functions. still being able to access the Netscript functions.
NetscriptJS was developed primarily by `Github user jaguilar <https://github.com/jaguilar>`_ NetscriptJS was developed primarily by `Github user jaguilar <https://github.com/jaguilar>`_
@ -53,6 +53,9 @@ Here is a summary of all rules you need to follow when writing Netscript JS code
* sleep * sleep
* prompt * prompt
* wget * wget
* scp
* write
* writePort
* Any function that contains :code:`await` must be declared as :code:`async` * Any function that contains :code:`await` must be declared as :code:`async`
@ -60,7 +63,7 @@ Here is a summary of all rules you need to follow when writing Netscript JS code
* Any functions that you want to be visible from other scripts must be marked with :code:`export`. * Any functions that you want to be visible from other scripts must be marked with :code:`export`.
* **Do not write any infinite loops without using a** :code:`sleep` **or one of the timed Netscript functions like** :code:`hack`. Doing so will crash your game. * **Do not write any infinite loops without using a** :code:`sleep` **or one of the timed Netscript functions like** :code:`hack`. Doing so will freeze your game.
* Any global variable declared in a NetscriptJS script is shared between all instances of that * Any global variable declared in a NetscriptJS script is shared between all instances of that
script. For example, assume you write a script *foo.ns* and declared a global variable like so:: script. For example, assume you write a script *foo.ns* and declared a global variable like so::

@ -1,140 +0,0 @@
.. _scripteditors:
Script Editors
==============
Third-party libraries are used to implement the game's Script Editor(s). There are
currently two options for the Script Editor:
* `Ace <https://ace.c9.io/>`_
* `CodeMirror <https://codemirror.net/>`_
You can select which of the two editors you want to use on the Script Editor page
('Create Script' on the main menu).
Ace was the game's original Script Editor, while CodeMirror was added later in
v0.43.0. The two editors share many of the same features, so there is not a significant
difference between the two. Currently, CodeMirror is slightly more modern,
more customizable, and has a few quality-of-life improvements compared to Ace.
Universal Key Bindings
----------------------
These keyboard shortcuts are available in both the Ace and CodeMirror editors, regardless
of what key binding option you are using:
============= ===========================================================================
Shortcut Action
============= ===========================================================================
Ctrl + b Save script and return to :ref:`terminal`
Ctrl + space Show Autocomplete Hints
============= ===========================================================================
.. _scripteditor_linter:
Linter
------
Both script editors contain a linter, which is a tool that analyzes your
code and flags anything it thinks might be an error. You can see
warnings and errors from the linter on the left-hand side of the script editor. There
will be an icon on whatever lines the linter thinks might be problematic. Hovering
over the icon will display information on what the issue is.
Note that **just because the linter shows an error/warning, this does NOT automatically mean that**
**your script is broken and will fail to run.** This is especially true if you are using
:ref:`netscriptjs`. The linter used by the script editors isn't necessarily perfect or
up-to-date. Furthermore, the linter does not affect anything when you actually run scripts.
Ace
---
The following documents what the different settings/options do for the Ace editor,
as well as the different key binding settings. Note that the
information for the key bindings may not be completely comprehensive. You'll
have to dig into the editor source code if you want to learn more.
Settings
~~~~~~~~
===================== ===========================================================================================================
Setting Effect
===================== ===========================================================================================================
Theme Switch between different color schemes
Key Binding Switch between different key binding options. This changes what keyboard shortcuts are available
Highlight Active Line When enabled, the line on which the cursor currently resides will be highlighted.
Show Invisibles When enabled, you will be able to view hidden whitespace characters such as spaces, tabs, and newlines.
Use Soft Tab When enabled, tabs will be replaced with spaces
Max Error Count Specifies the (approximate) number of lines that will be linted
===================== ===========================================================================================================
Ace Key Bindings
~~~~~~~~~~~~~~~~
For Ace, the "Ace" Key Binding setting uses the default configuration. A list of these
`can be found here <https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts>`_.
Vim Key Bindings
~~~~~~~~~~~~~~~~
For Ace, the "Vim" Key Binding setting configures the editor to use
`Vim <https://en.wikipedia.org/wiki/Vim_(text_editor)>`_ key mappings. Note that while this tries
to emulate Vim features as faithfully as possible, it is not a complete Vim implementation.
Since I'm not familiar with Vim, I'll leave
`Ace's Vim Mode implementation here <https://github.com/ajaxorg/ace/blob/96088d0fc292daf0706b2d029cc03c3799be5974/lib/ace/keyboard/vim.js#L860>`_,
which I believe shows most of the implemented features.
Note that the following Vim Ex commands will properly save the script and/or quit the editor in game:
======= ==============================================
Command Effect
======= ==============================================
:w Save the script and return to :ref:`terminal`
:q Return to :ref:`terminal` **WITHOUT** saving
:x Save the script and return to :ref:`terminal`
:wq Save the script and return to :ref:`terminal`
======= ==============================================
Emacs Key Bindings
~~~~~~~~~~~~~~~~~~
For Ace, the "Emacs" Key Binding setting configures the editor to use
`Emacs <https://en.wikipedia.org/wiki/Emacs>`_ key mappings. Note that while this tries
to emulate the Emacs key mappings as faithfully as possible, it won't necessarily be a
complete implementation.
Since I'm not familiar with Emacs, I'll leave
`Ace's Emacs Mode implementation here <https://github.com/ajaxorg/ace/blob/96088d0fc292daf0706b2d029cc03c3799be5974/lib/ace/keyboard/emacs.js#L343>`_,
which I believe shows most of the implemented features.
CodeMirror
----------
The following documents what the different settings/options do for the CodeMirror editor,
as well as the shortcuts for the different key binding settings. Note that the
information for the key bindings may not be completely comprehensive. You'll
have to dig into the editor source code if you want to learn everything.
Settings
~~~~~~~~
========================== ===========================================================================================================
Setting Effect
========================== ===========================================================================================================
Theme Switch between different color schemes
Key Binding Switch between different key binding options. This changes what keyboard shortcuts are available
Highlight Active Line When enabled, the line on which the cursor currently resides will be highlighted.
Show Invisibles When enabled, you will be able to view hidden whitespace characters such as spaces, tabs, and newlines.
Use Soft Tab When enabled, tabs will be replaced with spaces
Auto-Close Brackets/Quotes When enabled, any opening brackets or quotes that are typed will be closed
Enable Linting Enable/Disable the :ref:`scripteditor_linter`
Continue Comments When enabled, pressing 'Enter' inside a comment block will continue the comment on the next line
========================== ===========================================================================================================
Default Key Bindings
~~~~~~~~~~~~~~~~~~~~
.. todo:: Fill out
Sublime Key Bindings
~~~~~~~~~~~~~~~~~~~~
.. todo:: Fill out
Vim Key Bindings
~~~~~~~~~~~~~~~~
.. todo:: Fill out
Emacs Key Bindings
~~~~~~~~~~~~~~~~~~
.. todo:: Fill out