MZ How can i make a freeform text input dialog ?

Hi, new RPG Maker MZ developer here, also first time game developer 🙂

I'm making a RPG game where NPC conversations are interactive based on user side free-text inputs and responses generated by chatbots like LLaMA. I am much more familiar with the AI side of it that i can easily set up a http server up and running, and i've already built the scripts in RPG Maker MZ to interact with my http server and set game variables.

One issue I'm trying to resolve is I cannot find a good working solution to `free-form text input dialog` that works for MZ, closest working solution i found was to just use plain javascript like

```js
const playerInput = prompt("Please enter your input:");
if (playerInput !== null) {
$gameVariables.setValue(1, playerInput);
}
```

but it's browser dialog rather than in-game dialog. I'm using VisuMZ-1 plugins and it's starter template to build my game.

Other closer solution that sort-of works is create some temporary character and use the naming module to type in text input, but it seems to limit to 16 characters and still not quite the dialog experience i'm looking for.

Thanks !
Moved to: Plugin Requests
I've attached a Text-File which actually contains the Javascript code for the implementation of a simple in-game text editor. I've extracted this code from my base plugin, but it's just the window and no scene which includes this window, yet.
I guess it still needs some adjustments for you to work as a chat. Feel free to modify and include the code within your own scripts.
I've attached a Text-File which actually contains the Javascript code for the implementation of a simple in-game text editor. I've extracted this code from my base plugin, but it's just the window and no scene which includes this window, yet.
I guess it still needs some adjustments for you to work as a chat. Feel free to modify and include the code within your own scripts.
Thanks a lot ! Let me give it a try 🙂 A few n00b questions about how to set it up as I'm still learning how RPG Maker MZ works, does this look right ?

- Create new chat_window.js file with the text content you attached and put it under js/plugin
- Put it under other plugins in my plugin manager on game startup
- Use script / pluggin command like `Window_FreeTextInput` ?
- Yes create new e.g. chat_window.js with the content of the text file
- I guess you can place it anywhere in your plugin manager because it should not interfere with other plugins at all, but to be safe put it below or above all other code you need for chat.
- You will need a Scene containing the window and then call the Scene via script call, e.g. SceneManager.push(Scene_Chat)

Also by default my window only closes when pressing the "Escape" key. On "Return" or "Enter" it creates a new line of text. If you don't want that just change the code of the handleReturnEnter function.

You may use this code as a starting point for the Chat-Scene, just include it in chat_window.js aswell:
Spoiler: Simple Chat Scene
JavaScript:
class Scene_Chat extends Scene_Base
{
    constructor() {
       super();   
    }

    create() {
       super.create();
       this.createWindowLayer();
       this._chatWindow = new Window_Chat(0,0,Graphics.boxWidth,Graphics.boxHeight);
       this.addWindow(this._chatWindow);
    }

    terminate() {
        // Here do something with the text, either write it to a variable or send it immediately to your HTTP Server etc.
        // this._chatWindow.fullText();
        super.terminate();
    }
}

class Window_Chat extends Window_FreeTextInput
{
    constructor(x,y,width,height) {
        super(x,y,width,height);
    }
    
    handleReturnEnter(event)
    {
        if( event.code === 'NumpadEnter' )
            this.handleEscape();
        else
            super.handleReturnEnter();           
    }
}

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-make-a-freeform-text-input-dialog.156567/