MV Tileset Switches Plugin [ Request ]

hi can anyone make a script where tilesets can have notes that switch switches on or off. and can keep the state of the switch?
Code:
 * @help
 * This plugin activates switches based on notetags in the tileset notes for the current map.
 *
 * To set up, create notetags in the tileset notes in the following format:
 * <TileSwitch: x, on, keep>
 * or
 * <TileSwitch: x, on, dontkeep>
 * or
 * <TileSwitch: x, off, keep>
 * or
 * <TileSwitch: x, off, dontkeep>
 *
 * Where 'x' is the switch ID to activate or deactivate. Use 'keep' to retain the switch state when moving to the next map, or 'dontkeep' to not retain the switch state.
 */

or if there is one please point me in the right direction. i know there are change switches on maps but im looking for this one please?
I strongly< suggest that you clarify what you want, because your post is extremely confusing.

1) all switches always retain their states until commanded otherwise
2) you never mention what should trigger the plugin's actions
3) why aren't you simply using events? That is exactly what events are for, including the option to use tileset graphics (at the bottom of the sprite list)
I strongly< suggest that you clarify what you want, because your post is extremely confusing.

1) all switches always retain their states until commanded otherwise
2) you never mention what should trigger the plugin's actions
3) why aren't you simply using events? That is exactly what events are for, including the option to use tileset graphics (at the bottom of the sprite list)
1) I would like the switch on in the dungeon tileset and then switches off when player leaves the dungeon tileset.
2) tilesets in the database? The notes section. <TileSwitch: x, off, keep> is pretty much standard note format I think. Tileswitch being the standard game switch.e.g 1 or 2 or 233 etc.
3) I have 135 maps and counting. Only about 10 tilesets in database. This would be a much better way to add these common switch states to maps I think.
) tilesets in the database?
tilesets in the database do not trigger anything.
a trigger is an action by the player - what does the player have to do to trigger whatever effects the plugin should have?

I would like the switch on in the dungeon tileset and then switches off when player leaves the dungeon tileset.
then add a control switch command to the transfer events that would transfer the player in or out

I have 135 maps and counting. Only about 10 tilesets in database. This would be a much better way to add these common switch states to maps I think.
right - asking a programmer for half a dozen hours of work for free to replace something you could do in one minute per map is a better way, because it is not your time that is used here...
Sorry about the sarcasm, but those of us who help for free would at least like to have the people requesting our help aknowledge that we are spending hoursa helping for free instead of working on our own project.

yes, a lot of people are willing to program plugins for free to help the community - but only if the result of that work is really helping everyone.
But for convenience effects that do nothing but make a few people spent a few minutes less on a game project that usually needs hundreds of hours, I think you should post that in classifieds and pay someone for it (my opinion)
tilesets in the database do not trigger anything.
a trigger is an action by the player - what does the player have to do to trigger whatever effects the plugin should have?


then add a control switch command to the transfer events that would transfer the player in or out


right - asking a programmer for half a dozen hours of work for free to replace something you could do in one minute per map is a better way, because it is not your time that is used here...
Sorry about the sarcasm, but those of us who help for free would at least like to have the people requesting our help aknowledge that we are spending hoursa helping for free instead of working on our own project.

yes, a lot of people are willing to program plugins for free to help the community - but only if the result of that work is really helping everyone.
But for convenience effects that do nothing but make a few people spent a few minutes less on a game project that usually needs hundreds of hours, I think you should post that in classifieds and pay someone for it (my opinion)

def y its in requests not youhavetos . And yes i usually pay for things that just help me . this doesn't count as that. bigger projects would appreciate it. thanks. and maybe the below code could help cut down on their hours of work. dunno . its buggy.


Code:
//=============================================================================
// TilesetSwitches.js
//=============================================================================
/*:
 * @plugindesc Activates switches based on tileset notetags for the current map.
 * @author BMP Games
 *
 * @help
 * This plugin activates switches based on notetags in the tileset notes for the current map.
 *
 * To set up, create notetags in the tileset notes in the following format:
 * <TileSwitch: x, on, keep>
 * or
 * <TileSwitch: x, on, dontkeep>
 * or
 * <TileSwitch: x, off, keep>
 * or
 * <TileSwitch: x, off, dontkeep>
 *
 * Where 'x' is the switch ID to activate or deactivate. Use 'keep' to retain the switch state when moving to the next map, or 'dontkeep' to not retain the switch state.
 */

