- Joined
- Oct 19, 2019
- Messages
- 36
- Reaction score
- 15
- First Language
- English
- Primarily Uses
- RMMV
DE Immersive Dialogue | v1.01
DeadlyEssence
DeadlyEssence
Introduction
This plugin allows for implementation of random or sequential dialogue pulled from a txt file so you can easily create a batch text / random text. You can specify subfolders and file names, so each command can have a different text file it reads from.You can use yanfly's text codes and macros with this plugin, I have a long plugin list and have not found an incompatibility or issue yet.
Updates:
v1.01 - Random Dialogue doesn't repeat.
- Added an optional parameter to know which random message the plugin displayed.
Features
- Read a txt file of dialogue.
- Plugin command allows you to specify different files for each command / and pull text files from subfolders.
- Pull random dialogue from a list of options.
- Does support using face images.
- Is compatible with most? of Yanfly's plugins.
- Random dialogue doesn't repeat last used dialogue message.
- Show message number of displayed random dialogue
How to Use
Download the .js and put it in your plugins folder for your project.
You do not have to set the parameters if you don't want to...
If you want to know which message was displayed when using random dialogue, set a gamevariable in the parameters for "dialogue variable" the plugin will push the message number it displayed to your variable to allow for eventing checks.
1. Create a new folder in your project's data folder, name it dialogue.
2. Create a new text file, do not use spaces. The file name will be needed for the plugin command.
3. Insert your dialogue, being sure to use "//" to separate messages.
EX: (you can copy and paste below if you need...)
Howdy
//Heyo!
//Long time no see!
//Fancy seeing you here.
Or batched text: (without word wrap that should fit in the box)
This is the very first message, that appears in the
message box. And here is some filler continuation
words. You can go beyond the four lines of text
for this, it will automatically batch the text for
you so that it shows.
//And this is message two.
Note: Pressing enter will make a new line break, or you can use Yanfly's <WordWrap>. With word wrap, you can just put the whole message on a single line.
Using Subfolders:
If you'd like to use subfolders, your filename should preface with the subfolder name and a / before the actual filename.
Ex: subfolder/EnoAmsir.txt
Ex: newfolder/HaroldDialogue.txt
Plugin Commands:
Sequential Dialogue Command
Dialogue will read the dialogue in order, for the number of lines specified.
dialogue [FILENAME.txt][lineNumber] [lineCount] [faceImage filename] [faceIndex number]
EX: dialogue NiraAmosirNeutral.txt 0 3 NiraAmosirFace 0
EX: dialogue Gossip.txt 0 3
- Filename should be the name of the .txt file you are trying to pull from the dialogue folder. Be sure to include .txt or it will not work.
- LineNumber is the line of text you want to start on. 0 is the first line!
- LineCount is the number of lines to read. 0 will only show the line specified in lineNumber. 1 will read the next line in the file too.
- Faces: If you want a face image to appear put the name of the file, without the .png. The face index is the number slot the face appears in on the png file. Remember, the left top is 0, not 1.
- If you don't want to count lines, I suggest using Notepad++ it will automatically number the lines for you. However, subtract one from the number on the left.
Random Dialogue Command:
Random dialogue will give you a random response from your text file.
randomdialogue [FILENAME.txt] [faceImage FILENAME] [faceIndex number]
EX: randomdialogue Introductions.txt
EX: randomdialogue Introductions.txt NiraAmosirFace 0
EX: randomdialogue HaroldDialogue.txt Actor1 0
- Filename should be the name of the .txt file you are trying to pull from the dialogue folder.
- Faces: If you want a face image to appear put the name of the file, without the .png. The face index is the number slot the face appears in on the png file. Remember, the left top is 0, not 1.
Script
Code:
//===================
// DeadlyEssence01 Immersive Dialogue v1.01
//===================
var Imported = Imported || {} ;
Imported.DE_ImmersiveDialogue = true;
var DE_ImmersiveDialogue = DE_ImmersiveDialogue || {} ;
DE_ImmersiveDialogue.version = 1.01;
/*:
*
*@plugindesc Allows for random or sequential dialogue through a txt file. Easily batch or randomize text.
* @author DeadlyEssence01
*
* @param Dialogue Variable
* @type variable
* @desc If using random dialogue, the plugin will print the random message number chosen to your determined variable. 0 = not in use.
* @default 0
*
* @help
*===================
* Info:
*===================
*
* This plugin is compatible with (I believe) all of Yanfly's plugins.
* All text codes are supported. You also have the ability to use <WordWrap> from Yanfly's messagecore. This plugin should be put after Yanfly's to use Yanfly's textcodes.
*
*===================
*Instructions:
*===================
*
* 1. Create a new folder in your project's data folder, name it dialogue.
* 2. Create a new text file, do not use spaces. the file name (including .txt) will be needed for the plugin command.
* 3. Create your dialogue.
*
*Input your text in the new text file:
* Howdy
* //Heyo!
* //How are you doing???
*
* Note: Pressing enter will make a new line break, or you can use Yanfly's <WordWrap>. With word wrap, you can just put the whole message on a single line.
* Make sure to start each new message with //
*
* SUBFOLDERS:
* If you'd like to use subfolders, your filename should preface with the subfolder name and a / before the actual filename.
* Ex: subfolder/EnoAmsir.txt
* Ex: newfolder/HaroldDialogue.txt
*
*Some uses for this plugin...
*
*Create generic text for citizens, put all generic intros in an intro file, and let the plugin pull a random one. Just specify the actor image in the event's plugin commmand. Event all * your conditional statements.
*
*Give characters more depth by giving them their own random dialogue file. For extra depth, set conditional branches on various game variables to pull different dialogue files.
*
*
*===================
*Plugin Commands:
*===================
* --------------
* dialogue [FILENAME.txt][lineNumber] [lineCount] [faceImage filename] [faceIndex number]
* --------------
*
* EX: dialogue NiraAmosirNeutral.txt 0 3 NiraAmosirFace 0
* EX: dialogue Gossip.txt 0 3
*
* dialogue will read the dialogue in order, for the number of lines specified.
*
* Filename should be the name of the .txt file you are trying to pull from the dialogue folder. Be sure to include .txt or it will not work.
* lineNumber is the line of text you want to start on. 0 is the first line! line count is the number of lines to read. 0 will only show the line specified in lineNumber. 1 will read the * next line in the file * too.
* If you want a face image to appear put the name of the file, without the .png. The face index is the number slot the face appears in on the png file. Remember, the left top is 0, not 1.
*
* If you don't want to count lines, I suggest using Notepad++ it will automatically number the lines for you. However, subtract one from the number on the left.
*
* OR
* --------------
* randomdialogue [FILENAME.txt] [faceImage FILENAME] [faceIndex number]
* ---------------
*
* EX: randomdialogue Introductions.txt
* EX: randomdialogue Introductions.txt NiraAmosirFace 0
* EX: randomdialogue HaroldDialogue.txt Actor1 0
*
* Random dialogue will give you a random response from your text file.
*
* Filename should be the name of the .txt file you are trying to pull from the dialogue folder.
* If you want a face image to appear put the name of the file, without the .png. The face index is the number slot the face appears in on the png file. Remember, the left top is 0, not 1.
*
*
*===================
*Terms of Use:
*===================
*
* Free for commercial or non-commercial projects.
* You may edit this plugin to fit your needs, but please do not redistribute it. You may make an extension plugin and link it in the forums if you'd like to share changes/alterations.
*
*===================
*Changelog
*===================
*
*
* v1.01 No more repeated randoms. Added variable to display number of random message shown.
* v1.00 Released plugin!
*
*/
(function() {
"use strict"
var _params = PluginManager.parameters('DE_ImmersiveDialogue');
var _dialoguevariable = Number(_params['Dialogue Variable']) || 0;
var _lastUsedRandom;
var DE_ImmersiveD_PluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args)
{
DE_ImmersiveD_PluginCommand.call(this,command,args);
if (command === 'randomdialogue') {
var filename = String(args[0]);
var faceImage = String(args[1]);
var faceIndex = parseInt(args[2]);
var xhr = new XMLHttpRequest();
xhr.open("GET","data/dialogue/" + filename, false);
xhr.send(null);
var fileContent = xhr.responseText;
//divide up the txt file into an array based on //
var dia = fileContent.split("//")
//set face image if there
if (args.length > 1) {
$gameMessage.setFaceImage(faceImage, faceIndex);
}
//Choose and display random dialogue message.
var line = Math.randomInt(dia.length); if (_lastUsedRandom === line) { if (line + 1 > dia.length) {--line;} else if (line - 1 < 0) {++line; } else { line + 1; } }
var msg = dia[line];
this.setWaitMode('message');
$gameMessage.add(msg);
setDialogueVariable(line);
_lastUsedRandom = line;
} //end if random dialogue command
if (command === 'dialogue') {
var filename = String(args[0]);
var line = parseInt(args[1]);
var lineCount = parseInt(args[2]);
var faceImage = String(args[3]);
var faceIndex = parseInt(args[4]);
var xhr = new XMLHttpRequest();
xhr.open("GET","data/dialogue/" + filename, false);
xhr.send(null);
var fileContent = xhr.responseText;
//divide up the txt file into an array based on //
var dia = fileContent.split("//")
//check for line exists
if (line > dia.length) {
console.log("Immersive Dialogue Plugin: Your line does not exist. Please specify a correct line number.");
}
if (args.length > 3) {
$gameMessage.setFaceImage(faceImage, faceIndex);
}
if (lineCount !== 0) {
if (line + lineCount > dia.length) {console.log("Your lineCount exceeds your dialogue entries. Please change your lineCount.") }
for (var i = 0; i <= lineCount; i++) {
var msg = dia[line];
this.setWaitMode('message');
$gameMessage.newPage();
$gameMessage.add(msg);
line++;
}
}
else {
var msg = dia[line];
this.setWaitMode('message');
$gameMessage.add(msg);
}
}// end if command = dialogue
} //end game_interpreter
function setDialogueVariable(line) {
if (_dialoguevariable !== 0) {
$gameVariables.setValue(_dialoguevariable, line);
}
}
})();
FAQ
None yet...
Q:
A:
Credit and Thanks
- DeadlyEssence01
Terms of Use
This plugin is free for both non-commercial and commercial use.
You can give me credit as DeadlyEssence01 if you'd like.
You may edit this plugin to fit your needs, but please do not redistribute it. You may make an extension plugin and link it in the forums if you'd like to share changes/alterations.
Author's Notes
This plugin comes how it is. I may not update it at all, or provide support for it I am just deciding to share a resource I made for my project. However, as for right now I am open to feedback. You can try asking questions / reporting problems in this thread first, and if I do not respond, I suggest taking it to the plugin support thread and posting there.
Attachments
-
7 KB Views: 30
Last edited:





