MV I wanna check multiple variable data at once

I think this is an array issue and I don't get arrays very well, but basically I want a conditional branch that checks to see if ONE of the events in a 9x9 radius (it's a bomb event) has a matching ID number (using variables).

The long winded way to do this would be a conditional branch for each of the 8 variables, but that's very sloppy (eight because there is no need to check the spot the player is on).

I need a conditional branch that checks all the bomb event variables to see if ONE matches the events own ID. This would allow for multiple events in the 9x9 area (should they exist) to activate due to only one of the spots needing to match the number.

Let me know if I phrased that badly, I am bad at phrasing.
have a plugin create a new function to be called by the conditional branch
that function should then make the eight comparisons for the eight events and return true if one of them fits.

Programming is not the same as miracle working. You have to check each position independently.
You can only change where you make that list or loop of comparisons.
have a plugin create a new function to be called by the conditional branch
that function should then make the eight comparisons for the eight events and return true if one of them fits.

Programming is not the same as miracle working. You have to check each position independently.
You can only change where you make that list or loop of comparisons.
B-but, I had programming spin me gold, how can it fail me now.
(sigh) not sure I have the skills to make a pulgin yet. Guess I'll have to do it that hard way.

Thanks. 🙂
I'm not sure I understand the request.

From your first paragraph, it sounds like you have an event Id, and you want to see if a given 3x3 square contains an event that has the same Id - is that right? That would mean that you're saying, "Is the event located somewhere in these 9 squares," correct?

You mention only needing to check 8 squares, so is it more like the player blows up and you want to see if there's an event somewhere in the 8 squares around them?

We can probably make a common event instead of a Plugin if you really wanted, though a Plugin would be easier, but I don't quite get what you actually want the end result to be and what information you're starting with.
I'm not sure I understand the request.

From your first paragraph, it sounds like you have an event Id, and you want to see if a given 3x3 square contains an event that has the same Id - is that right? That would mean that you're saying, "Is the event located somewhere in these 9 squares," correct?

You mention only needing to check 8 squares, so is it more like the player blows up and you want to see if there's an event somewhere in the 8 squares around them?

We can probably make a common event instead of a Plugin if you really wanted, though a Plugin would be easier, but I don't quite get what you actually want the end result to be and what information you're starting with.
Sorry, I'm really bad at explaining things.

Common event calls up a bomb in front of the player-> Bomb explodes covering the area around it -> blows up compatible events

Since the diagram looks like this:
XXX
XBX
XPX


I was merely saying I don't really need the variable to check the players location since the player is never going to be standing on an event that can be blown up therefore I only need to check for events in the X and B areas. Simple enough.

Honestly the information was superfluous.
I was just wondering if there was a quick way to check if one of those variables matched the ID of the activated bombed event all at once instead of having to make a conditional branch for each.
Without a plugin this does not seem to be the case so I must do it in the round about way instead.

I thought that might be the case.
I'm still not totally getting what you're after, but perhaps this will help?

I've set aside four variables. In this case, I used:
  • Variable 9: boomId (represents the Id of the bomb event going off)
  • Variable 10: destructibleIds (represents all the event Ids that should blow up)
  • Variable 11: destructCount (used as an iterator in a loop)
  • Variable 12: destructibleId (used to represent the current event Id that should blow up in a loop)

I've made a common event called Boom that looks like so:
Spoiler: Boom common event
boom-event.PNG

It would be called like so:
bomb-event.PNG


So whatever the bomb event is, you set its Id to variable 9 (or whatever you want to set aside), then call the common event.

The common event will then look at each coordinate around that event with that event's coordinates as the center - so:
  • x - 1, y - 1: top left
  • x, y - 1: top center
  • x + 1, y - 1: top right
  • x - 1, y: left center
  • etc.
For each coordinate, it will look at all the events on the current map and gather up the Ids of each event whose coordinates match one of those coordinates and it will store the resulting Array in game variable 10.

As an example, the slime is event 1 and represents my bomb. The brown chest is event 2, the red chest is event 3, and the gold chest is event 4.
chest-events.PNG

After interacting with the slime, game variable 10 would be an Array of [2, 3], because event Id 2 (the brown chest) and event Id 3 (the red chest) are in the 8 surrounding squares, but event Id 4 (the gold chest) is not.

So then, in the common event, I've got the event version of a for loop - set an iterator (game variable 11 = 0, the first index of the Array that variable 10 is holding), then retrieve the value for that iterator (game variable 12, which will be game variable 10 at index 0, which is game variable 11). I then have a conditional branch saying, "If something is defined for game variable 12," and an else meaning, "There's nothing in the Array at that point, so exit the loop".

So within the part of the conditional where something is defined for game variable 12, I could do whatever you want to do to have something blow up. Presumably it would be a programmatic move route of some sort, but again, I'm not for sure what you're trying to do.

If that's not quite what you're looking for, then the first part would at least give you an Array of all the Ids of events that are in explodable range of the bomb. Here's the code for that:
Code:
const bomb = $dataMap.events[$gameVariables.value(9)];
$gameVariables.setValue(10,
[
  [bomb.x - 1, bomb.y - 1], [bomb.x, bomb.y - 1],
  [bomb.x + 1, bomb.y - 1], [bomb.x - 1, bomb.y],
  [bomb.x + 1, bomb.y], [bomb.x - 1, bomb.y + 1],
  [bomb.x, bomb.y + 1], [bomb.x + 1, bomb.y + 1]
].reduce((blowUpIds, [x,y]) => {
  return blowUpIds.concat($dataMap.events.filter(event => {
    return event && event.x === x && event.y === y;
  }).map(event => event.id));
}, []));
If that's not quite what you're looking for, then the first part would at least give you an Array of all the Ids of events that are in explodable range of the bomb. Here's the code for that:
Code:
const bomb = $dataMap.events[$gameVariables.value(9)];
$gameVariables.setValue(10,
[
  [bomb.x - 1, bomb.y - 1], [bomb.x, bomb.y - 1],
  [bomb.x + 1, bomb.y - 1], [bomb.x - 1, bomb.y],
  [bomb.x + 1, bomb.y], [bomb.x - 1, bomb.y + 1],
  [bomb.x, bomb.y + 1], [bomb.x + 1, bomb.y + 1]
].reduce((blowUpIds, [x,y]) => {
  return blowUpIds.concat($dataMap.events.filter(event => {
    return event && event.x === x && event.y === y;
  }).map(event => event.id));
}, []));
Nah it's not quite what I'm looking for, but this array may help - if not now - then in a future project.

I appricate you trying to help despite me being so bad at expressing what I want.

Original thread: https://forums.rpgmakerweb.com/threads/i-wanna-check-multiple-variable-data-at-once.139713/