Need help with NPC Random Dialogue Control Variables

ThisExitSign

Villager
Member
Joined
Oct 24, 2016
Messages
5
Reaction score
0
First Language
English
Primarily Uses
I've read a number of articles explaining how to supposedly create an NPC which will say randomly selected lines of dialogue using Control Variable. I tried using this tutorial I found on Youtube: 










But after doing exactly as he said my NPC will only say the first piece of text. It will also sometimes not respond to me selecting the action key, or will quickly look at my character and not say anything or do nothing at all. When messing around with the event further the NCP would disappear all together. My final attempt at this is in the picture below. I tried to find an MV tutorial but all I could find is VX and VX ACE tutorials, so it may have something to do with that. Can someone help out this lowly pleb? (I'm also pretty sure this post is in the correct forum, I'm praying it is) 

Why does this happen to me.jpg
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,100
Reaction score
13,705
First Language
English
Primarily Uses
RMMV
You didn't do exactly as he said ;)


Just looking at your screenshot and the event in the video, you can tell that he's got more lines than you do, so there's something missing in yours.  You need to use ELSE statements in there too.  


What you've got is "if Wood is 1, show this text and then check if Wood is 2 (which it's not going to be, because it's 1)".  Since the two later tests are only run if the previous ones are successful, you're only ever going to get a message when wood is 1.
 
Last edited by a moderator:

Vassim74

It's a Secret!
Veteran
Joined
Jan 7, 2014
Messages
115
Reaction score
85
First Language
English
Primarily Uses
RMMV
As Shaz said, the problem is that you have the other 2 conditions within each other instead of placing them outside of each other. Also, you don't need to use Else statements. Here's a snapshot of I have mine set up:

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,100
Reaction score
13,705
First Language
English
Primarily Uses
RMMV
You can do it without else statements, but the benefit of using them is that once it finds a condition that's true, it'll stop testing the others.  If you don't use Else statements, if the variable is set to 1, it'll show the first message, but then it'll also do the other tests to see if it's 2 or 3, when really it already knows it's not going to be either of those.  Hardly worth worrying about in this situation, but if you had a situation where you had a lot of possibilities, you wouldn't want it to keep testing after it found the correct one. :)
 
Last edited by a moderator:

ThisExitSign

Villager
Member
Joined
Oct 24, 2016
Messages
5
Reaction score
0
First Language
English
Primarily Uses
Thank you all for your help, I have seen the fault in my ways.
 

Dad3353

Veteran
Veteran
Joined
Mar 9, 2016
Messages
421
Reaction score
110
First Language
English
Primarily Uses
You can do it without else statements, but the benefit of using them is that once it finds a condition that's true, it'll stop testing the others...


This can be achieved by having a 'Jump' at the end of each 'If' statement. The 'Else' solution is fine, but it can be difficult to manage if one is adding more conditions later, of if the order of conditions needs changing.  There are often several methods for achieving any one result, and all options are useful to know about, so as to choose the most appropriate for one's needs. There is, of course, nothing wrong with using 'else' in many cases.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,100
Reaction score
13,705
First Language
English
Primarily Uses
RMMV
good points.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,236
Members
137,608
Latest member
Arm9
Top