2023-05-02 17:06:54 -07:00
|
|
|
import { getCart } from "./cart.ts";
|
2023-05-03 15:17:27 -07:00
|
|
|
import { runCode, addToContext } from "./runcode.ts";
|
2023-05-02 17:06:54 -07:00
|
|
|
|
|
|
|
export type SheetType = "code" | "spritesheet" | "map" | "sfx" | "patterns" | "fonts";
|
|
|
|
|
2023-05-05 11:52:08 -07:00
|
|
|
export const getSheet = (n: number) => {
|
2023-05-02 17:06:54 -07:00
|
|
|
return getCart()[n].value;
|
|
|
|
}
|
|
|
|
|
2023-05-05 11:52:08 -07:00
|
|
|
// deno-lint-ignore no-explicit-any
|
|
|
|
export const setSheet = (n: number, type: SheetType, value: any) => {
|
|
|
|
return getCart()[n] = {sheet_type: type, value};
|
|
|
|
}
|
|
|
|
|
2023-05-02 17:06:54 -07:00
|
|
|
export const codeSheet = (sheet: number) => {
|
|
|
|
const code = getSheet(sheet);
|
2023-05-03 15:17:27 -07:00
|
|
|
return runCode(code);
|
2023-05-02 17:06:54 -07:00
|
|
|
}
|
|
|
|
|
2023-05-03 15:17:27 -07:00
|
|
|
addToContext("code_sheet", codeSheet);
|