allow saving and loading carts
This commit is contained in:
parent
13b600eb95
commit
86d8a8b166
@ -9,6 +9,7 @@ import { addToContext, runCode } from "./runcode.ts";
|
|||||||
import { resetRepl } from "./repl.ts";
|
import { resetRepl } from "./repl.ts";
|
||||||
import { COLOR } from "./colors.ts";
|
import { COLOR } from "./colors.ts";
|
||||||
import { getSheet, getCodeSheet } from "./sheet.ts";
|
import { getSheet, getCodeSheet } from "./sheet.ts";
|
||||||
|
import { saveCart, loadCart } from "./cart.ts";
|
||||||
|
|
||||||
let spritesheet: number | null = null;
|
let spritesheet: number | null = null;
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ const faux = {
|
|||||||
},
|
},
|
||||||
log: console.log,
|
log: console.log,
|
||||||
JSON: JSON,
|
JSON: JSON,
|
||||||
|
save: saveCart,
|
||||||
|
load: loadCart,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in faux) {
|
for (const key in faux) {
|
||||||
|
10
cart.ts
10
cart.ts
@ -1,10 +1,14 @@
|
|||||||
import fakeCart from "./cart_unpacked.json" assert { type: "json" };
|
import fakeCart from "./cart_unpacked.json" assert { type: "json" };
|
||||||
import { Sheet } from "./sheet.ts";
|
import { Sheet } from "./sheet.ts";
|
||||||
|
|
||||||
const cart = fakeCart as Array<Sheet>;
|
let cart = fakeCart as Array<Sheet>;
|
||||||
|
|
||||||
export const loadCart = (_name: string) => {
|
export const saveCart = async (fname: string) => {
|
||||||
return;
|
await Deno.writeTextFile("./carts/"+fname+".fx", JSON.stringify(getCart()));
|
||||||
|
}
|
||||||
|
|
||||||
|
export const loadCart = async (fname: string) => {
|
||||||
|
cart = JSON.parse(await Deno.readTextFile("./carts/"+fname+".fx"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCart = () => {
|
export const getCart = () => {
|
||||||
|
0
carts/.gitkeep
Normal file
0
carts/.gitkeep
Normal file
Loading…
x
Reference in New Issue
Block a user