Hello there,
the basic idea of this plug-in is that you can determine switches to be automatically turned on/off depending on the tilesets id. And make it possible to set these switches and tilesets in the parameter setting to make entire development process much smoother.
If there is a similar plug-in, I'll be glad to know about that. and here is the part where I got stuck to implement:
1) how can I check if the parameter conditions are met, and perform the logic without less memory leakage.
thank you!
the basic idea of this plug-in is that you can determine switches to be automatically turned on/off depending on the tilesets id. And make it possible to set these switches and tilesets in the parameter setting to make entire development process much smoother.
If there is a similar plug-in, I'll be glad to know about that. and here is the part where I got stuck to implement:
1) how can I check if the parameter conditions are met, and perform the logic without less memory leakage.
/*: * @plugindesc Toggle switches based on the player's current tileset ID. * @param OnSwitches * @type struct<SwitchTileset>[] * @default [] * @param OffSwitches * @type struct<SwitchTileset>[] * @default [] *//*~struct~SwitchTileset: * @param SwitchID * @type switch * @desc The switch ID to be toggled. * @param TilesetIDs * @type string * @desc Tileset IDs separated by commas. Use hyphen for range (e.g., "1,3" or "1-3"). */(function() { var parameters = PluginManager.parameters('TilesetSwitches'); var onSwitches = JSON.parse(parameters['OnSwitches'] || '[]').map(JSON.parse); var offSwitches = JSON.parse(parameters['OffSwitches'] || '[]').map(JSON.parse); var _Game_Map_update = Game_Map.prototype.update; Game_Map.prototype.update = function(sceneActive) { _Game_Map_update.call(this, sceneActive); this.updateSwitches(); }; Game_Map.prototype.updateSwitches = function() { var tilesetId = $gameMap.tilesetId(); console.log('Current Tileset ID:', tilesetId); // Process OnSwitches onSwitches.forEach(function(setting) { if (checkTilesetMatch(tilesetId, setting.TilesetIDs)) { console.log('Turning on switch:', setting.SwitchID); $gameSwitches.setValue(Number(setting.SwitchID), true); } }); // Process OffSwitches offSwitches.forEach(function(setting) { if (checkTilesetMatch(tilesetId, setting.TilesetIDs)) { console.log('Turning off switch:', setting.SwitchID); $gameSwitches.setValue(Number(setting.SwitchID), false); } }); }; function checkTilesetMatch(tilesetId, tilesetIDs) { var ranges = tilesetIDs.split(','); return ranges.some(function(range) { if (range.includes('-')) { var bounds = range.split('-').map(Number); return tilesetId >= bounds[0] && tilesetId <= bounds[1]; } else { return tilesetId == Number(range); } }); }})();thank you!