(function() {
    var _Game_Map_setup = Game_Map.prototype.setup;
    Game_Map.prototype.setup = function(mapId) {
        _Game_Map_setup.call(this, mapId);
        this.activateSwitchesOnTiles();
    };

    Game_Map.prototype.activateSwitchesOnTiles = function() {
        var tileset = $dataTilesets[$gameMap.tilesetId];
        var mapMeta = $dataMap.meta;
        var tilesetMeta = tileset.meta;

        if (mapMeta) {
            if (mapMeta["tileSwitches"]) {
                this.processTileSwitches(mapMeta["tileSwitches"]);
            }
        }

        if (tilesetMeta) {
            if (tilesetMeta["tileSwitches"]) {
                this.processTileSwitches(tilesetMeta["tileSwitches"]);
            }
        }
    };

    Game_Map.prototype.processTileSwitches = function(noteData) {
        var switchData = noteData.split(/\r?\n/);
        for (var i = 0; i < switchData.length; i++) {
            var note = switchData[i];
            var match = /(\d+),\s*(on|off),\s*(keep|dontkeep)/i.exec(note);

            if (match) {
                var switchId = Number(match[1]);
                var state = match[2].toLowerCase() === 'on';
                var shouldKeep = match[3].toLowerCase() === 'keep';

                if (shouldKeep) {
                    $gameSwitches.setValue(switchId, state);
                } else {
                    $gameSwitches.setValue(switchId, !state);
                }
            }
        }
    };
})();
In the amount of time that's passed since you started this thread, you could already be done setting up switches on most, if not all, of your maps.
In the amount of time that's passed since you started this thread, you could already be done setting up switches on most, if not all, of your maps.
What am I missing here.. this is a request forum I think I did my part. You two are what? The ridicule crew?
You're not wrong for requesting.

I think the other replies were simply pointing out that this is easily doable by you without needing a plugin at all, which is absolutely true.

It's also possible that whatever you're using this for could be streamlined without having to touch anything on your 135 maps.

For example, in whatever event is actually referencing these switches, you could just replace the Conditional Branch that checks for a switch to be active with the script call to see what the tileset is.

e.g.
Conditional Branch -> Script -> $gameMap.tilesetId()==4

Is the code above AI-generated? That's pretty much never useful - I gave it a read through and it doesn't look like it would come close to correctly doing what you described you want.
this is a request forum I think I did my part.
no, you did not - your request is still incomplete.

you still haven't answered the question on WHEN the plugin should change those switches.
If you do not specify what should happen to cause the plugin to change the switches, then the switches will never change and the plugin will be useless.
You're not wrong for requesting.

I think the other replies were simply pointing out that this is easily doable by you without needing a plugin at all, which is absolutely true.

It's also possible that whatever you're using this for could be streamlined without having to touch anything on your 135 maps.

For example, in whatever event is actually referencing these switches, you could just replace the Conditional Branch that checks for a switch to be active with the script call to see what the tileset is.

e.g.
Conditional Branch -> Script -> $gameMap.tilesetId()==4

Is the code above AI-generated? That's pretty much never useful - I gave it a read through and it doesn't look like it would come close to correctly doing what you described you want.
Mmm thanks. yes ur smart .

I did actually have one common event that runs on every Map . But it runs once only the whole game... If i understood you right. maybe I could use the ones that run each time user is on map... then just put the tileset logic in the common event.

I'm trying to specify if dungeon switch is on then this is the map a user can place a small fire.

thanks will see if I can use any of that to streamline the process.
you still haven't answered the question on WHEN the plugin should change those switches.
That was answered in Post #3 - you seemed to understand it at the time, because in Post #4 you suggested an alternate way to do it via eventing.

