Mark All Tiles Impassible in a Tileset

Hey, folks!

I want to get into plugin development, so I figured I'd start out by trying to alleviate an issue I have that I can't find a plugin for. Personally, I hate individually marking tiles with 0, X, * because I have far more X tiles than anything else. So I want a plugin that can either mark the entire tileset X with a script or command, or (more likely) do that on import by changing the default passage from O to X.

I have found the documentation for the flags here: https://kinoar.github.io/rmmv-doc-web/interfaces/rpg.tileset.html

The array info is pretty straightforward: 0x0001: Impassable downward 0x0002: Impassable leftward 0x0004: Impassable rightward 0x0008: Impassable upward 0x0010

Or so I thought.

When looking at the Tilesets.json, I can find no indication of these flags or how they're used. I see them (I think) in various MapXXXX.json, but again, don't know how to quite get that info into a plugin script. Both because I am crazy new to RMMV scripting and because these arrays are ginormous.

I put this in the Learning JavaScript forum instead of the Plugin Request because I'm not so much interested in the solution to the problem as I am the fundamental how and why of the scripting behind solving it. If that makes sense.

Thanks, y'all!
Get ready to get your hands dirty. Do you know what 0x10 is? That's hexadecimal notation for the hex number 10, which is equivalent to 16 in decimal and 0001 0000 in binary.

If you have a Windows computer I'd recommend opening up the Calculator app and switch to Programmer mode.

If you open up the code you'll see stuff like this:
Code:
Game_Map.prototype.checkPassage = function(x, y, bit) {
    var flags = this.tilesetFlags();
    var tiles = this.allTiles(x, y);
    for (var i = 0; i < tiles.length; i++) {
        var flag = flags[tiles[i]];
        if ((flag & 0x10) !== 0)  // [*] No effect on passage
            continue;
        if ((flag & bit) === 0)   // [o] Passable
            return true;
        if ((flag & bit) === bit) // [x] Impassable
            return false;
    }
    return false;
};

The single "&" is a bitwise AND operation to check the passability of the tile based on the flag. You could drop a breakpoint into that function and check the values in debug to get a better sense of what it is doing.

Edit:
Check this function too, it uses a bitwise shift operator
Code:
Game_Map.prototype.isPassable = function(x, y, d) {
     return this.checkPassage(x, y, (1 << (d / 2 - 1)) & 0x0f);
};
we discussed something like this in another thread, for Ace.
https://forums.rpgmakerweb.com/inde...p-tiles-using-script-call.104491/#post-948892

shouldn't be too hard to make the conversion.
You guys are fantastic. Thank you.

As soon as I can get back to my computer, I’m gonna start getting in over my head since I’ve never worked with hex.

Original thread: https://forums.rpgmakerweb.com/threads/mark-all-tiles-impassible-in-a-tileset.107417/