MV Easiest way to fill in a tile with transparent green overlay color?

As the title says, I'm interested in simply filling a tile with green color.
Preferably in a psuedo format as follows:
Game_Map.prototype.fillTile(x, y, color); //color being optional

I've been looking at the QMovement plugin since it has the red overlay for map pathing. However, it does seem to incorporate quite a lot. And before I delve even deeper into it than I already have. I am gonna ask if there is an easy way to accomplish the specific task I am interested in?

Best regards,
Bishiba
I think you'll need to explain what exactly you mean by "transparent green overlay", because MV doesn't use color code transparency at all, it uses PNGs with true transparency (alpha channel data).
I think you'll need to explain what exactly you mean by "transparent green overlay", because MV doesn't use color code transparency at all, it uses PNGs with true transparency (alpha channel data).
Here's a photoshop edit that displays an example of what I want.
1639349540600.png

The following tiles are filled in with a green overlay:
(2, 2), (3,2), (3,3), (4,2), and (4,3).
Assuming the map picture above is representative of the entire map.


I'd also like to clarify that I know there is no built in function for anything like this, at least as far as I know, and I can't imagine there is one. So the function I suggested in the thread Game_Map.prototype.fillTile(x, y, color) would be a custom function.

Alright, so, I guess the best way might be a to use a sprite. And if that is the case, how would I fill the tile and map it to the map? The sprite does not need to be saved to the map. It only needs to be active upon request.

I imagine something like this, the following is simply psuedo code that I hope clarifies further what I want.
JavaScript:
Game_Map.prototype.fillTile = function(x, y, color) {
    this.sprite[x][y] = new Sprite;
    x = x * 48;
    var x2 = x + 48;
    y = y * 48;
    var y2 = y + 48;
    var opacity = 50;
    color = color || "#4eff00"; //Sets the color to specified color or to bright green.
    this.sprite.fill(x, x2 y2, y, opacity, color); // Fills an opaque green square within the pixels x -> x2 -> y2 -> y
};

Hope this clears up what I am after.

Best regards,

Edit:
And I want to clarify that I am not in love with the above idea. I can for example add a transparent green tile to the tileset. So if there is a way where I can simply add that tile on top of all other layers on a specific tile that works as well. In fact, I am gonna start looking into that option.
so basically you want to mark an area on the map without completely hiding it?

then you have two different options, both requiring plugins for different functions.

the first would be a change tile plugin giving you a script command to change a tile on the current map.
this would be the better solution for performance especially on large areas, but requires you to have thegreen glow as a tile in the tileset of the map.

the second option is to have a clone event plugin and create copies of a decorative event containing the green glow. This has two disadvantages of requiring a lot of events and possibly causing problems if there are already other events in the target position, but would work even if the tileset has no place for the additional tiles required by the first solution.
So basically you want to draw a partially-transparent 32x32 bitmap over the tile.
So basically you want to draw a partially-transparent 32x32 bitmap over the tile.
48x48 but yes 🙂

I am currently investigate the ShaderTilemap class. Hoping I'll figure out how to do this soon enough. But currently I am just trying to figure out what tileId is more specifically.

JavaScript:
ShaderTilemap.prototype._drawNormalTile = function(layer, tileId, dx, dy) {
    var setNumber = 0;

    if (Tilemap.isTileA5(tileId)) {
        setNumber = 4;
    } else {
        setNumber = 5 + Math.floor(tileId / 256);
    }

    var w = this._tileWidth;
    var h = this._tileHeight;
    var sx = (Math.floor(tileId / 128) % 2 * 8 + tileId % 8) * w;
    var sy = (Math.floor(tileId % 256 / 8) % 16) * h;

    layer.addRect(setNumber, sx, sy, dx, dy, w, h);
};

And sadly I am unable to set which bitmap to use as tileset here, so I kinda know that I am using the wrong class... Yet, the "Tilemap" class doesn't seem to exist or it exists outside the stack trace feature, somehow... Perhaps it is created in such a way that the created object just doesn't reference the original class lines?
1639353328742.png

