DeadlyEssence01 Immersive Dialogue - v1.01

DeadlyEssence01

Veteran
Veteran
Joined
Oct 19, 2019
Messages
36
Reaction score
15
First Language
English
Primarily Uses
RMMV
DE Immersive Dialogue | v1.01
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

Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,273
Reaction score
11,660
First Language
English
Primarily Uses
RMVXA
You might want to add to your terms of service something about whether people can repost the plugin or if they must link back here. I know a lot of plugin/script writers don't like possibly out of date versions of their work floating around the internet.
 

DeadlyEssence01

Veteran
Veteran
Joined
Oct 19, 2019
Messages
36
Reaction score
15
First Language
English
Primarily Uses
RMMV
Thanks! I added it to the plugin itself, but forgot to add it to the post. Edited~
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
529
Reaction score
269
First Language
thai
Primarily Uses
RMMV
I feel it's more hard to do it this way
do you have a trick to know that the text line not out of message box
in editor, it had visual but in text pad I had no Idea

and can it have more line at one time
now it need to click for every line or I miss something?
 
Last edited:

DeadlyEssence01

Veteran
Veteran
Joined
Oct 19, 2019
Messages
36
Reaction score
15
First Language
English
Primarily Uses
RMMV
@pasunna To know what line you have in the text document. I suggest using notepad++ it displays linecount on the left hand side of your document. If you're using sequential dialogue and not random, you can leave the first line blank and the numbers will match. Or, subtract 1 from the number on the left side of notepad++ to get the number to use in the plugin command.

If you want to display more than one line, you can use the "linecount" number in the plugin command. It will tell the plugin to put multiple lines of dialogue into the text box. So,

dialogue textfilename.txt 0 3
The number three will show lines 1, 2 and 3.

Or if you meant having a linebreak, like so:

//start some text
Use enter, or the line break textcode.

I hope that answers your questions!
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
529
Reaction score
269
First Language
thai
Primarily Uses
RMMV
@pasunna To know what line you have in the text document. I suggest using notepad++ it displays linecount on the left hand side of your document. If you're using sequential dialogue and not random, you can leave the first line blank and the numbers will match. Or, subtract 1 from the number on the left side of notepad++ to get the number to use in the plugin command.

If you want to display more than one line, you can use the "linecount" number in the plugin command. It will tell the plugin to put multiple lines of dialogue into the text box. So,

dialogue textfilename.txt 0 3
The number three will show lines 1, 2 and 3.

Or if you meant having a linebreak, like so:

//start some text
Use enter, or the line break textcode.

I hope that answers your questions!
no... I mean in one line if it is to long it out of the box
3.JPG
If use word warp it's ok
but I do not like that style

and the click2.JPG
1.JPG
not sure what I did wrong
I use the same comand and copy your text
Howdy
//Heyo!
//Long time no see!
//Fancy seeing you here.
but the outcome is still show one line
Thank you
 

DeadlyEssence01

Veteran
Veteran
Joined
Oct 19, 2019
Messages
36
Reaction score
15
First Language
English
Primarily Uses
RMMV
@pasunna
Oh, my apologies.
No, there is no way to know how far you can type in the text document. I typically use wordwrap myself, so I don't worry about the text getting cut off.
If you test it once, and determined the length, you could just linebreak all the rest of the entries to match the length In my example below, I assume "message" would go past the | so I just used a line break. It's not a great method though...

Also, the // separator will create a new message, not batch the text.
If you want to display a bunch of lines you just type out what you would like. Use enter or the linebreak method. So,

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.


----

v1.01 is out.
I added the ability to see the number of the random dialogue line that was displayed through a game variable.
Random dialogue doesn't repeat last used dialogue message.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

X[ oh gawd.... I dropped my super expensive laptop on my hard tile floor! It still comes on and all, but now Im worried its gunna start screwing up in the near future.... I hope not, cant afford to replace stuff like that. :(
I wrote a nice animated preloading system for mv+mz today. It only supports graphic assets atm, should it support audio too? See it in action in my recent minigame @
I posted my first commercial game on the forums, and now waiting for approval.
fingers crossed.
TMW the air quality is so bad, your hair changes color every time you wash it. :LZYyuck:
Finished two animations today. :kaojoy:

Forum statistics

Threads
103,002
Messages
996,648
Members
134,485
Latest member
olivecat
Top