From a6d093d728e863044daffecf9c7138ed0fa179d0 Mon Sep 17 00:00:00 2001 From: dylan <> Date: Sun, 14 May 2023 13:54:52 -0700 Subject: [PATCH] Disable mset for now --- builtins.ts | 13 +++++++------ cart.ts | 7 +++++-- manual.md | 2 +- sheet.ts | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/builtins.ts b/builtins.ts index d60d906..2f623c2 100644 --- a/builtins.ts +++ b/builtins.ts @@ -127,12 +127,13 @@ const faux = { } return getMapSheet(mapSheet).get(x, y)[1]; }, - mset: (mapSheet: number, x: number, y: number, sprSheet: number, spr: number) => { - if (x < 0 || x >= 64 || y < 0 || y >= 64) { - return; - } - getMapSheet(mapSheet).set(x, y, [sprSheet, spr]); - }, + // Temporarily removing mset, since it would overwrite static cart data + // mset: (mapSheet: number, x: number, y: number, sprSheet: number, spr: number) => { + // if (x < 0 || x >= 64 || y < 0 || y >= 64) { + // return; + // } + // getMapSheet(mapSheet).set(x, y, [sprSheet, spr]); + // }, // Input [CHAR.UP]: K.ARROW_UP, [CHAR.DOWN]: K.ARROW_DOWN, diff --git a/cart.ts b/cart.ts index 34cd14a..7f8aede 100644 --- a/cart.ts +++ b/cart.ts @@ -2,7 +2,8 @@ import { path } from "./deps.ts"; import initialCart from "./initialCart.json" assert { type: "json" }; import { Sheet } from "./sheet.ts"; -let cart = initialCart as Array; +let staticCart = initialCart as Array; +let cart: Array = JSON.parse(JSON.stringify(staticCart)); const virtualPathToRealPath = (virtualFname: string) => { const realPath = path.join(".", "carts", ...virtualFname.split("/")); @@ -14,7 +15,9 @@ export const saveCart = async (fname: string) => { } export const loadCart = async (fname: string) => { - cart = JSON.parse(await Deno.readTextFile(virtualPathToRealPath(fname+".fx"))); + const json = await Deno.readTextFile(virtualPathToRealPath(fname+".fx")); + staticCart = JSON.parse(json); + cart = JSON.parse(json); } export const getCart = () => { diff --git a/manual.md b/manual.md index ad6ddf6..1bd4654 100644 --- a/manual.md +++ b/manual.md @@ -51,7 +51,7 @@ And math symbols: - `mgetsht(mapSheet: number, x: number, y: number)` returns the sheet number of the sprite at tile (x,y) in the given map - `mgetspr(mapSheet: number, x: number, y: number)` returns the sprite number within it's sheet of the sprite at tile (x,y) in the given map -- `mset(mapSheet: number, x: number, y: number, sprSheet: number, spr: number)` sets the sprite at tile (x,y) in the given map to the given sprite of the given spritesheet. +- `mset(mapSheet: number, x: number, y: number, sprSheet: number, spr: number)` sets the sprite at tile (x,y) in the given map to the given sprite of the given spritesheet. **(THIS FUNCTION IS TEMPORARILY UNAVAILABLE.)** ### Input diff --git a/sheet.ts b/sheet.ts index 0fa93ef..692ba6e 100644 --- a/sheet.ts +++ b/sheet.ts @@ -18,7 +18,7 @@ export type Sheet = { } export type SheetType = Sheet["sheet_type"]; -export const getSheet = (n: number) => { +export const getSheet = (n: number): Sheet => { return getCart()[n]; } @@ -51,5 +51,6 @@ export const getMapSheet = (sheet: number) => { if (sheet_type !== "map") { throw "Trying to use a non-map sheet as a map." } + sheet_type return LinearGrid(value, 64); } \ No newline at end of file