2
This commit is contained in:
113
js/plugins/BatchText.js
Normal file
113
js/plugins/BatchText.js
Normal file
@@ -0,0 +1,113 @@
|
||||
//===================
|
||||
// Batch Text for MV
|
||||
//===================
|
||||
|
||||
/*:
|
||||
* @plugindesc Allows you to implement sequenced dialogue through the use of batch input.
|
||||
* @author JGreene
|
||||
*
|
||||
* @param Variable
|
||||
* @desc The variable you want to reserve for this plugin's functions.
|
||||
* @default 1
|
||||
*
|
||||
* @param WindowPosition
|
||||
* @desc Set this to the position you'd like to use. Refer to help for info.
|
||||
* @default 2
|
||||
*
|
||||
* @param Separator
|
||||
* @desc Don't change this unless you know what you're doing!
|
||||
* @default |
|
||||
*
|
||||
* @help Requires YEP_MessageCore to function properly. It is also compatible
|
||||
with Galv's Message Background. Just place this below them in your load order.
|
||||
|
||||
Each time you use the plugin command, the next message in the sequence will
|
||||
be displayed. The parameters you set up will determine where the message
|
||||
displays.
|
||||
|
||||
Window Positions:
|
||||
0 = Top
|
||||
1 = Middle
|
||||
2 = Bottom
|
||||
|
||||
All text codes are supported, except those that use the symbol reserved for
|
||||
the separator. By default, use \. several times to make up for the loss of \|
|
||||
Or, change the separator if you feel comfortable doing so.
|
||||
|
||||
For long messages, insert <WordWrap> at the beginning of the message.
|
||||
|
||||
--- Important! ---
|
||||
Be sure to place your messages in the order they need to appear in
|
||||
your game! The plugin will do the rest! You can still use the engine's
|
||||
default Show Text command separate from this plugin as normal.
|
||||
|
||||
===== SETUP Instructions =====
|
||||
|
||||
1. Create a file in your project's data folder named messages.txt
|
||||
2. Input your text lines like so:
|
||||
This is line 1.
|
||||
|This is line 2!
|
||||
|This is line 3, right?
|
||||
|Etc.
|
||||
|
||||
Note: Pressing enter will make a new line, as well as <WordWrap>. Only use
|
||||
one or the other. With word wrap, put the whole message on one line. The
|
||||
separator | has to be the first character for each new message.
|
||||
|
||||
3. Load your plugin in the editor and set up your variable and position
|
||||
4. Use the plugin command batchtext in place of messages, and the plugin
|
||||
will automatically keep track of which to play next.
|
||||
|
||||
Keep in mind, this only works for direct sequences - much like a scripted
|
||||
play or movie. However, with careful planning, you can jump to and from
|
||||
sections in your script. Furthermore, your game will error and crash if
|
||||
you use the plugin command after all the messages in your file have been
|
||||
read through. Be careful!
|
||||
|
||||
---------- Advanced ------------------
|
||||
|
||||
If you want to go out of order at any point, I would advise copying your script
|
||||
into another file, numbering each message in order, and then dividing up
|
||||
the sections by NPC/event.
|
||||
|
||||
At that point, assign each NPC/event to the proper section. When you talk to
|
||||
them, be sure the first thing that happens is a Control Variable X = Y. Where
|
||||
X is your parameter variable, and Y is the line number that they should begin
|
||||
with. Just plan accordingly so they don't end up speaking someone else's lines
|
||||
(or crashing the game).
|
||||
|
||||
--------------------------------------
|
||||
|
||||
Have any questions? Contact me --> jgreene on rpgmakerweb
|
||||
|
||||
Enjoy!
|
||||
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var parameters = PluginManager.parameters('BatchText');
|
||||
|
||||
var JG_Batch_aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;
|
||||
|
||||
Game_Interpreter.prototype.pluginCommand = function(command, args)
|
||||
{
|
||||
JG_Batch_aliasPluginCommand.call(this,command,args);
|
||||
if (command == "batchtext")
|
||||
{
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET","data/messages.txt",false);
|
||||
xhr.send(null);
|
||||
var fileContent = xhr.responseText;
|
||||
var x = parameters['Variable']
|
||||
var pos = parameters['WindowPosition']
|
||||
var dia = fileContent.split(parameters['Separator'])
|
||||
var index = $gameVariables.value(x)
|
||||
var msg = dia[index]
|
||||
$gameMessage.setPositionType(pos);
|
||||
$gameMessage.add(msg);
|
||||
this.setWaitMode('message');
|
||||
$gameVariables.setValue(x, index+1);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user