├── .github
└── FUNDING.yml
├── .gitignore
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── package.json
├── patches
└── typescript.patch
├── pnpm-lock.yaml
├── src
├── lib
│ ├── isRecord.ts
│ └── isScriptor.ts
└── scripts
│ ├── js_example.js
│ ├── my_user
│ └── example.js
│ ├── ts_example.ts
│ └── ts_template.ts
└── tsconfig.json
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [ samualtnorman ] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: samualn # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12 | polar: # Replace with a single Polar username
13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | player.d.ts
3 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "javascript.validate.enable": true,
3 | "typescript.validate.enable": true,
4 | "typescript.tsdk": "node_modules/typescript/lib",
5 | "files.exclude": {
6 | "node_modules": true,
7 | "package-lock.json": true,
8 | "patches": true,
9 | "LICENSE": true,
10 | "player.d.ts": true
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Samual Norman
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Hackmud Scripting Environment
2 | This is for the game [hackmud](https://hackmud.com/). If you don't know what that is, you should go away and play it!
3 |
4 | This is the whole kitchen sink built around HSM, setting this up takes more effort but will give you autocompletes in your IDE, automatic script pushing when you save a script, as well as minification. If you only need minification, I instead recommend heading over to [Hackmud Script Manager](https://github.com/samualtnorman/hackmud-script-manager#readme).
5 |
6 | Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
7 |
8 | [](https://ko-fi.com/R6R0XN5CX)
9 |
10 | ## Features
11 | ### Minification
12 | This is the main feature of this project and works with JavaScript or [TypeScript](https://www.typescriptlang.org/). All
13 | scripts are automatically minified before being written into the hackmud folder. This means you can focus less on
14 | getting your character count down, and more on writing readable scripts.
15 |
16 | ### Autocompletes/Intellisense
17 | In modern editors like [Visual Studio Code](https://code.visualstudio.com/), as you're typing the names of subscripts or
18 | filling the args of subscripts, drop-down menus of relevant autocompletes will appear. Hovering over a script also tells
19 | you info like its security level.
20 |
21 | ### TypeScript Support
22 | Using TypeScript in this environment is completely optional, but using it means warnings when you use the wrong type in
23 | a subscript's args or use an unsupported type in a DB query.
24 |
25 | ## First Time Setup
26 | 1. Install [Node.JS](https://nodejs.org/en/download) and [PNPM](https://pnpm.io/installation)
27 | 2. Download this template:
28 | - If you have [Git installed](https://git-scm.com/downloads), make a new folder, `cd` to it, and run `pnpm dlx tiged samualtnorman/hackmud-environment`
29 | - Otherwise, [click here to download the ZIP](https://github.com/samualtnorman/hackmud-environment/archive/refs/heads/main.zip) and extract it somewhere, then `cd` to it
30 | 4. Run `pnpm install`
31 |
32 | Once you have everything setup, you just need to open the folder in your editor of choice.
33 |
34 | > [!IMPORTANT]
35 | > Do not put this template in your hackmud folder. This will not work.
Instead put this template somewhere you have easy access to like your desktop or home folder.
36 |
37 | > [!NOTE]
38 | > If you get an error message that looks like this:
39 | > ```
40 | > [...]\AppData\Local\pnpm\hsm.ps1 cannot be loaded because running scripts is disabled on this system. [...]
41 | > ```
42 | > You will need to run `Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser` in PowerShell as an administrator. For more information, see [Microsoft's page about Execution Policies](https://learn.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4).
43 |
44 | ## Guide
45 | ### Writing scripts
46 | You can create scripts in the `src/scripts` directory directly, and you can create a folder with the name of one of your users,
47 | and create scripts in that folder too.
48 |
49 | #### Alternative Preprocessor Format
50 | To get autocompletes, you'll need to replace the `#` characters with `$` characters. For example instead of writing `#fs.scripts.trust()`, you'll need to write
51 | `$fs.scripts.trust()`.
52 |
53 | #### Autocompletes for Your Own Scripts
54 | To get autocompletes for the other scripts you've written in the environment, instead of starting your scripts with
55 | `function (...`, start them with `export default function(...`.
56 |
57 | > [!NOTE]
58 | > When using this format, to get autocompletes working in hackmud, you must have a `// @autocomplete foo: "bar"` comment at the top above all other code.
59 |
60 | ### Pushing Your Scripts
61 | Use `pnpm push` to push all your scripts to all your users.
62 | To automatically push scripts as you edit them, leave `pnpm dev` running.
63 |
64 | Scripts directly in the `src/scripts` folder are pushed to all your users.
65 | To have a script be pushed to only a specific user, create a folder in the `src/scripts` folder and create your scripts in that
66 | new folder.
67 |
68 | Once a script has been pushed to a user, you can run `#up