Next, we need to create a new closeChest function. Create this under openChest.
Tip: Folding Code
When scripts get longer, it can get annoying to scroll through lots of code you aren’t working on right now. The dot big bang code editor allows you to fold code, which hides the lines inside a function or if-statement (basically anything with { }) when you don’t need to be looking at it.
- In the left margin of your code editor (near the line numbers), hover your mouse to see the ⌄ character.
- Choose a function you aren’t using right now, like
start
,tick
, andstartOpeningLidAnimation
and click the down arrow to fold the code. - You can click the ⋯ to the right of the function or the > in the left margin to open the code again when you need to work on it.