professorbeej

Villager
Member
Joined
Feb 27, 2019
Messages
29
Reaction score
10
First Language
English
Primarily Uses
RMMV
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!
 

Aloe Guvner

Walrus
Regular
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,206
First Language
English
Primarily Uses
RMMV
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);
};
 
Last edited:

professorbeej

Villager
Member
Joined
Feb 27, 2019
Messages
29
Reaction score
10
First Language
English
Primarily Uses
RMMV
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Anyone else? Hairstylist cuts and styles hair, "see it look so nice!" Me: Hey. I agree with you, but I'mma be real. I'm immediately washing this all out.
How it feels right now with Advent resources and Sleigh the Competition event screenshots coming in.
WindRyder_ChristmasIncoming.png
So, apparently, Glow-in-the-Dark cats exist.

Are Sir Oinkers and the fairy responsible for all those dead uhm sleeping monsters?
Well, they now can be in your game, thanks to Day 4's content!
1701691228682.png

Forum statistics

Threads
136,737
Messages
1,269,358
Members
180,459
Latest member
CielRuby
Top