Skip to content

Commit 36e6103

Browse files
committed
lua/community: source index from in-repo community-lua-scripts/ directory
Previously the community Lua index was fetched from a separate (and non-existent) openforge/openforge-lua-scripts repo. Move it into a community-lua-scripts/ subdirectory of this repo so contributing a script is a single PR against the same codebase rather than a separate project to maintain. - Backend lua/community.rs: INDEX_URL_TEMPLATE and default_script_url now point at satyajiit/openforge-aio/community-lua-scripts/<gameId>/. - Frontend lua-scripts-tab.tsx: COMMUNITY_REPO_URL now opens the community-lua-scripts/ directory in this repo (tree/main view). - README.md: Lua scripts section updated to reflect the in-repo layout. - New community-lua-scripts/ directory with a contributor README (layout, index.json schema, contribution rules, local-testing instructions) plus an empty batman-lod/index.json placeholder so the fetcher sees a valid (empty) listing on day one.
1 parent 450fc81 commit 36e6103

5 files changed

Lines changed: 89 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Every game has a **Lua Scripts** tab with two columns: your own scripts on the l
197197

198198
- **In-app editor** — Monaco-powered, syntax highlighting, parse-time validation pills that tell you the moment a script stops being valid Lua.
199199
- **Per-game storage** — user scripts live under your local app-data dir, scoped by game id. No cloud, no telemetry, no sync.
200-
- **Community index** — browse scripts from the [openforge-lua-scripts](https://github.com/openforge/openforge-lua-scripts) repo, install them locally with one click. Anyone can PR a script to the index.
200+
- **Community index** — browse scripts from the [`community-lua-scripts/`](community-lua-scripts/) directory in this repo, install them locally with one click. Drop a `.lua` file + index entry into `community-lua-scripts/<game-id>/` and open a PR — no separate repo to track.
201201
- **Save, validate, share** — the Phase A surface (the editor + the index) is shipping now. The Phase B runtime — actually running scripts against a live game, with the same UE5 reflection bindings the declarative engine uses — is the next milestone.
202202

203203
Until the runtime is wired, **Run** is disabled and authoring is the loop. Worth opening if you want to draft cheats that the declarative TOML engine can't express yet.

community-lua-scripts/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Community Lua Scripts
2+
3+
This directory holds **community-contributed Lua scripts** for every game OpenForge supports. The OpenForge desktop app fetches each game's `index.json` from this directory and lets users install scripts with one click.
4+
5+
No separate repo, no separate auth — drop a `.lua` file in the right subdirectory, add an entry to the index, open a PR.
6+
7+
## Layout
8+
9+
```
10+
community-lua-scripts/
11+
├── README.md (this file)
12+
└── <game-id>/ (matches the manifest.toml `id` of the game)
13+
├── index.json (machine-readable script listing)
14+
├── <slug>.lua (script bodies)
15+
└── …
16+
```
17+
18+
Currently shipped games:
19+
20+
- `batman-lod/` — LEGO Batman: Legacy of the Dark Knight
21+
22+
## `index.json` schema
23+
24+
Each game's `index.json` is a single object with a `scripts` array. Slugs must be kebab-case (`[a-z0-9-]+`) and unique inside the game.
25+
26+
```json
27+
{
28+
"scripts": [
29+
{
30+
"slug": "rapid-fire-batarang",
31+
"name": "Rapid-fire Batarang",
32+
"description": "Loops the throw animation so batarangs leave faster than the cooldown allows.",
33+
"author": "@your-github-handle",
34+
"url": "https://raw.githubusercontent.com/satyajiit/openforge-aio/main/community-lua-scripts/batman-lod/rapid-fire-batarang.lua"
35+
}
36+
]
37+
}
38+
```
39+
40+
Fields:
41+
42+
| Field | Required | Notes |
43+
|---------------|----------|-------------------------------------------------------------------------------------------------------------|
44+
| `slug` | yes | Filename stem of the `.lua` body (without extension). Must match `^[a-z0-9-]+$`. |
45+
| `name` | yes | Display name shown in the sidebar. |
46+
| `description` | no | One-sentence summary, shown under the name. |
47+
| `author` | no | Your GitHub handle (e.g. `@octocat`) or display name. |
48+
| `url` | no | Raw URL to the `.lua` body. Defaults to `community-lua-scripts/<game>/<slug>.lua` in this repo — usually fine to omit. |
49+
50+
## Adding a script
51+
52+
1. Fork `satyajiit/openforge-aio` and check out a branch.
53+
2. Drop your script at `community-lua-scripts/<game-id>/<slug>.lua`.
54+
3. Add a corresponding entry to `community-lua-scripts/<game-id>/index.json` (create the file if it doesn't exist yet — schema above).
55+
4. Open a PR. CI will validate the JSON shape; we'll review the script body for safety + behaviour.
56+
57+
## Rules
58+
59+
- **Single-player offline only.** Same as the rest of OpenForge. Scripts that touch online state will be declined.
60+
- **No outbound network calls.** Scripts run inside the trainer's per-game DLL with reflection + memory access; they should not need HTTP / sockets and the runtime doesn't expose them.
61+
- **MIT-licensed original work.** Don't paste extracted CT logic from closed-source trainers. Recreating an idea from scratch is fine.
62+
- **Stable APIs only.** The Lua bindings (UE5 reflection, key helpers, output) are still firming up — pin to documented helpers, not internal back-doors.
63+
- **Author credit goes in the `author` field.** No header banners or watermarks inside the script body, please.
64+
65+
## Local testing
66+
67+
Before opening a PR, point your local OpenForge build at your fork to verify:
68+
69+
1. Push your branch to your fork.
70+
2. Edit `crates/app/src-tauri/src/lua/community.rs` constants `INDEX_URL_TEMPLATE` + `default_script_url` to point at `https://raw.githubusercontent.com/<your-fork>/openforge-aio/<branch>/community-lua-scripts/…` temporarily.
71+
3. `pnpm tauri:dev:fast`, open the game, switch to the Lua tab → Community.
72+
4. Revert the constants before opening the PR.
73+
74+
(A cleaner per-build override mechanism is on the roadmap; for now this manual swap is the workflow.)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"scripts": []
3+
}

crates/app/src-tauri/src/lua/community.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
//! Community Lua script index fetcher.
22
//!
3-
//! Sources its data from `github.com/openforge/openforge-lua-scripts`. For
4-
//! each game we fetch:
3+
//! Sources its data from the `community-lua-scripts/` directory inside the
4+
//! OpenForge repo itself — no separate repo to maintain. For each game we
5+
//! fetch:
56
//!
67
//! ```text
7-
//! https://raw.githubusercontent.com/openforge/openforge-lua-scripts/main/games/<gameId>/index.json
8+
//! https://raw.githubusercontent.com/satyajiit/openforge-aio/main/community-lua-scripts/<gameId>/index.json
89
//! ```
910
//!
1011
//! The index is a JSON `{ "scripts": [ { slug, name, description, author,
1112
//! url } ] }`. Script bodies are pulled lazily by `install_community_script`
12-
//! using the `url` field. The repo is expected to not exist (or 404) on day
13-
//! one — that path returns an empty list rather than erroring, so the UI
14-
//! always renders the contribute-CTA cleanly.
13+
//! using the `url` field (defaults to `community-lua-scripts/<gameId>/<slug>.lua`
14+
//! in the same repo). If a game's directory doesn't exist yet the fetcher
15+
//! returns an empty list rather than erroring, so the UI always renders the
16+
//! contribute-CTA cleanly.
1517
1618
use std::path::PathBuf;
1719
use std::time::Duration;
@@ -24,7 +26,7 @@ use crate::paths::AppPaths;
2426
use super::{LuaScript, LuaSource, storage};
2527

2628
const INDEX_URL_TEMPLATE: &str =
27-
"https://raw.githubusercontent.com/openforge/openforge-lua-scripts/main/games/{game}/index.json";
29+
"https://raw.githubusercontent.com/satyajiit/openforge-aio/main/community-lua-scripts/{game}/index.json";
2830

2931
const HTTP_TIMEOUT: Duration = Duration::from_secs(10);
3032

@@ -59,7 +61,7 @@ fn index_url(game_id: &str) -> String {
5961

6062
fn default_script_url(game_id: &str, slug: &str) -> String {
6163
format!(
62-
"https://raw.githubusercontent.com/openforge/openforge-lua-scripts/main/games/{game_id}/{slug}.lua"
64+
"https://raw.githubusercontent.com/satyajiit/openforge-aio/main/community-lua-scripts/{game_id}/{slug}.lua"
6365
)
6466
}
6567

crates/app/src/components/lua-scripts-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const EMPTY_BUCKET: { user: LuaScript[]; community: LuaScript[] } = {
5151
};
5252

5353
const COMMUNITY_REPO_URL =
54-
"https://github.com/openforge/openforge-lua-scripts";
54+
"https://github.com/satyajiit/openforge-aio/tree/main/community-lua-scripts";
5555

5656
const STARTER_TEMPLATE = `-- New script
5757
-- Tip: the Lua runtime integration is not yet wired up — Run is disabled.

0 commit comments

Comments
 (0)