Arcade throws error without any identifiable source in Blocks after creating array "trees"

I am working a makecode arcade game with a level system where every level ha multiple “parts”(tilemaps). Recently i changed the system so that instead of a bunch of ifs, every part was stored in an array, and that worked just fine. Later, i realized it would be much more convenient if it was made up of multiple smaller arrays with each array being a level or area in general.

However, for whatever reason, the game would refuse to run, giving me a generic error. “Fine, i’ll just look around and find what’s causing the problem”, i thought, but strangely enough, there was no error. Every block was working perfectly fine.

After finding no information online, i decided to dig a little deeper, and found that by switching to JavaScript, 4 problems popped in 2 pairs:

Element implicitly has an ‘any’ type because type ‘Number’ has no index signature.
Type ‘number’ is not assignable to type ‘number’.

The first two came up at a line where a assign a variable and start a countdown based off the respective array “trees” for each one of these

The second two came up where i assign the two arrays who’s reading cause the first two errors

Can anybody tell me exactly what’s going on and why? Thanks in Advance!

1 Like

To clarify, "Array “trees” " referrers to an array with arrays inside

Ive tried to do array trees before and I havent gotten them to work, but that may just be my lack of knowledge on how to work them. It could be that makecode isnt made to take an array from another array, like how usually you take data in the form of a number or text or image etc, but it did not have a data type for taking an array as arrays are always used by taking one value in it that is not an array.

1 Like

Hmm… Which do you think i should do?

Go Back to the messy and confusing 1 big array?
Split each Area into a separate array, making for 9 total level variables and many ifs?

1 Like

Unfortunately it’s really hard to tell without having the code to mess with; we’ve done similar set ups before in our own coding / on live streams so it sounds like it should work fine but something is clearly going wrong. Could you post a share link with the game and we can poke around and see if there’s anything we can fix?

1 Like

Wait a minute, i just found something crucial that might help solve this case.
I was trying to recreate the situation separetly and for some reason decided togo to the assignment of the variables, and saw something. The ‘levels’ variable is normal, while the ones that caused the error… are being set to 0.

I managed to fix it by copying the functional variable!


Great job!! congrats!

1 Like