I'm messing around with Foreground.js (one of the Kodokawa plugins) at the moment, which lets you have a second parallax layer above everything else, and is set up using meta tags in a map's "Note" box.
There's a bug with it though: it causes an error when trying to use the event test mode (right-click on an event command -> Test). In this case:
TypeError: Cannot read property 'fgName' of undefinedHaving a look at the plugin we can see where the error occurs:
Game_Map.prototype.setupForeground = function() { this._foregroundName = $dataMap.meta.fgName || ''; this._foregroundZero = ImageManager.isZeroForeground(this._foregroundName); this._foregroundLoopX = !!$dataMap.meta.fgLoopX; this._foregroundLoopY = !!$dataMap.meta.fgLoopY; this._foregroundSx = Number($dataMap.meta.fgSx) || 0; this._foregroundSy = Number($dataMap.meta.fgSy) || 0; this._foregroundX = 0; this._foregroundY = 0; };All the meta data being retrieved has fallbacks, but the $dataMap.meta object itself isn't available in event test mode! This mode just uses an empty map that's generated on the fly, and clearly it wasn't seen necessary to initialize this particular object.
My solution in this case is to add this line at the top of the method:
if (!$dataMap.meta) $dataMap.meta = {};This ensures that there is at least an empty object available so it doesn't throw errors when you try to read properties from it. But I think this is something that should be fixed in the engine itself - if you have a look at rpg_managers.js it has this method:
DataManager.makeEmptyMap = function() { $dataMap = {}; $dataMap.data = []; $dataMap.events = []; $dataMap.width = 100; $dataMap.height = 100; $dataMap.scrollType = 3;}; All it needs is an extra line with $dataMap.meta = {};
So anyway, this is just kinda a word of warning for anyone creating plugins: be sure to try out event test mode (I guess this may also apply to battle test mode depending on what the plugin does) and make sure it's working before you release your script, you might run into an unexpected error that doesn't occur normally. Otherwise it might be a pain in the ass for your users.
There's a bug with it though: it causes an error when trying to use the event test mode (right-click on an event command -> Test). In this case:
TypeError: Cannot read property 'fgName' of undefinedHaving a look at the plugin we can see where the error occurs:
Game_Map.prototype.setupForeground = function() { this._foregroundName = $dataMap.meta.fgName || ''; this._foregroundZero = ImageManager.isZeroForeground(this._foregroundName); this._foregroundLoopX = !!$dataMap.meta.fgLoopX; this._foregroundLoopY = !!$dataMap.meta.fgLoopY; this._foregroundSx = Number($dataMap.meta.fgSx) || 0; this._foregroundSy = Number($dataMap.meta.fgSy) || 0; this._foregroundX = 0; this._foregroundY = 0; };All the meta data being retrieved has fallbacks, but the $dataMap.meta object itself isn't available in event test mode! This mode just uses an empty map that's generated on the fly, and clearly it wasn't seen necessary to initialize this particular object.
My solution in this case is to add this line at the top of the method:
if (!$dataMap.meta) $dataMap.meta = {};This ensures that there is at least an empty object available so it doesn't throw errors when you try to read properties from it. But I think this is something that should be fixed in the engine itself - if you have a look at rpg_managers.js it has this method:
DataManager.makeEmptyMap = function() { $dataMap = {}; $dataMap.data = []; $dataMap.events = []; $dataMap.width = 100; $dataMap.height = 100; $dataMap.scrollType = 3;}; All it needs is an extra line with $dataMap.meta = {};
So anyway, this is just kinda a word of warning for anyone creating plugins: be sure to try out event test mode (I guess this may also apply to battle test mode depending on what the plugin does) and make sure it's working before you release your script, you might run into an unexpected error that doesn't occur normally. Otherwise it might be a pain in the ass for your users.