Help with scripted conversations

So I've been trying to use scripts to create conversation trees, and I've been running into a bit more trouble. When using the regular "show text" event, the npc automatically faces the player character. How do I do that with a script?

Here is the code I have right now:
Code:
var interpreterCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
    // to be overridden by plugins

    interpreterCommand.apply(this);

    if (command === 'test') {
    $gameMessage.setFaceImage('actor2', 3);
    $gameMessage.add("\\<WordWrap> \\n<test> I'm talking! But this is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long message, I wonder how it will fit." );
    $gameMessage.setChoices([ 'ch0', 'ch1', 'ch2', 'cry', 'cancel'], 1, 4);
    };
};
Question! Why are you using Scripting for something that can be done easier with events?

Also pretty sure you can make conversation trees with the use of events and labels. Which might make it a lot easier then to code it all in.


Also if you want to do it your way via coding then use the script event and place in inside that NPC.
Question! Why are you using Scripting for something that can be done easier with events?

Also pretty sure you can make conversation trees with the use of events and labels. Which might make it a lot easier then to code it all in.


Also if you want to do it your way via coding then use the script event and place in inside that NPC.
The reason I'm using scripts is because I'm trying to do rather complicated conditional conversation trees. (Things like hiding options/branches based on other game factors, and looping back to early parts of the conversation to pursue other branches). So scripts seemed like the best way to do that.

You mentioned something about events and labels. I don't know anything about those, but it does sound like something that would be helpful. Do you know any good tutorials for those?
The reason I'm using scripts is because I'm trying to do rather complicated conditional conversation trees. (Things like options being restricted based on other game factors, and looping back to early parts of the conversation to peruse new paths). So scripts seemed like the best way to do that.

You mentioned something about events and labels. I don't know anything about those, but it does sound like something that would be helpful. Do you know any good tutorials for those?

At the top of my head no, I'm mostly self-taught after using RPG maker for a few years so I've basically know a lot about events and the are quite powerful you just need to understand how to use them.

So basically what Labels is a name of a go-to point in the event processing.

So if you got a long list of events with different convo and wish to go back to a certain point of even skip forward to a certain point you can use the event command "Jump to label" so for example.


Lable "intro"
Question: Is there anything else you like to know?
C1: Yes, how did you come to live here? -> Jump to Label "Choice 1"
C2: What can you tell me about super mutants? -> Jump to Label "Super mutants"
C3: Where can I buy supplies? -> Jump to Label "Suplies"

Label "Choice 1"
Well, what do you want to know?
C1: Your parents? -> Jump to label Parents
Label "Parents" -> Textbox "Super mutants killed em"
C2: Your children?
C3: Nothing thanks. -> Jump to Label "Intro"

Label "Super mutants"
Damn super mutants, hate em. The reason why my parents ain't here.
C1: What the hell are they?
C2: Where do they come from?
C3: your parents?. -> Jump to Label "Choice 1"
C4: let's talk about something else. -> Jump to label "intro"


So just by the quick example above, as events go down the page in a normal process labels can nab it and tell it to go start somewhere else if you want to have back and forth with your convo and as for what appears in the convo or choices you can use conditional branches.
At the top of my head no, I'm mostly self-taught after using RPG maker for a few years so I've basically know a lot about events and the are quite powerful you just need to understand how to use them.

So basically what Labels is a name of a go-to point in the event processing.

So if you got a long list of events with different convo and wish to go back to a certain point of even skip forward to a certain point you can use the event command "Jump to label" so for example.


Lable "intro"
Question: Is there anything else you like to know?
C1: Yes, how did you come to live here? -> Jump to Label "Choice 1"
C2: What can you tell me about super mutants? -> Jump to Label "Super mutants"
C3: Where can I buy supplies? -> Jump to Label "Suplies"

Label "Choice 1"
Well, what do you want to know?
C1: Your parents? -> Jump to label Parents
Label "Parents" -> Textbox "Super mutants killed em"
C2: Your children?
C3: Nothing thanks. -> Jump to Label "Intro"

Label "Super mutants"
dayum super mutants, hate em. The reason why my parents ain't here.
C1: What the hell are they?
C2: Where do they come from?
C3: your parents?. -> Jump to Label "Choice 1"
C4: let's talk about something else. -> Jump to label "intro"


So just by the quick example above, as events go down the page in a normal process labels can nab it and tell it to go start somewhere else if you want to have back and forth with your convo and as for what appears in the convo or choices you can use conditional branches.

That sounds extremely useful. I'm definitely going to need that. But it doesn't give me conditional conversation functionality (Though this could be a part of it.) This means that I still need to find a way to change event sprite facings in scripts.
I'm not sure exactly the code for but put at the beginning of the convo script to face the player?

Now for the conditional Convos, you can use the Event "Conditional branch" but this won't change the options of what choices appear unless you do a separate choice for each conditional.
I'm not sure exactly the code for but put at the beginning of the convo script to face the player?

Now for the conditional Convos, you can use the Event "Conditional branch" but this won't change the options of what choices appear unless you do a separate choice for each conditional.
That solution doesn't work. When the text is triggered, the event defaults to it's original sprite. I think I have to do it the same way as the text event does, and I have no idea where to find that.

The conditional branch solution creates an explosive multiplicative problem. It wont work for this.

Thanks for the help!
This means that I still need to find a way to change event sprite facings in scripts.
That part of the engine is not in show texts, it is part of the event triggering.
An event turns toward player when the player triggers it by action button.

As such, there is no need to make it part of your conversation script, but let the engine handle it before the conversation starts.
Just make the event as usual with trigger = action button, and in the content call the script function that starts your conversation tree instead of using regular show text if that is what you need.

If you need to change facing during conversation, do it the same way it would be done with regular event commands: setup a move route targeted on that event (or on the player) and program it to make the changes by that.
That part of the engine is not in show texts, it is part of the event triggering.
An event turns toward player when the player triggers it by action button.

As such, there is no need to make it part of your conversation script, but let the engine handle it before the conversation starts.
Just make the event as usual with trigger = action button, and in the content call the script function that starts your conversation tree instead of using regular show text if that is what you need.

If you need to change facing during conversation, do it the same way it would be done with regular event commands: setup a move route targeted on that event (or on the player) and program it to make the changes by that.
Hi, thanks for the response. Your info made me realize something: When activating the event, the sprite snaps to face my character for a second, and then snaps back to its default facing. This suggests that the event's native facing ability is working, but that something in my code is forcing it back to it's default position. Is there anything in my code that could be giving a new facing command?
this suggests that the event's native facing ability is working, but that something in my code is forcing it back to it's default position.
Not quite, it's not what you are doing, but rather what you are not doing.

There is something called a Game Interpreter which essentially interprets an Event Command into JS. For example, the Set Text Event Command is command101 and the engine does a few things with it, including $gameMessage.add(...) which you have already discovered.
But another thing it does is set itself (itself = Game_Interpreter) to a wait mode which means that everything else is frozen until that wait mode is over. i.e. the event doesn't turn back until the wait mode is over.

I'm usually a fan of using script calls, but anything which involves waiting / timing (show text, move routes, animations, balloons, etc.) is better as an Event Command because the Game Interpreter is already designed to handle the waiting/timing aspects.
Not quite, it's not what you are doing, but rather what you are not doing.

There is something called a Game Interpreter which essentially interprets an Event Command into JS. For example, the Set Text Event Command is command101 and the engine does a few things with it, including $gameMessage.add(...) which you have already discovered.
But another thing it does is set itself (itself = Game_Interpreter) to a wait mode which means that everything else is frozen until that wait mode is over. i.e. the event doesn't turn back until the wait mode is over.

I'm usually a fan of using script calls, but anything which involves waiting / timing (show text, move routes, animations, balloons, etc.) is better as an Event Command because the Game Interpreter is already designed to handle the waiting/timing aspects.
Ok, that's good to know. I was doing a bit of research on my own, and actually found a few plugins from HIMEWorks that might do what I need. In any case, it looks Like I'll stay away from script calls when if I can.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/help-with-scripted-conversations.91378/