ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Dev Tools (https://www.esoui.com/forums/forumdisplay.php?f=173)
-   -   Nodejs - Saved Variable JSON converter (https://www.esoui.com/forums/showthread.php?t=10438)

quentinlamamy 01/31/23 12:35 AM

Nodejs - Saved Variable JSON converter
 
Hi,

I just create a nodejs script to convert a lua saved variable file to a json. Do you think that there is a need for some other dev. If yes i will publish it on npm.

If you have some specific request of feature , feel free to ask, i will add it

Baertram 01/31/23 04:36 AM

It could always help to have such tools, thank you.
If you put it on github e.g. we can raise feature requests or contribute.
Or you release it as addon in the tools category here, which is a good way to find them too.

quentinlamamy 01/31/23 06:35 AM

I think i will let the project on github (and published on npm). For the esoui webpage, i can automate the upload and the addon description based on the readme file (i don't have check the esoui api upload yet, not sure if description can be automated)

buldezir 05/12/23 11:38 AM

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"));
}



All times are GMT -6. The time now is 07:29 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI