CRG Random Text - random text when clicking on events

Tommy Gun

♩ ♪ ♫ ♬
Veteran
Joined
Jan 20, 2014
Messages
385
Reaction score
123
First Language
English
This is my very first MV plug-in, and I need some feedback/help!

What it does: This lets you write a bunch of different descriptions, dialogue, etc. for various events, and have them randomly displayed when clicked. For instance, I can write multiple descriptions of a crystal, and then every time you click on a crystal (that uses the plug-in command), it will give you one of the descriptions randomly. You can have characters say different dialogue to you each time you talk to them, and so on. See the script help file for more info, and examples.

There are parameters to change window position, face graphic, etc. You can also override these in each event.

You have to edit the script itself to add your text -- adding it all in parameters would be incredibly tedious and limiting.

Everything works as intended, but I don't know if this is the best way to do it. Any serious problems here? Is it okay to use "switch" for this? Is there a more efficient method? If I have hundreds of "objects" is that going to be a problem? Other thoughts?

 *** THIS IS IN PROGRESS *** Use at your own risk. I may radically rewrite this script, and you will need to redo your changes with different code.

Code:
//=============================================================================// CRG_RandomText.js//=============================================================================/*: * @plugindesc v1.02 Displays random text when clicking on an event. * @author Tommy Gun * * @help  * * You need to manually edit this script and add your objects (or whatever you * want the player to click on) and your text. You can add any number of  * sentences, and any number of objects (create a new "case" for each one). *  * Then add the plug-in command "RandomText object" (without quotes)  to each  * event, and replace "object" with the name you used in the script. * * Example: RandomText candles * * You can also use the shorter version "rt object" if you prefer. * * You can override the default parameters in two ways: * 1) use the Advanced Template to change options in the script * 2) pass the arguments in the plug-in command (which will also override #1), * in this format:  * RandomText object Background WindowPos NameBox ShowFace FaceName FaceNum * * Example: RandomText candles 1 1 none true Actor3 4 * * If you leave out any at the end, the default values will be used. * * Example: RandomText candles 1 1 none true * In this case Actor1 would be shown, or whatever you have set. * * Name Box: You must have Yanfly Message Core installed. To disable, leave * blank or type "none" or 0. Underscores will get converted into spaces * when used in the plug-in command. * Example: Tommy_Gun * * Word Wrap: You must install a separate plug-in, then add the tag they use. * Yanfly Message Core: <WordWrap> * Yami: <wrap> * You can also leave it blank to disable word wrap. * * @param Background * @desc [0 = window, 1 = dim, 2 = transparent] * @default 1 * * @param Window Position * @desc [0 = top, 1 = middle, 2 = bottom] * @default 1 * * @param Name Box * @desc Requires Yanfly Message Core! Type a name to show in the name box or use "none" to disable. Example: Tommy * @default none * * @param Show Face * @desc Displays a face graphic. [true/false] * @default false * * @param Face Name * @desc Type the name of the face graphic. Example: Actor1 * @default Actor1 * * @param Face Number * @desc Type the number of the face graphic [0-3 top row, 4-7 bottom row] * @default 0 * * @param Word Wrap Tag * @desc Requires another plug-in! Yanfly Message Core: <WordWrap> / Yami: <wrap> * @default  * */(function() {    var parameters = PluginManager.parameters('CRG_RandomText');        // Parameters    var backgroundParam = Number(parameters['Background'] || 1);    var windowPositionParam = Number(parameters['Window Position'] || 1);    var nameBoxParam = String(parameters['Name Box'] || 'none');    var showFaceParam = String(parameters['Show Face'] || 'false');    var faceNameParam = String(parameters['Face Name'] || 'Actor1');    var faceNumberParam = Number(parameters['Face Number'] || 0);    var wordWrapTagParam = String(parameters['Word Wrap Tag'] || '');        var _Game_Interpreter_pluginCommand =            Game_Interpreter.prototype.pluginCommand;    Game_Interpreter.prototype.pluginCommand = function(command, args) {        _Game_Interpreter_pluginCommand.call(this, command, args);        if (command === 'RandomText' || command === 'rt' ) {            switch (args[0]) {                        	    /* ## OBJECT TEMPLATE - copy and paste below to add more objects ##  	                case 'NameHere':		var object = [		"", 		"", 		"", 		""];                break;                           ## ADVANCED TEMPLATE TO OVERRIDE PARAMETERS - you can delete the lines you don't need to override ##                       case 'NameHere':		var backgroundCase =     '0';		var windowPositionCase = '0';		var nameBoxCase =        '';		var showFaceCase =       'true';		var faceNameCase =       'Actor1';		var faceNumberCase =     '0';		var object = [		"", 		"", 		"", 		""];                break;                            ###### ADD OBJECTS BELOW HERE ###### */                          case 'candles':        	var object = [		"There are three candles burning brightly.", 		"A candle holder with three lit candles.", 		"These candles look like they've been recently lit.", 		"Let us bask in its warm, glowing, warming glow."];                break;                                                                            /* ###### DO NOT EDIT PAST HERE ###### */                            }                                    		// Load arguments, case settings, or parameters		var background = Number(args[1] || backgroundCase || backgroundParam);		var windowPosition = Number(args[2] || windowPositionCase || windowPositionParam);		var nameBox = String(args[3] || nameBoxCase || nameBoxParam);		var showFace = String(args[4] || showFaceCase || showFaceParam);		var faceName = String(args[5] || faceNameCase || faceNameParam);		var faceNumber = Number(args[6] || faceNumberCase || faceNumberParam);		// Check name box, convert underscores to spaces		if (nameBox == 'none' || nameBox == 0) {			nameBox = '';		} else {			nameBox = "\\n<" + nameBox.replace(/_/g,' ') + ">";		}		// Select random sentence		var randomText = object[Math.floor(Math.random() * object.length)];				// Create Message		if (showFace === 'true') {			$gameMessage.setFaceImage(faceName,faceNumber);		}		$gameMessage.setBackground(background);		$gameMessage.setPositionType(windowPosition);		$gameMessage.add(nameBox + wordWrapTagParam + randomText);		        }    };})();
 
 
Last edited by a moderator:

SzymeQx

Warper
Member
Joined
Sep 25, 2015
Messages
1
Reaction score
0
First Language
Polish
Take screens, please :/

And thanks! ;)
 

Tommy Gun

♩ ♪ ♫ ♬
Veteran
Joined
Jan 20, 2014
Messages
385
Reaction score
123
First Language
English
Oh, I will, and I'll make a video, because it's much easier to explain how useful it is that way. But right now I just want to make sure I didn't code it in some really stupid way, so I want some JS experts to take a look.
 

wsensor

Villager
Member
Joined
May 2, 2012
Messages
20
Reaction score
5
First Language
English
Primarily Uses
Maybe the option to load the text from an external file or files?
 

Tommy Gun

♩ ♪ ♫ ♬
Veteran
Joined
Jan 20, 2014
Messages
385
Reaction score
123
First Language
English
Oh, that's a great idea, as it would let me update the plug-in without killing everyone's changes. Is that possible? That might be over my head.
 

wsensor

Villager
Member
Joined
May 2, 2012
Messages
20
Reaction score
5
First Language
English
Primarily Uses
There is a plugin called [RMMV] External Text

That was made by Zelerinian that might help you.

If that does not work you could always add a feature for it to use the Script function on tab 3 in the event editor.
 

Tommy Gun

♩ ♪ ♫ ♬
Veteran
Joined
Jan 20, 2014
Messages
385
Reaction score
123
First Language
English
Updated with the newest version. I added some new features and changed the format a little. I'm still looking into getting an external file working, but I have other stuff to do first.
 

teachpriest

Warper
Member
Joined
Feb 19, 2019
Messages
4
Reaction score
0
First Language
english
Primarily Uses
RMMV
Updated with the newest version. I added some new features and changed the format a little. I'm still looking into getting an external file working, but I have other stuff to do first.
Hello Mr gun I am a high school student trying to make a game. I'm trying to use this random text plugin. but I'm not sure how it works and was wondering if I could get some help to understand it.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top