View Single Post
05/12/23, 11:38 AM   #4
buldezir
AddOn Author - Click to view addons
Join Date: Oct 2018
Posts: 4
without any libs:

Code:
import { readFileSync } from "node:fs";

export function luaToJson(content: string): any {
    content = content.substring(content.indexOf("\r\n") + 2);
    content = content.replace(/\[\"?([\w\$]+)\"?\] = /g, '"$1": ');
    content = content.replace(/,(\r\n\s*})/gm, "$1");
    return JSON.parse(content);
}

export function readSavedVariablesFile(path: string): any {
    return luaToJson(readFileSync(path, "utf8"));
}
  Reply With Quote