fantasy-console/sheet.ts
2023-05-05 11:52:08 -07:00

20 lines
552 B
TypeScript

import { getCart } from "./cart.ts";
import { runCode, addToContext } from "./runcode.ts";
export type SheetType = "code" | "spritesheet" | "map" | "sfx" | "patterns" | "fonts";
export const getSheet = (n: number) => {
return getCart()[n].value;
}
// deno-lint-ignore no-explicit-any
export const setSheet = (n: number, type: SheetType, value: any) => {
return getCart()[n] = {sheet_type: type, value};
}
export const codeSheet = (sheet: number) => {
const code = getSheet(sheet);
return runCode(code);
}
addToContext("code_sheet", codeSheet);