hackclub / sprig

🍃 Learn to code by making games in a JavaScript web-based game editor.

Home Page:https://sprig.hackclub.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Map editor does not open when clicking on map thingie

grymmy opened this issue · comments

Describe the bug
After some work in the editor, I observed not being able to open the map editor when clicking on a map variable.

To Reproduce
Steps to reproduce the behavior:

  1. Click on a map variable

Expected behavior
The map editor opens

Actual behavior
The map editor does not open

Screenshots
https://hackclub.slack.com/files/U01FAVARYH1/F06QSUETU59/screen_recording_2024-03-21_at_8.06.06_pm.mov

Note that we are currently unable to provide 100% steps for reproduction here. (NEVERMIND! 3/27)

Here is a minimal procedure to reproduce the issue.

Consider the following example:

/*
First time? Check out the tutorial game:
https://sprig.hackclub.com/gallery/getting_started

@title: 
@author: 
@tags: []
@img: ""
@addedOn: 2024-00-00
*/

const player = "p"

setLegend(
  [ player, bitmap`...` ]
)

setSolids([])

let level = 0
const levels = [
  map`
p.
..`
]

setMap(levels[level])

setPushables({
  [ player ]: []
})

onInput("s", () => {
  getFirst(player).y += 1
})

afterInput(() => {
  
})
  1. Duplicate this line, without adding a separating comma
[ player, bitmap`...` ]
  1. Click Run. The editor appropriately raises a syntax error:
Error: The sprites passed into setLegend each need to be in square brackets, like setLegend([player, bitmap`...`]).
    at setLegend (index.78f90869.js:1:8965)
    at setLegend (index.78f90869.js:3120:12136)
    at eval (index.78f90869.js:14:1)
  1. Looking at the console events log, the backend also raises this error
editor.bde1f794.js:23 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'state')
    at editor.bde1f794.js:23:22531
    at Array.map (<anonymous>)
    at f1 (editor.bde1f794.js:23:22513)
    at editor.bde1f794.js:23:26806
    at p.x (signals.module.5a04f1ba.js:1:1208)
    at p.c (signals.module.5a04f1ba.js:1:3642)
    at $ (signals.module.5a04f1ba.js:1:312)
    at u.set (signals.module.5a04f1ba.js:1:1616)
    at Object.c [as onClick] (editor.bde1f794.js:268:6812)
    at Object.onClick (button.7ef0ffa5.js:8:108)
    at HTMLButtonElement.B (preact.module.3821bb68.js:1:4195)

Now, the map cannot be opened. I suspect that when this particular syntax error is present, once we click "Run", an autosave is attempted. This autosave likely fails, setting the value of some important property to null. When the modal popup view is then triggered, we try accessing a property of some null value, which prevents the map from opening in the future. It's not entirely clear to me which portion of the TypeScript source code the backend error provided in step 3 relates to (since it's fairly cryptic due to the JS compilation), but it may be a good idea to check this file for anything suspicious, as well as wherever the saving loop is implemented.

commented

i get a different error:

Uncaught (in promise) TypeError: (destructured parameter) is undefined
    children map-editor.tsx:81
    MapEditor map-editor.tsx:81
    Preact 15
    debounceRendering debounceRendering.js:13
[map-editor.tsx:81:25](http://localhost:3000/src/components/subeditors/map-editor.tsx)
Uncaught (in promise) TypeError: ResizeObserver.observe: Argument 1 is not an object.
    MapEditor map-editor.tsx:58
    Preact 18
    debounceRendering debounceRendering.js:13
2 [map-editor.tsx:58:11](http://localhost:3000/src/components/subeditors/map-editor.tsx)
Uncaught (in promise) TypeError: ResizeObserver.observe: Argument 1 is not an object.
    MapEditor map-editor.tsx:58
    Preact 18
    debounceRendering debounceRendering.js:13
    promise callback*options.debounceRendering debounceRendering.js:11
    Preact 6
    onClick open-button.tsx:43
    I Preact
[map-editor.tsx:58:11](http://localhost:3000/src/components/subeditors/map-editor.tsx)