Skip to content

Commit e311800

Browse files
authored
BREAKING CHANGE: support Lua scripting (#307)
* lua * lua types * lua types * lua types * lua types * organize files * create files * lua types * more lua types and an actual bug fix * files * finish lua types? (for now) * metadata * license * nil dir * doc * user agent * run examples * user agent * files * bindings * clippy * flags * rename fn * lua state * commands * reuse `is_script` * avoid clone * fix eval regex * stdout * heterogeneous try blocks * cheat_get_players * cheat_get_player * links * `NIL_DIR` env var * chat history * limit size * devtools * rename database crate * deps * scripts scene * fonts * deps * if let guard is now stable * world id * separator * deps * radius * settings footer * remove stdout * fonts * readme * stdio messages * remove helper * terminal * `Round::started_at` * change order * don't disable * rename * splice * chat input * queue chat messages * spinner * line class * settings * strum * update tauri-store * reactive and spinner * spinner * load scripts * sort by name * useScripts * table * wrap-anywhere * https * scripts scenes * path * return round * preserve order * tap
1 parent 2d7e8d0 commit e311800

File tree

465 files changed

+9878
-1806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

465 files changed

+9878
-1806
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ rustflags = []
44

55
[env]
66
CARGO_TARGET_DIR = "target"
7+
8+
# Relative to the home dir.
9+
NIL_DIR = ".tsukilabs/nil"

.github/CONTRIBUTING.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,47 @@ To install Diesel, run:
1313
cargo install diesel_cli --no-default-features --features "sqlite-bundled"
1414
```
1515

16+
> [!NOTE]
17+
> The truth is you don’t really need to install Diesel unless you want to work with the [server database](/crates/nil-server-database).
18+
1619
If you also want to work on the Android version, you’ll need to go through some additional steps. The [official Tauri guide](https://v2.tauri.app/start/prerequisites/#android) should help you with that.
1720

21+
## Creating a server endpoint
22+
23+
When you add a new endpoint, there are a few places you need to update. Right now this is entirely manual, but we might be able to automate at least part of it in the future ~~(I hope)~~. Use what already exists as a reference for how the new one should look.
24+
25+
Here’s a simplified list of the steps you’ll need to take. In some cases, you can skip a few of them, for example, most of them won't need a response struct at all.
26+
27+
- [`nil-payload`](/crates/nil-payload)
28+
- [Create request and response structs](/crates/nil-payload/src/lib.rs)
29+
30+
- [`nil-server`](/crates/nil-server)
31+
- [Create a handler](/crates/nil-server/src/router/mod.rs)
32+
- [Register it as a new route](/crates/nil-server/src/router/mod.rs)
33+
34+
- [`nil-client`](/crates/nil-client)
35+
- [Update the client](/crates/nil-client/src/client/mod.rs)
36+
37+
- [`nil`](/app)
38+
- [Create a new command (Rust)](/app/src-tauri/src/command/mod.rs)
39+
- [Expose it to the frontend](/app/src-tauri/src/lib.rs)
40+
- [Create a new command (TypeScript)](/app/src/commands/index.ts)
41+
- [Declare an interface for the request struct](/app/src/lib/request)
42+
- [Declare an interface for the response struct](/app/src/lib/response)
43+
44+
- [`nil-lua`](/crates/nil-lua)
45+
- [Expose it to Lua](/crates/nil-lua/src/client/mod.rs)
46+
- [Declare Lua types](/crates/nil-lua/types)
47+
- [Client](/crates/nil-lua/types/script/client/index.d.lua)
48+
- [Request](/crates/nil-lua/types/request)
49+
- [Response](/crates/nil-lua/types/response)
50+
1851
## Environment variables
1952

20-
- `NIL_DATABASE_URL`
21-
- `NIL_JWT_SECRET`
22-
- `NIL_LOG_DIR`
23-
- `NIL_LOG_TOWER_HTTP`
24-
- `NIL_MINIFY_SOURCE`
25-
- `NIL_REMOTE_SERVER_ADDR`
53+
- [`NIL_DATABASE_URL`](/crates/nil-server/src/main.rs)
54+
- [`NIL_DIR`](/app/src-tauri/src/manager.rs)
55+
- [`NIL_JWT_SECRET`](/crates/nil-server/src/middleware/authorization.rs)
56+
- [`NIL_LOG_DIR`](/crates/nil-log/src/lib.rs)
57+
- [`NIL_LOG_TOWER_HTTP`](/crates/nil-log/src/lib.rs)
58+
- [`NIL_MINIFY_SOURCE`](/app/vite.config.ts)
59+
- [`NIL_REMOTE_SERVER_ADDR`](/crates/nil-client/src/server.rs)

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
include:
16-
- platform: ubuntu-22.04
16+
- platform: ubuntu-24.04
1717
args: ""
1818
- platform: windows-latest
1919
args: ""
@@ -31,7 +31,7 @@ jobs:
3131
uses: dtolnay/rust-toolchain@nightly
3232

3333
- name: Install dependencies (Ubuntu)
34-
if: matrix.platform == 'ubuntu-22.04'
34+
if: matrix.platform == 'ubuntu-24.04'
3535
run: |
3636
sudo apt-get update
3737
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
@@ -62,7 +62,7 @@ jobs:
6262

6363
release-server:
6464
needs: release-client
65-
runs-on: ubuntu-22.04
65+
runs-on: ubuntu-24.04
6666
permissions:
6767
contents: write
6868
steps:

.taurignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
**/android
2+
**/nil-lua/examples
3+
**/nil-lua/types

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"[lua]": {
3+
"editor.defaultFormatter": "sumneko.lua"
4+
},
25
"[rust]": {
36
"editor.defaultFormatter": "rust-lang.rust-analyzer"
47
},
@@ -23,6 +26,7 @@
2326
},
2427
"files.eol": "\n",
2528
"githubPullRequests.defaultMergeMethod": "squash",
29+
"Lua.workspace.library": ["crates/nil-lua/types"],
2630
"rust-analyzer.cargo.targetDir": true,
2731
"rust-analyzer.linkedProjects": [
2832
"./Cargo.toml",
@@ -31,6 +35,7 @@
3135
"./scripts/build-server.rs",
3236
"./scripts/clean.rs",
3337
"./scripts/run-clippy.rs",
38+
"./scripts/run-example.rs",
3439
"./scripts/sort-namegen.rs",
3540
"./scripts/start-dev.rs",
3641
"./scripts/start-server.rs",

.zed/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"./scripts/build-wasm.rs",
1515
"./scripts/clean.rs",
1616
"./scripts/run-clippy.rs",
17+
"./scripts/run-example.rs",
1718
"./scripts/sort-namegen.rs",
1819
"./scripts/start-dev.rs",
1920
"./scripts/start-server.rs",

0 commit comments

Comments
 (0)