Skip to content

Commit

Permalink
Fix for #1557 (#1563)
Browse files Browse the repository at this point in the history
fix for #1557
  • Loading branch information
snoglobe authored Mar 30, 2024
1 parent ecc5123 commit 59cdac0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/lib/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ export function runGame(code: string, canvas: HTMLCanvasElement, onPageError: (e
return timer
},
setLegend: (..._bitmaps: [string, string][]) => {
bitmaps.value = _bitmaps
return game.api.setLegend(..._bitmaps)
// this is bad; but for some reason i could not do _bitmaps === [undefined]
// @ts-ignore
if(JSON.stringify(_bitmaps) === "[null]") {
// @ts-ignore
bitmaps.value = [[]];
throw new Error('The sprites passed into setLegend each need to be in square brackets, like setLegend([player, bitmap`...`]).')
} else {
bitmaps.value = _bitmaps;
}
return game.api.setLegend(...bitmaps.value)
},
playTune: (text: string, n: number) => {
const tune = textToTune(text)
Expand Down Expand Up @@ -94,7 +102,13 @@ export function runGameHeadless(code: string): void {
setTimeout: () => {},
setInterval: () => {},
setLegend: (..._bitmaps: [string, string][]) => {
bitmaps.value = _bitmaps
// this is bad; but for some reason i could not do _bitmaps === [undefined]
if(JSON.stringify(_bitmaps) === "[null]") {
// @ts-ignore
bitmaps.value = [[]];
throw new Error('The sprites passed into setLegend each need to be in square brackets, like setLegend([player, bitmap`...`]).');
} else
bitmaps.value = _bitmaps
return game.api.setLegend(..._bitmaps)
},
playTune: () => {}
Expand Down

0 comments on commit 59cdac0

Please sign in to comment.