feat: add 2DA intellisense parser and lookup for NWScript editor
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
} from "../services/editor.service.js";
|
||||
import { lookupResref, getResrefCount } from "../nwscript/resref-index.js";
|
||||
import { lookupTlk, getTlkCount } from "../nwscript/tlk-index.js";
|
||||
import { get2DAFile, list2DAFiles, get2DARow } from "../nwscript/twoda-index.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -78,4 +79,22 @@ router.get("/tlk-count", (_req, res) => {
|
||||
res.json({ count: getTlkCount() });
|
||||
});
|
||||
|
||||
router.get("/2da", (_req, res) => {
|
||||
res.json({ files: list2DAFiles() });
|
||||
});
|
||||
|
||||
router.get("/2da/:name", (req, res) => {
|
||||
const file = get2DAFile(req.params.name);
|
||||
if (!file) return res.status(404).json({ error: "2DA file not found" });
|
||||
res.json({ columns: file.columns, rowCount: file.rows.size });
|
||||
});
|
||||
|
||||
router.get("/2da/:name/:row", (req, res) => {
|
||||
const row = parseInt(req.params.row, 10);
|
||||
if (isNaN(row)) return res.status(400).json({ error: "invalid row" });
|
||||
const data = get2DARow(req.params.name, row);
|
||||
if (!data) return res.status(404).json({ error: "row not found" });
|
||||
res.json(data);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user