random title (under development)

ok so i found that to be a bit of help but now im at my noobie limit this is what i got out of it, maybe someone could tell me why i cant get it to run like the simple bite im trying to replace.

Spoiler
/****************************************
 TitleScreenRandomImgSelector.js
****************************************/

/*:
 * @plugindesc Displays a random background image for the title screen.
 * @author WorldWakeSTU
 *
 * @param TitleScreenCount
 * @desc The number of images used for random selection on the title scene.
 * @default 0
 */
/*******************************************************************************
*         Rpg_Scene.js rip
*******************************************************************************/
Scene_Title.prototype.createBackground = function () {

    this.backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
    this.addChild(this.backSprite2);
/*******************************************************************************
*        WorldWakeSTU personal patch (scripting style from Liquidize anima_manyLoadingScreen)
*******************************************************************************/              
var parameters = PluginManager.parameters('TitleScreenRandomImgSelector');
var TitleScreenCount = Number(parameters.TitleScreenCount || 0);
if (TitleScreenCount > 0) {
    var random = Math.floor(Math.random() * (TitleScreenCount - 0 + 1));
        if (random > 0) {
        this._backSprite1 = new Sprite('img/title1/Title' + random + '.png');   //  <<< after an alert test this said im not a sprite so you cant set my //x(what the @#$%&* (excuse me while I beat my head against the wall.) how is [new Sprite] not a sprite!)
        this.addChild(this._backSprite1);
              } else {
                        this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
                        this.addChild(this._backSprite1);
                 }
         }
};
/************************************************************

*          core > Rpg_scene.js > Scene_Title

************************************************************/

this is what im replaceing

Spoiler
Scene_Title.prototype.createBackground = function() {
    this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
    this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
    this.addChild(this._backSprite1);
    this.addChild(this._backSprite2);
};
it feeds but gives me the database choice and ignores or errors as undefined.

the console shows this:

Spoiler
TypeError: undefined is not a function
    at Sprite.Object.defineProperty.set (rpg_core.js:3223)
    at Sprite.initialize (rpg_core.js:3202)
    at new Sprite (rpg_core.js:3178)
    at Scene_Title.createBackground (TitleScreenRandomImgSelector.js:28)
    at Scene_Title.create (rpg_scenes.js:246)
    at Function.SceneManager.changeScene (rpg_managers.js:1654)
    at Function.SceneManager.updateMain (rpg_managers.js:1640)
    at Function.SceneManager.update (rpg_managers.js:1576)
@WorldWakeSTU,

Aren't you supposed to pass bitmap instead of path as Sprite's constructor argument?

Code:
this._backSprite1 = new Sprite('img/title1/Title' + random + '.png');// tothis._backSprite1 = new Sprite(ImageManager.loadTitle1('Title' + random);
@ Mr. Trivel: have tried your way and the script is completely ignored, i cant even get it to throw the alert tester.
@WorldWakeSTU,

Something like this works perfectly for me:

Spoiler
Code:
//=============================================================================// MrTS_RandomRandomTS.js//=============================================================================/*:* @plugindesc Random title screen script.* @author Mr. Trivel** @param Title Screens* @desc How many different title screens you have?* Default: 5* @default 5* * @help * --------------------------------------------------------------------------------* Free for non commercial and non-commercial use.* Version 1.0* --------------------------------------------------------------------------------** --------------------------------------------------------------------------------* Required Files* --------------------------------------------------------------------------------* "img\titles1\Title#.png" - # being number of title screen starting from 1.** --------------------------------------------------------------------------------* Version History* --------------------------------------------------------------------------------* 1.0 - Release*/(function() {	var parameters = PluginManager.parameters('MrTS_RandomRandomTS');	var paramRandomTotal = Number(parameters['Title Screens'] || 5);	Scene_Title.prototype.createBackground = function() {		var r = Math.floor((Math.random() * paramRandomTotal) + 1);	    this._backSprite1 = new Sprite(ImageManager.loadTitle1("Title" + r));	    this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));	    this.addChild(this._backSprite1);	    this.addChild(this._backSprite2);	};})(); 
ok so yours was simpler than mine. it did work except with less than 5 it will eventually throw and error for file not found. even with tweaks to the default and the || on paramRandomTotal it fails or find an empty page. if it had support for a min of 2 with no max it would be perfect. thank you for looking at this for me.
why don't you make a list of array to load from instead of random number?

If there's an error, it's the user fault not your script.

Spoiler
Code:
//=============================================================================// MrTS_RandomRandomTS.js//=============================================================================/*:* @plugindesc Random title screen script.* @author Mr. Trivel** @param Title Screens* @desc The title screen name you want to random.* Default: castle,demoncastle,Crystal* @default castle,demoncastle,crystal* * @help * --------------------------------------------------------------------------------* Free for commercial and non-commercial use.* Version 1.0* --------------------------------------------------------------------------------** --------------------------------------------------------------------------------* Required Files* --------------------------------------------------------------------------------* List in Array.** --------------------------------------------------------------------------------* Version History* --------------------------------------------------------------------------------* 1.0 - Release*/(function() {	var parameters = PluginManager.parameters('MrTS_RandomRandomTS');	var paramImgArray = parameters['Title Screens'].split(/\s*,\s*/) || ['castle','demoncastle','crystal'];	Scene_Title.prototype.createBackground = function() {		this._backSprite1 = new Sprite(ImageManager.loadTitle1(paramImgArray[Math.randomInt(paramImgArray.length)]));	    this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));	    this.addChild(this._backSprite1);	    this.addChild(this._backSprite2);	};})();  

Original thread: https://forums.rpgmakerweb.com/threads/random-title-under-development.51849/