(Does not freeze at this line, or any other line within this function or other Tilemap.prototype.functions I've tried it with.

This means I can't create a reference to the tilemap, which might be better since it actually requests a bitmap rather than layer. This depends on wheter or not Tilemap is actually being used.
Currently in the ShaderTilemap I have added a line "tilemap = this;". Giving me the option to go over the class/object in the console. And simply experiment.

JavaScript:
Tilemap.prototype._drawNormalTile = function(bitmap, tileId, dx, dy) {
    var setNumber = 0;

    if (Tilemap.isTileA5(tileId)) {
        setNumber = 4;
    } else {
        setNumber = 5 + Math.floor(tileId / 256);
    }

    var w = this._tileWidth;
    var h = this._tileHeight;
    var sx = (Math.floor(tileId / 128) % 2 * 8 + tileId % 8) * w;
    var sy = (Math.floor(tileId % 256 / 8) % 16) * h;

    var source = this.bitmaps[setNumber];
    if (source) {
        bitmap.bltImage(source, sx, sy, w, h, dx, dy, w, h);
    }
};

And, I don't know if "Normal" is what I am after, but seems to be a decent starting point at least.

And since I do not know how the (Shader)Tilemap works, it is very possible that it loops over several times, meaning that my variable "tilemap" is just referencing a useless object that can't do anything anymore. I have noticed that "paintTiles" and similar functions do work. But the draw functions, are so far useless.

The last command I tried was:
JavaScript:
tilemap._drawNormalTile(tilemap.upperLayer, 114, $gamePlayer.x, $gamePlayer.y);
I am using the $gamePlayer coords because it should then display any newly painted tile above or below the player.

Where tilemap is a reference to the last created ShaderTilemap object. Assuming they are created of course. I assume this as the functions in the class are preceeded with the "prototype". Which tells me that it's probably a constructor. But I have quite limited experience so I could be wrong.

so basically you want to mark an area on the map without completely hiding it?

then you have two different options, both requiring plugins for different functions.

the first would be a change tile plugin giving you a script command to change a tile on the current map.
this would be the better solution for performance especially on large areas, but requires you to have thegreen glow as a tile in the tileset of the map.

the second option is to have a clone event plugin and create copies of a decorative event containing the green glow. This has two disadvantages of requiring a lot of events and possibly causing problems if there are already other events in the target position, but would work even if the tileset has no place for the additional tiles required by the first solution.
Yes, I already have an event spawner, but as you state, it wouldn't be very efficient. Therefore I stray away from that solution.

Alright, if those are the only two options, I shall keep looking within the ShaderTilemap class to see if I can figure out how to simply place a tile on x,y and top layer.
Hi there!

I'm not in my computer right now, but you could try this:

Create a sprite and paint him using script call:

const spr = new Sprite(new Bitmap(48,48))
spr.bitmap.fillAll(color)
spr.move(x,y)
spr.opacity = X(0 to 255)
SceneManager._scene.addChild(spr)

Or build this as a plugin and put it on a function, and just call the function on script calls.
Hi there!

I'm not in my computer right now, but you could try this:

Create a sprite and paint him using script call:

const spr = new Sprite(new Bitmap(48,48))
spr.bitmap.fillAll(color)
spr.move(x,y)
spr.opacity = X(0 to 255)
SceneManager._scene.addChild(spr)

Or build this as a plugin and put it on a function, and just call the function on script calls.
It does create the sprite accurately, but doesn't stick to the map. It's something I discovered as well within the Tilemap is that it keeps drawing new tiles based on character location. At least that's how I believe it works at the moment.

So is there a way to lock the sprite to a map coordinate rather than a screen coordinate. Otherwise I think I'll start looking into adding a tileset tile to the tilemap.

But, I really do appreciate your little code snippet!

Best regards,
Bishiba

Edit:
After some time tampering, meaning about three hours, based off of @Eliaquim's original little suggestion I've now made a little plugin that allows this too happen 🙂

JavaScript:
BISH.createMapSprite = function(x, y, color, tilemap) {
        var color = color || "#4eff00";
        var tilemap = tilemap || SceneManager._scene.children[1].children[0].children[2];
        var tw = $gameMap.tileWidth();
        var th = $gameMap.tileHeight();
        var spr = new Sprite_Map(new Bitmap(tw, tw));
        spr._mapX = x;
        spr._mapY = y;
        spr.bitmap.fillAll(color);
        spr.move(x * tw - tw, y * th - th);
        spr.opacity = 170;
        tilemap.addChild(spr);
    };
   
    function Sprite_Map() {
        this.initialize.apply(this, arguments);
    };

    Sprite_Map.prototype = Object.create(Sprite.prototype);
    Sprite_Map.prototype.constructor = Sprite_Map;
   
    Sprite_Map.prototype.initialize = function(bitmap) {
        Sprite.prototype.initialize.call(this, bitmap);
        this._isSpriteMap = true;
        mapSprite = this;
    };
   
    Sprite_Map.prototype.update = function() {
        this.updatePosition();
    };
   
    Sprite_Map.prototype.clear = function() {
        //Dummy function.
    };
   
    Sprite_Map.prototype.updatePosition = function() {
        this.x = this.screenX();
        this.y = this.screenY();
    };
   
    Sprite_Map.prototype.screenX = function() {
        var tw = $gameMap.tileWidth();
        return Math.round(this.scrolledX() * tw);
    };

    Sprite_Map.prototype.screenY = function() {
        var th = $gameMap.tileHeight();
        return Math.round(this.scrolledY() * th);
    };

    Sprite_Map.prototype.scrolledX = function() {
        return $gameMap.adjustX(this._mapX);
    };

    Sprite_Map.prototype.scrolledY = function() {
        return $gameMap.adjustY(this._mapY);
    };

If anyone sees any improvements you're welcome to suggest it, atm, it seems to do what I wish 🙂
It does create the sprite accurately, but doesn't stick to the map. It's something I discovered as well within the Tilemap is that it keeps drawing new tiles based on character location. At least that's how I believe it works at the moment.

So is there a way to lock the sprite to a map coordinate rather than a screen coordinate. Otherwise I think I'll start looking into adding a tileset tile to the tilemap.

But, I really do appreciate your little code snippet!

Best regards,
Bishiba

Edit:
After some time tampering, meaning about three hours, based off of @Eliaquim's original little suggestion I've now made a little plugin that allows this too happen 🙂

JavaScript:
BISH.createMapSprite = function(x, y, color, tilemap) {
        var color = color || "#4eff00";
        var tilemap = tilemap || SceneManager._scene.children[1].children[0].children[2];
        var tw = $gameMap.tileWidth();
        var th = $gameMap.tileHeight();
        var spr = new Sprite_Map(new Bitmap(tw, tw));
        spr._mapX = x;
        spr._mapY = y;
        spr.bitmap.fillAll(color);
        spr.move(x * tw - tw, y * th - th);
        spr.opacity = 170;
        tilemap.addChild(spr);
    };
  
    function Sprite_Map() {
        this.initialize.apply(this, arguments);
    };

    Sprite_Map.prototype = Object.create(Sprite.prototype);
    Sprite_Map.prototype.constructor = Sprite_Map;
  
    Sprite_Map.prototype.initialize = function(bitmap) {
        Sprite.prototype.initialize.call(this, bitmap);
        this._isSpriteMap = true;
        mapSprite = this;
    };
  
    Sprite_Map.prototype.update = function() {
        this.updatePosition();
    };
  
    Sprite_Map.prototype.clear = function() {
        //Dummy function.
    };
  
    Sprite_Map.prototype.updatePosition = function() {
        this.x = this.screenX();
        this.y = this.screenY();
    };
  
    Sprite_Map.prototype.screenX = function() {
        var tw = $gameMap.tileWidth();
        return Math.round(this.scrolledX() * tw);
    };

    Sprite_Map.prototype.screenY = function() {
        var th = $gameMap.tileHeight();
        return Math.round(this.scrolledY() * th);
    };

    Sprite_Map.prototype.scrolledX = function() {
        return $gameMap.adjustX(this._mapX);
    };

    Sprite_Map.prototype.scrolledY = function() {
        return $gameMap.adjustY(this._mapY);
    };

If anyone sees any improvements you're welcome to suggest it, atm, it seems to do what I wish 🙂
Nice you manage to make it work! 😀

Original thread: https://forums.rpgmakerweb.com/threads/easiest-way-to-fill-in-a-tile-with-transparent-green-overlay-color.142935/