From ffc8133fb80534de5c4c583237056cebee245796 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 18 Oct 2021 19:12:41 -0400 Subject: [PATCH] some doc --- CONTRIBUTING.md | 15 ++++++++ .../advancedfunctions/inject_html.rst | 35 +++++++++++++++++++ .../netscript/netscriptadvancedfunctions.rst | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 doc/source/netscript/advancedfunctions/inject_html.rst diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 604549106..41c22e38d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -106,6 +106,21 @@ Fork and clone the repo # Makes sure you always start from `danielyxie/dev` to avoid merge conflicts. ``` +### Running locally. + +Install + +- `npm` (maybe via `nvm`) +- Github Desktop (windows only) +- Visual Studio code (optional) + +Inside the root of the repo run +`npm install` to install all the dependencies +`npm run start:dev` to launch the game in dev mode. + +After that you can open any browser and naviguate to `localhost:8000` and play the game. +Saving a file will reload the game automatically. + #### Submitting a Pull Request When submitting a pull request with your code contributions, please abide by diff --git a/doc/source/netscript/advancedfunctions/inject_html.rst b/doc/source/netscript/advancedfunctions/inject_html.rst new file mode 100644 index 000000000..bec8bde50 --- /dev/null +++ b/doc/source/netscript/advancedfunctions/inject_html.rst @@ -0,0 +1,35 @@ +Injecting HTML in the game +========================== + +Bitburner uses React and Material-UI to render everything. Modifying the UI is possible but +not officially supported. + +To automatically enter commands in the terminal (only works if looking at the terminal): + +.. code-block:: javascript + + // Acquire a reference to the terminal text field + const terminalInput = document.getElementById("terminal-input"); + + // Set the value to the command you want to run. + terminalInput.value="home;connect n00dles;home;connect n00dles;home;"; + + // Get a reference to the React event handler. + const handler = Object.keys(terminalInput)[1]; + + // Perform an onChange event to set some internal values. + terminalInput[handler].onChange({target:terminalInput}); + + // Simulate an enter press + terminalInput[handler].onKeyDown({keyCode:13,preventDefault:()=>null}); + + +To add lines to the terminal (only works if looking at the terminal): + +.. code-block:: javascript + + // Acquire a reference to the terminal list of lines. + const list = document.getElementById("generic-react-container").querySelector("ul"); + + // Inject some HTML. + list.insertAdjacentHTML('beforeend',`
  • whatever custom html

  • `) \ No newline at end of file diff --git a/doc/source/netscript/netscriptadvancedfunctions.rst b/doc/source/netscript/netscriptadvancedfunctions.rst index b24c85eb2..31454253e 100644 --- a/doc/source/netscript/netscriptadvancedfunctions.rst +++ b/doc/source/netscript/netscriptadvancedfunctions.rst @@ -11,3 +11,5 @@ they contain spoilers for the game. getBitNodeMultipliers() getServer() autocomplete() + atExit() + Injecting HTML