Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Creating dialogue using javascript

Dreamsavior

Villager
Xy$
0.00
I know this sounds weird, since creating dialogue is may be the easiest thing to do using those "Show Text" feature in event editor GUI.
But, when it comes to smartly showing random messages and dialogue based on stats and variable with tons of possibility (ie: based on character's mood, weather, time, etc) using GUI can be a tedious task.
So I decided to make my own AI-like-dialog-system plugins utilizing RMMV standard show message script calls....
so I created the module, the routine, the method..everything is merry and all... until I stuck at the very basic thing... How do I display the random generated dialogue to the game!!? By dialog, I mean, showing text with two or more character face image / busts, and perhaps more than one message window location.

For example :

This is expected result :

and then...after click...



Here is the series of script call that I use in hope to achieve that:

Code:
$gameMessage.setFaceImage("Actor1", 0);
$gameMessage.setBackground(0);
$gameMessage.setPositionType(2);
$gameMessage.add("Text at bottom");
$gameMessage.newPage();
$gameMessage.setFaceImage("Actor1", 1);
$gameMessage.setBackground(0);
$gameMessage.setPositionType(0);
$gameMessage.add("Text at top");

And here is the result :


and then after click...


So, I wonder where do I do wrong?
Please anyone?
How to show message with multiple actor's image / busts, more than one window location and background using script call?
 

Attachments

You need to let the tick happen, you're changing everything instantly. I'll write you something just give me ten minutes or so and I'll edit this to teach you.

Update:
Okay, this in a plugin:
JavaScript:
var bones_textArray = new Array;

function showTextMessege(){
    var textObject;
    for(i = 0; i < bones_textArray.length; i++){
        if(!$gameMessage.isBusy()){
            textObject = bones_textArray[i];
            $gameMessage.setFaceImage(textObject.faceImage, textObject.faceImageNumber);
            $gameMessage.setBackground(textObject.background);
            $gameMessage.setPositionType(textObject.position);
            $gameMessage.add(textObject._text);
            $gameMessage.newPage();
            bones_textArray.splice(i,1);
        }
    }
}

function addToMessegeArray(index,contents){
    if(bones_textArray.length < index + 1){
        bones_textArray.push(contents);
    }
}
and then this is what you need to do, you need to make sure that the function showTextMessege is run every tick or on the next page however the way I'll explain is the better one:


Put that on your map or if like me have a few scripts called from parallels add that to the list.

Then put this in any event or in any script. (I'll explain the code after the methods)
Event:

Script:

Provided that function isn't run every tick but like the event happens when you do something. You can define all the text, however make sure this isn't being run every tick.

Okay the code:
addToMessegeArray(0,
The zero is the order you want to display the text. First element is 0 next is 1 and 2.
addToMessegeArray(0,{
Start an object and then define these properties:
faceImage: "Actor1",faceImageNumber: 0, background: 0, position: 2,_text: "Text at bottom"
Then close off the object with another }, close the function with a ); and this is the two lines expressed in this way:
JavaScript:
 addToMessegeArray(0,{faceImage: "Actor1",faceImageNumber: 0, background: 0, position: 2,_text: "Text at bottom"});
addToMessegeArray(1, {faceImage: "Actor1",faceImageNumber: 1, background: 0, position: 0,_text: "Text at top"});
Basically this script ensures that the text properties are set only when text isn't on the screen.

Additionally this is one method that is probably a long way around so anyone else feel free to chime in.
 
Last edited:

Dreamsavior

Villager
Xy$
0.00
Thanks LordBones, that's worked!
although this work around require us to use a watcher parallel event, ... but this is a working solution! Thank's for that!
[doublepost=1462846844,1462074667][/doublepost]Hooking showTextMessege(); to Scene_Map.update() seems working too.

I have testing below code, and it's worked. This doesn't require parallel event.
JavaScript:
var DV_Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
    DV_Scene_Map_update.call(this);
    if (bones_textArray.length>0) {
        showTextMessege();
    }
};
 
Hmm.... that would work. I think if I make standalone functions like this available on the resources, I know how to make it more user friendly so thanks for teaching me back! lol
 
Top