Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 

ESOUI » Developer Discussions » Dev Tools » Nodejs - Saved Variable JSON converter


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off