Servus,
ich darf euch mein erstes komplett geschriebene Plugin vorstellen
(Ohne die Hilfe von Mr. Fu und Boros , die meine ständigen Fragen erdulden mussten hätte ich es wahrscheinlich nicht hinbekommen - Tat mich voll schwer es als "Ordentliches Plugin" [Benutzerfreundlich] zu erstellen
- Danke euch noch einmal hier )
Lange Rede kurzer Sinn - Das Plugin benötigt ein Core-Plugin, der die Sprache anpasst und ein Sprach-Plugin, welches als Database dient.
Die Namen dieser Plugins müssen fix sein:
Core-Plugin -> Sprache-Core
Database-Plugin(s) -> Sprache-1; Sprache-2; Sprache-3; Sprache-4; Sprache-5
(Ja es sind bis 5 Sprachen möglich)
Um die Sprache nun zu integrieren werden folgende Befehle verwendet:
<#> Bei der gesamten Datenbank, egal ob es sich im einen Skill/ Item - Namen oder ne Beschreibung handelt
<#,"Folder #"> Für "Zeige Nachricht" oder dem Auswahlfenster
# bedeutet immer die ID
Die Datenbank ist selbst ist in Sub-Kategorien aufgeteilt um mögliche Performance-Einbußen entgegen zu wirken, daher auch bei Nachrichten mehrere Folder
Wer Fit ist mit Plugins schreiben kann gerne mal auch Inhaltlich drüber schauen und mir mitteilen wo ich was besser hätte machen können
Ich habe das Plugin nun wesentlich kompakter und Benutzerfreundlicher gemacht
Die Hauptänderung ist nun, dass es keine 2 Plugins benötigt jedoch nur noch sich selbst
Die Daten die benötigt werden, müssten im Ordner "Data" im Unterordner "Sprache-X" wobei X gleich die ID der Sprache ist.
In diesem Ordner werden dann die 9 Sprachdateien als *.txt Datei benötigt
- /*:
- @plugindesc Multi-Language Plugin by Firemaster640
- @author Firemaster640
- @help
- ############################################################################
- ############### Attention! Attention! Attention! Attention! ###############
- ############################################################################
- # To use this plugin, the name of the plugin must be: 'Multi-Lang.js'. #
- # Additionally, the language files must be located in '/data/Language-X', #
- # where X represents the ID of the language. The following *.txt files will#
- # be required in this folder: #
- # - battle.txt #
- # - classes.txt #
- # - commands.txt #
- # - costum.txt #
- # - enemy.txt #
- # - help.txt #
- # - items.txt #
- # - messages.txt #
- # - term.txt #
- ############################################################################
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~~~~~~~~~~~~~~~~~~~~~~~~~ Description: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ This plugin allows multiple languages to be easily added to the game. To ~
- ~ add a language to an area, simply add <X>, where X represents the line ~
- ~ of the *.txt file. These are mapped as follows: ~
- ~ battle.txt ~
- ~ |-> Skill(Batte-Logs) ~
- ~ classes.txt ~
- ~ |-> Class (Names) ~
- ~ |-> Nicknames ~
- ~ commands.txt ~
- ~ |-> Skill-Types ~
- ~ |-> All Main Commands (For example: "New Game") ~
- ~ costum.txt ~
- ~ |-> Only by Call ~
- ~ enemy.txt ~
- ~ |-> Enemy (Names) ~
- ~ help.txt ~
- ~ |-> Descriptions of: ~
- ~ |-> Items ~
- ~ |-> Weapons ~
- ~ |-> Armors ~
- ~ |-> Skills ~
- ~ items.txt ~
- ~ |-> Names of: ~
- ~ |-> Items ~
- ~ |-> Weapons ~
- ~ |-> Armors ~
- ~ |-> Skills ~
- ~ messages.txt ~
- ~ |-> Show Text ~
- ~ |-> Show Choices ~
- ~ term.txt ~
- ~ |-> For all Vocab-Terms (For example: "Always Dash") ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ----------------------------------------------------------------------------
- ----------------------- Expert Description: --------------------------------
- ----------------------------------------------------------------------------
- - To check the language in the game, the following is checked, where X is -
- - the language ID: -
- - MULTI_LANGUAGE.langID == X -
- - -
- - To change the language in the game, this script call is required: -
- - MULTI_LANGUAGE.langID = 4; -
- - MULTI_LANGUAGE.Translation(MULTI_LANGUAGE.langID); -
- - -
- - To load entries from 'Custom', the following entry is used, where X is -
- - the line of the *.txt file. -
- - $gameMessage.add(CALLER_SPRACHE.MessageC(X)); -
- - or -
- - MULTI_LANGUAGE.costum[X] -
- - -
- - To load entries from other areas of the databases using a call, this is -
- - done as follows: -
- - MULTI_LANGUAGE.Y[X] -
- - Here, X represents the line of the *.txt file and Y represents the file -
- - name. -
- ----------------------------------------------------------------------------
- ******************************************************************************
- ******************************* Rules for use: *******************************
- ******************************************************************************
- ** Free to use in non-commercial projects, but credits must be given. **
- ** For commercial projects, a copy of the project must be provided. **
- ******************************************************************************
- * @param ------ Configs ------
- *
- * @param linebreak
- * @text Line Breaks
- * @desc The amout of Letters each Line
- * @type Struct<linebreaks>
- * @default {"breakfullwindow":"55","breakshortwindow":"40","breakhelpwindow":"50"}
- *
- *
- * @param spracheAname
- * @text Language 1 Name
- * @desc The Name of your Language
- * @type text
- *
- * @param spracheBname
- * @text Language 2 Name
- * @desc The Name of your Language
- * @type text
- *
- * @param spracheCakti
- * @text Language 3?
- * @desc Aktivate Language 3?
- * @type boolean
- * @default false
- *
- * @param spracheCname
- * @text Language 3 Name
- * @desc The Name of your Language
- * @type text
- *
- * @param spracheDakti
- * @text Language 4?
- * @desc Aktivate Language 4?
- * @type boolean
- * @default false
- *
- * @param spracheDname
- * @text Language 4 Name
- * @desc The Name of your Language
- * @type text
- *
- * @param spracheEakti
- * @text Language 5?
- * @desc Aktivate Language 5?
- * @type boolean
- * @default false
- *
- * @param spracheEname
- * @text Language 5 Name
- * @desc The Name of your Language
- * @type text
- *
- */
- /*~struct~linebreaks:
- *
- * @param breakfullwindow
- * @text Messagebox Normal
- * @type number
- * @desc For the normal Messagebox without a Face
- * @default 55
- *
- * @param breakshortwindow
- * @text Messagebox with Face
- * @type number
- * @desc For the normal Messagebox with a Face
- * @default 40
- *
- * @param breakhelpwindow
- * @text Help Window
- * @type number
- * @desc Linebreak for the Help Window
- * @default 55
- *
- */
- // -------------------------------------------------------------------------------
- // Daten laden (Plugin Config)
- // -------------------------------------------------------------------------------
- var RUN_SPRACHE = {
- BreakFull : function(){
- let breaker = JSON.parse(PluginManager.parameters('Multi-Lang')['linebreak'])["breakfullwindow"];
- return breaker;
- },
- BreakFace : function(){
- let breaker = JSON.parse(PluginManager.parameters('Multi-Lang')['linebreak'])["breakshortwindow"];
- return breaker;
- },
- BreakHelp : function(){
- let breaker = JSON.parse(PluginManager.parameters('Multi-Lang')['linebreak'])["breakhelpwindow"];
- return breaker;
- },
- SpracheC : function(){
- let params = PluginManager.parameters("Multi-Lang")
- let active = params["spracheCakti"]
- return active;
- },
- SpracheD : function(){
- let params = PluginManager.parameters("Multi-Lang")
- let active = params["spracheDakti"]
- return active;
- },
- SpracheE : function(){
- let params = PluginManager.parameters("Multi-Lang")
- let active = params["spracheEakti"]
- return active;
- },
- SprachNames: function(){
- var Sprachname = [];
- var spracheC = "C";
- var spracheD = "D";
- var spracheE = "E";
- let params = PluginManager.parameters("Multi-Lang");
- var spracheA = params["spracheAname"];
- var spracheB = params["spracheBname"];
- var spracheC = params["spracheCname"];
- var spracheD = params["spracheDname"];
- var spracheE = params["spracheEname"];
- Sprachname.push(spracheA);
- Sprachname.push(spracheB);
- Sprachname.push(spracheC);
- Sprachname.push(spracheD);
- Sprachname.push(spracheE);
- return Sprachname;
- }
- }
- // -------------------------------------------------------------------------------
- // Daten laden (txt)
- // -------------------------------------------------------------------------------
- var MULTI_LANGUAGE = {
- langID: 1,
- commands: null,
- messages: null,
- items: null,
- classes: null,
- term: null,
- battle: null,
- enemy: null,
- help: null,
- costum: null,
- loadTrans: function(id, stringname) {
- var rawFile = new XMLHttpRequest();
- rawFile.open("GET", "data/Sprache-" + id +"/" + stringname + ".txt", false);
- rawFile.onreadystatechange = function () {
- if(rawFile.readyState === 4) {
- if(rawFile.status === 200 || rawFile.status == 0) {
- this[stringname] = rawFile.responseText;
- this[stringname] = this[stringname].split("\n");
- this[stringname].unshift("ERROR")
- }
- }
- }.bind(this);
- rawFile.send(null);
- },
- Translation: function(lang) {
- this.loadTrans(lang, "commands");
- this.loadTrans(lang, "messages");
- this.loadTrans(lang, "items");
- this.loadTrans(lang, "classes");
- this.loadTrans(lang, "term");
- this.loadTrans(lang, "battle")
- this.loadTrans(lang, "enemy")
- this.loadTrans(lang, "help")
- this.loadTrans(lang, "costum")
- }
- };
- MULTI_LANGUAGE.langID = 0;
- // -------------------------------------------------------------------------------
- // Commands
- // -------------------------------------------------------------------------------
- Window_Command.prototype.addCommand = function(name, symbol, enabled, ext) {
- if (enabled === undefined) {
- enabled = true;
- }
- if (ext === undefined) {
- ext = null;
- }
- var ownName = name;
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.commands[number]
- }
- this._list.push({ name: ownName, symbol: symbol, enabled: enabled, ext: ext});
- };
- Window_EquipSlot.prototype.slotName = function(index) {
- var slots = this._actor.equipSlots();
- var ownName = $dataSystem.equipTypes[slots[index]];
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.commands[number]
- }
- return this._actor ? ownName : '';
- };
- TextManager.basic = function(basicId) {
- var ownName = $dataSystem.terms.basic[basicId];
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.commands[number]
- }
- return ownName || '';
- };
- TextManager.param = function(paramId) {
- var ownName = $dataSystem.terms.params[paramId];
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.commands[number]
- }
- return ownName || '';
- };
- // -------------------------------------------------------------------------------
- // Items
- // -------------------------------------------------------------------------------
- Window_Base.prototype.drawItemName = function(item, x, y, width) {
- width = width || 312;
- if (item) {
- var iconBoxWidth = Window_Base._iconWidth + 4;
- this.resetTextColor();
- this.drawIcon(item.iconIndex, x + 2, y + 2);
- var ownName = item.name;
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.items[number]
- }
- this.drawText(ownName, x + iconBoxWidth, y, width - iconBoxWidth);
- }
- };
- // -------------------------------------------------------------------------------
- // Class & Nickname
- // -------------------------------------------------------------------------------
- Window_Base.prototype.drawActorClass = function(actor, x, y, width) {
- width = width || 168;
- this.resetTextColor();
- var ownName = actor.currentClass().name;
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.classes[number]
- }
- this.drawText(ownName, x, y, width);
- };
- Window_Base.prototype.drawActorNickname = function(actor, x, y, width) {
- width = width || 270;
- this.resetTextColor();
- var ownName = actor.nickname();
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.classes[number]
- }
- this.drawText(ownName, x, y, width);
- };
- // -------------------------------------------------------------------------------
- // Term Messages
- // -------------------------------------------------------------------------------
- TextManager.message = function(messageId) {
- var ownName = $dataSystem.terms.messages[messageId];
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.term[number]
- }
- return ownName || '';
- };
- // -------------------------------------------------------------------------------
- // Battle Log
- // -------------------------------------------------------------------------------
- Window_BattleLog.prototype.displayAction = function(subject, item) {
- var numMethods = this._methods.length;
- if (DataManager.isSkill(item)) {
- if (item.message1) {
- var ownName = item.message1.format(item.name);
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.battle[number]
- };
- this.push('addText', subject.name() + ownName);
- }
- if (item.message2) {
- var ownName = item.message2.format(item.name);
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.battle[number]
- };
- this.push('addText', ownName);
- }
- } else {
- this.push('addText', TextManager.useItem.format(subject.name(), item.name));
- }
- if (this._methods.length === numMethods) {
- this.push('wait');
- }
- };
- // -------------------------------------------------------------------------------
- // Enemys
- // -------------------------------------------------------------------------------
- Game_Enemy.prototype.originalName = function() {
- var ownName = this.enemy().name;
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = MULTI_LANGUAGE.enemy[number]
- }
- return ownName;
- };
- // -------------------------------------------------------------------------------
- // Text Caller for Message/ Choices
- // -------------------------------------------------------------------------------
- var CALLER_SPRACHE = {
- MessageL: function(nummer){
- var nummer = parseInt(nummer);
- let pre_ausgabe = MULTI_LANGUAGE.messages[nummer];
- var MaxZeichenAnzahl = RUN_SPRACHE.BreakFull();
- let IstZeichenAnzahl = 0;
- let ausgabe = "";
- for (let i = 0; i < pre_ausgabe.length; i++) {
- let Zeichen = pre_ausgabe[i];
- ausgabe += Zeichen;
- IstZeichenAnzahl++;
- if (IstZeichenAnzahl >= MaxZeichenAnzahl && Zeichen === " ") {
- ausgabe += "\n";
- IstZeichenAnzahl = 0;
- }
- }
- return ausgabe;
- },
- MessageS: function(nummer, lists){
- var nummer = parseInt(nummer);
- let pre_ausgabe = MULTI_LANGUAGE.messages[nummer];
- var MaxZeichenAnzahl = RUN_SPRACHE.BreakFace();;
- let IstZeichenAnzahl = 0;
- let ausgabe = "";
- for (let i = 0; i < pre_ausgabe.length; i++) {
- let Zeichen = pre_ausgabe[i];
- ausgabe += Zeichen;
- IstZeichenAnzahl++;
- if (IstZeichenAnzahl >= MaxZeichenAnzahl && Zeichen === " ") {
- ausgabe += "\n";
- IstZeichenAnzahl = 0;
- }
- }
- return ausgabe;
- },
- MessageN: function(nummer, lists){
- var nummer = parseInt(nummer);
- let ausgabe = MULTI_LANGUAGE.messages[nummer];
- return ausgabe;
- },
- MessageH: function(nummer){
- var nummer = parseInt(nummer);
- let pre_ausgabe = MULTI_LANGUAGE.help[nummer];
- var MaxZeichenAnzahl = RUN_SPRACHE.BreakHelp();;
- let IstZeichenAnzahl = 0;
- let ausgabe = "";
- for (let i = 0; i < pre_ausgabe.length; i++) {
- let Zeichen = pre_ausgabe[i];
- ausgabe += Zeichen;
- IstZeichenAnzahl++;
- if (IstZeichenAnzahl >= MaxZeichenAnzahl && Zeichen === " ") {
- ausgabe += "\n";
- IstZeichenAnzahl = 0;
- }
- }
- return ausgabe;
- },
- MessageC: function(nummer){
- var nummer = parseInt(nummer);
- let ausgabe = MULTI_LANGUAGE.costum[nummer];
- return ausgabe;
- },
- };
- // -------------------------------------------------------------------------------
- // Help Window
- // -------------------------------------------------------------------------------
- Window_Help.prototype.setItem = function(item) {
- var ownName = item ? item.description : ''
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = CALLER_SPRACHE.MessageH(number)
- }
- this.setText(ownName);
- };
- // -------------------------------------------------------------------------------
- // Messages
- // -------------------------------------------------------------------------------
- Game_Interpreter.prototype.command101 = function() {
- if (!$gameMessage.isBusy()) {
- $gameMessage.setFaceImage(this._params[0], this._params[1]);
- $gameMessage.setBackground(this._params[2]);
- $gameMessage.setPositionType(this._params[3]);
- while (this.nextEventCode() === 401) { // Text data
- this._index++;
- var ownName = this.currentCommand().parameters[0];
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ownName)
- if (newName) {
- let number = newName[1]
- var ownName = number
- let MessagePri = ownName;
- let MessageSplit = MessagePri.split(",");
- let nummer = MessageSplit[0];
- if (this._params[0] === ""){
- $gameMessage.add(CALLER_SPRACHE.MessageL(nummer));
- } else {
- $gameMessage.add(CALLER_SPRACHE.MessageS(nummer));
- }
- } else
- {
- $gameMessage.add(ownName)
- }
- }
- switch (this.nextEventCode()) {
- case 102: // Show Choices
- this._index++;
- this.setupChoices(this.currentCommand().parameters);
- break;
- case 103: // Input Number
- this._index++;
- this.setupNumInput(this.currentCommand().parameters);
- break;
- case 104: // Select Item
- this._index++;
- this.setupItemChoice(this.currentCommand().parameters);
- break;
- }
- this._index++;
- this.setWaitMode('message');
- }
- return false;
- };
- Game_Interpreter.prototype.setupChoices = function(params) {
- var choices = params[0].clone();
- var cancelType = params[1];
- var defaultType = params.length > 2 ? params[2] : 0;
- var positionType = params.length > 3 ? params[3] : 2;
- var background = params.length > 4 ? params[4] : 0;
- if (cancelType >= choices.length) {
- cancelType = -2;
- }
- var choicesNew = [];
- choices.forEach(function (Eintrag) {
- var ChoicePri = Eintrag;
- let bracks = /<(.+)>/;
- let newName = bracks.exec(ChoicePri)
- if (newName) {
- let number = newName[1]
- var ChoicePri = number
- let ChoiceSplit = ChoicePri.split(",");
- let nummer = ChoiceSplit[0];
- choicesNew.push(CALLER_SPRACHE.MessageN(nummer));
- } else {
- choicesNew.push(Eintrag);
- }
- });
- $gameMessage.setChoices(choicesNew, defaultType, cancelType);
- $gameMessage.setChoiceBackground(background);
- $gameMessage.setChoicePositionType(positionType);
- $gameMessage.setChoiceCallback(function(n) {
- this._branch[this._indent] = n;
- }.bind(this));
- };
- // -------------------------------------------------------------------------------
- // Menü Zeug
- // -------------------------------------------------------------------------------
- var aliasSceneTitlecreateCommandWindow = Scene_Title.prototype.createCommandWindow
- Scene_Title.prototype.createCommandWindow = function() {
- aliasSceneTitlecreateCommandWindow.call(this)
- this._commandWindow.setHandler('SpracheA', this.commandSpracheA.bind(this))
- this._commandWindow.setHandler('SpracheB', this.commandSpracheB.bind(this))
- this._commandWindow.setHandler('SpracheC', this.commandSpracheC.bind(this))
- this._commandWindow.setHandler('SpracheD', this.commandSpracheD.bind(this))
- this._commandWindow.setHandler('SpracheE', this.commandSpracheE.bind(this))
- this.addWindow(this._commandWindow);
- };
- Scene_Title.prototype.commandSpracheA = function() {
- MULTI_LANGUAGE.langID = 1;
- MULTI_LANGUAGE.Translation(MULTI_LANGUAGE.langID);
- this._commandWindow.close();
- SceneManager.push(Scene_Title);
- };
- Scene_Title.prototype.commandSpracheB = function() {
- MULTI_LANGUAGE.langID = 2;
- MULTI_LANGUAGE.Translation(MULTI_LANGUAGE.langID);
- this._commandWindow.close();
- SceneManager.push(Scene_Title);
- };
- Scene_Title.prototype.commandSpracheC = function() {
- MULTI_LANGUAGE.langID = 3;
- MULTI_LANGUAGE.Translation(MULTI_LANGUAGE.langID);
- this._commandWindow.close();
- SceneManager.push(Scene_Title);
- };
- Scene_Title.prototype.commandSpracheD = function() {
- MULTI_LANGUAGE.langID = 4;
- MULTI_LANGUAGE.Translation(MULTI_LANGUAGE.langID);
- this._commandWindow.close();
- SceneManager.push(Scene_Title);
- };
- Scene_Title.prototype.commandSpracheE = function() {
- MULTI_LANGUAGE.langID = 5;
- MULTI_LANGUAGE.Translation(MULTI_LANGUAGE.langID);
- this._commandWindow.close();
- SceneManager.push(Scene_Title);
- };
- Scene_Title.prototype.createBackground = function() {
- if (MULTI_LANGUAGE.langID == 0) {
- this._backSprite1 = new Sprite("");
- this._backSprite2 = new Sprite("");
- this.addChild(this._backSprite1);
- this.addChild(this._backSprite2);
- } else {
- this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
- this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
- this.addChild(this._backSprite1);
- this.addChild(this._backSprite2);
- }
- };
- var aliasWindowTitleCommandmakeCommandList = Window_TitleCommand.prototype.makeCommandList
- Window_TitleCommand.prototype.makeCommandList = function() {
- if (MULTI_LANGUAGE.langID == 0) {
- let Name = RUN_SPRACHE.SprachNames();
- this.addCommand(Name[0], 'SpracheA');
- this.addCommand(Name[1], 'SpracheB');
- if (RUN_SPRACHE.SpracheC() === 'true') {
- this.addCommand(Name[2], 'SpracheC');
- }
- if (RUN_SPRACHE.SpracheD() === 'true') {
- this.addCommand(Name[3], 'SpracheD');
- }
- if (RUN_SPRACHE.SpracheE() === 'true') {
- this.addCommand(Name[4], 'SpracheE');
- }
- } else {
- aliasWindowTitleCommandmakeCommandList.call(this)
- }
- };
Achja, die Beschreibung ist etwas groß geworden aber dafür Umfassend