Attempting to create a simple fog of war without the use of plugins

Good day! I hope that someone can help me, I am attempting to create a simple fog of war for dungeon purpose. I assumed this was possible, but I have no idea how to go about it once I sat down to do it.

I'm trying to exploit this "SceneManager._scene._spriteset._tilemap.children[0].tilemap.upperZLayer.alpha = 0;" on created black/semi-trasparent tilesets in common events in order to create a sort of fog of war.

What I achieved so far is the possibility to set ALL upper(or lower) tilesets "invisible" by changing the alpha to 0.

Is there the possibility to change a single tilemap alpha instead of all the tileset? So I could use that for different tile on different part of the map and choose which one have to be revealed.

Exemple: when hero touch lever A, reveal hidden room A (change alpha = 0 of tile 1), when touch the lever B, reveal hidden room B (change alpha = 0 of tile 2) and so on.

I'm kinda stuck. Any ideas?
Li'l rant here: why do some people (not just you) insist on doing things "without plugins", then ask how to edit the code? Plugins modify the existing code, plus they can be switched on/off on demand, are not erased by core script updates, are more easily tracked/identified/credited, etc. OK, rant over. 😔
Edit: whoops, you're just trying to use a script call. 😅 Similar idea, sorry for going off on a tangent though.

For your question: at least in canvas mode, tiles are blitted, a.k.a. "painted", onto the appropriate layer, so I believe you'd need to intercept the draw calls. Maybe something like this (untested):
Spoiler: Plugin code suggestion
JavaScript:
(function() {
'use strict';

    let shouldPaintTile = function(x, y) {
        /* Your code here!
         *  - return true  => tile paints as normal;
         *  - return false => tile does not paint.
         */
        return true;
    };

    // Canvas renderer - paint tile layers at (x, y)
    (function(alias) {
        Tilemap.prototype._paintTiles = function(startX, startY, x, y) {
            if (shouldPaintTile(x, y)) alias.apply(this, arguments);
        };
    })(Tilemap.prototype._paintTiles);

    // WebGL renderer - paint tile layers at (x, y)
    (function(alias) {
        ShaderTilemap.prototype._paintTiles = function(startX, startY, x, y) {
            if (shouldPaintTile(x, y)) alias.apply(this, arguments);
        };
    })(ShaderTilemap.prototype._paintTiles);

})();
You will need to have some kind of variable to reference in the shouldPaintTile function so that the game knows when to paint a tile and when to skip it.

Note that this can be saved as a .js file (paste into text editor, Save As > File Type: All Files, Filename: whatever.js) and imported as a plugin via the Plugin Manager. 🙂

Alternatively, it is possible to take the concept here and edit the relevant parts of your project's core script files. I wouldn't recommend that (certainly not until you've confirmed that it is working as you want), for reasons already stated. 😴
Alternatively, you can use pictures to "cover" the area and then have the switch erase the picture, when the door is opened. Depending on how many rooms you're creating, this could be a lot of manual work though.
No problem dude ahaha. Just to say, I love plugins! 😛

I hope that there was some simple script call like "SceneManager._scene._spriteset._tilemap.children[0].tilemap[0].alpha = 0" to use eheh

However I'll try to create a plugin, but I don't have that much experience 😛

For "covering the area with pictures", you mean to have events with "black img" spread around the map, right? It will be a huge work to do ahah

Original thread: https://forums.rpgmakerweb.com/threads/attempting-to-create-a-simple-fog-of-war-without-the-use-of-plugins.129672/