Help with global variables/arrays

v1.19.3

I’m trying to make a grid-based level maker, and it uses an array to store the level, but whenever I go from the level editor frame to the level playing frame it says the grid variable is undefined.

I’ve tried defining it as window.grid and project.grid but that doesn’t work.

LevelMaker4-27-2022_12-21-15.wick (3.4 KB)

I can’t go on my computer right now to check your project, but you have to make sure the frame that defines the variables are on the topmost layer, and lasts throughout the entirety of the project.

oh ok. I thought defining it as project.grid would work

it still does not work

if you define it via window.grid, you access the variable via window.grid or grid alone.

if you define it via project.grid, you access the variable with project.grid

i hope this solves your problem. otherwise idk how to help you since i still am unable to go on my computer.

First, the unload doesn’t work from testing and according to this post https://forum.wickeditor.com/t/unload-script-is-not-executing
A solution is to run the code in the button that brings you to the next frame before switching frames.

Secondly I noticed that it looks like when going to the second frame all the clones automatically goto a set frame rather than loading anything from the array.

Well, the clones going to a set frame is intentional and meant for testing purposes. Also, I’ll see what I can do about running the code in the button.