goboscript icon indicating copy to clipboard operation
goboscript copied to clipboard

variables and lists 'for all sprites' get reset upon initialization

Open rens2 opened this issue 1 year ago • 0 comments

Currently, variables and lists 'for all sprites' need to be defined in the stage while also being under a hat block like this:

costumes "blank.svg";

onflag {
    x = 0;
    delete list;
}

Unfortunately, this means that both of them are automatically reset when a project is restarted. It also interferes with scripts in other sprites that make use of these variables and lists right after the green flag is clicked, resetting them after a value has already been set or an item has already been added.

I've been able to resolve this issue with a simple workaround, but this doesn't appear to be intended behavior:

costumes "blank.svg";

onloudness > 999 {
    x = 0;
    delete list;
}

Maybe this could be solved by adding new syntax? Or, alternatively, changes could be made to allow blocks to exist without a hat block, however that does not sound like a great idea to me. Using the workaround I found is not a huge inconvenience, but it did take me some time to figure out why my project wasn't working...

rens2 avatar Oct 10 '24 15:10 rens2