Granted, the incorrect terminology of "on in tileset" and "leave the tileset" was used rather than referring to "maps using that tileset," but the intent seems clear to me.
you still didn't explain the "WHEN" part Andar suggested, is it saved on saving the game, revert on transfer
between maps, revert back on saving if its not set to "notKeep" or on keep etc.

because if it is, that function doesn't exist in your plugin either, so there is alot of part missing to make
it work the way you want it to work though.

more details, better explaination can get you futher and faster on the right direction.
What am I missing here.. this is a request forum I think I did my part. You two are what? The ridicule crew?
I never ridiculed you. You'd absolutely know if I decided to do that. Only thing I pointed out was that you could've already potentially had this done through eventing. Don't know why you're so defensive about someone mentioning that.
@ATT_Turan no, I made a guess on one of the possibilities what he could have meant, but that guess was never explicitly confirmed - and there have been cases where similar guesses were wrong before.
In one very bad case even to the point that a programmer wrote the wrong plugin and then rewrote it wrong two more times because whenever he presented it the requester of that old case had another "no, that is not what I meant - it has to do xy in addition".
Seems like this could be done with one of the many plugins that run a script or common event on map change and just using the conditional ATT_Turan posted:
Conditional Branch -> Script -> $gameMap.tilesetId()==4

Like this one

Or you can use CT_Bolt's ObjectsEx which runs scripts when a predefined variable is changed

Seems like this could be done with one of the many plugins that run a script or common event on map change and just using the conditional ATT_Turan posted:
Conditional Branch -> Script -> $gameMap.tilesetId()==4
I have the Yep common events one I believe for on map load and menu exit etc. I will probably use those to do this sounds like my best bet with no plugin.

Before this thread I wasn't Thinking about all that so thanks! Will get right on that wen I get back on a pc .
you still didn't explain the "WHEN" part Andar suggested, is it saved on saving the game, revert on transfer
between maps, revert back on saving if its not set to "notKeep" or on keep etc.

because if it is, that function doesn't exist in your plugin either, so there is alot of part missing to make
it work the way you want it to work though.

more details, better explaination can get you futher and faster on the right direction.
On map enter and map exit check I think would be nice places to see of the tileset switches should be on or off.

Whats faster. Plugin doing this or putting it in a common event?

Since upgrading my pixi to 5 something , I have seen my game performance shoot up. I made this request thinking plugins running instead of adding to my common event may somehow keep the performance going . I could be wrong . Havent googled it yet.
in some cases, plugins can be faster in loading (also depending what plugin you use for what cause).
simple things and not to complex able to event it out can be faster, depending what the exact mechanic
is behind this (if its need to be done on each map/map transfer conditional check that needs on each
transfer, a plugin can simplified it to do it automatically for you.

but if you have switch check ON/OFF are those global (so each map has its on switch for tileset?
as I have no idea how tileset check can be done though for A1, A2 etc as it seems to be bound?

like tileset meta must be equal to mapMeta to read and draw it correctly (I can be wrong here though).
but so far I get you.

you want the following:

Using the MapMeta or TilesetMeta to switch between tileset: example:
mapMeta <draw Tileset: ocean, switchID 5, keep>
so each tileset that has ocean or have the name [ocean] in in the name draws that tileset,
where as tilesetMeta: <mapID: 11, switch 14, nokeep> and the likes?
change switch value based on keep/nokeep on game transfer (exclude saving the game)?
I doubt the performance between a plugin and a common event is going to be more than a frame of difference, but is this really a performance-important issue? All you're doing is toggling a switch that allows the player to place a fire on the map.
On map enter and map exit check I think would be nice places to see of the tileset switches should be on or off.

This plugin will run a common event on map entry and exit. Plugin file has English instructions
Whats faster. Plugin doing this or putting it in a common event?
There's no measurable difference. (human measure - obviously you can use software to measure differences in your processor down to the FLOPS)

Pretty much the only way you'd actually see any kind of performance hit from eventing something is if you're already doing something inefficient with it - running intensive commands in a loop or parallel process.

Original thread: https://forums.rpgmakerweb.com/threads/tileset-switches-plugin-request.162458/