[RMMV] Erase pictures based on zeroed variables (Script help)

Hi everyone, I hope your are all ok.

I need your precious help again!

The title basically says what I need. But it can get a little complex (for me..):

I need a script that checks which variable from 200 to 300 are equals to zero.
Then, it gets the 100th var(after each of those with zero value) value to erase some pictures (The value returned is the picture's Id)

I know, it's a little confusing, right?

So here goes an exemple:

1. Script checks variables 200 to 300 looking for zeroed ones.
- Returns vars 230 to 236. (They won't always be a sequence)

2. Then the script will now check the value of the 100th var after each one.
- Vars 330 to 336 will be checked in this case.

Let's say that this is how variables are set right now:
var 330 = 21
var 331 = 23
var 332 = 24
var 334 = 26
var 335 = 27
var 336 = 31

3. Finally the script should erase all pictures with the same Id as the value stored in those vars.
- Pictures 21,23, 24, 26, 27 and 31 are erased.

Obs. If the var with picture's Id returns zero, then no picture should be erased. (Of course no picture can use the 0 as id, but I want to avoid error messages and math conflicts in the script)

Logic suggestions are always welcome too!
Thanks!
Code:
for (let i = 200, l = $gameVariables; i < 300; ++i) if (l.value(i) > 0) l.value(401).push(l.value(i + 100));
for (let i = 0, l = $gameVariables.value(401); i < l.length; ++i) $gameScreen.erasePicture(l[i]);
This will probably work, need to script call/change variable at the beginning of game to set variable 401 to [] or change the 401 to whatever in that, just copy above code into a script call.


Actually just use this in a plugin.
Code:
Game_Screen.prototype.pictureAllErase = function() {
const p = [];
for (let i = 200, l = $gameVariables; i < 300; ++i) if (l.value(i) === 0) p.push(l.value(i + 100));
for (let i = 0; i < p.length; ++i) this.erasePicture(p[i]);
};
$gameScreen.pictureAllErase(); in script call.
Code:
for (let i = 200, l = $gameVariables; i < 300; ++i) if (l.value(i) > 0) l.value(401).push(l.value(i + 100));
for (let i = 0, l = $gameVariables.value(401); i < l.length; ++i) $gameScreen.erasePicture(l[i]);
This will probably work, need to script call/change variable at the beginning of game to set variable 401 to [] or change the 401 to whatever in that, just copy above code into a script call.


Actually just use this in a plugin.
Code:
Game_Screen.prototype.pictureAllErase = function() {
const p = [];
for (let i = 200, l = $gameVariables; i < 300; ++i) if (l.value(i) === 0) p.push(l.value(i + 100));
for (let i = 0; i < p.length; ++i) this.erasePicture(p[i]);
};
$gameScreen.pictureAllErase(); in script call.


Wow, so fast! You took about 30 min to set this up!? Damn

So I tested and........ it's working!!

Forgot to say: I realized that some of the vars holding picture's id can also be negative, but thankfully your script still fits!

I think this is it! I'm posting here the java file you made it just in case someone (I strongly doubt) needs it!

Javascript file: click here!

Thank you very much @glaphen

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-erase-pictures-based-on-zeroed-variables-script-help.119857/