Conditional Branch When button is triggered

Shikuroshi

Artist
Member
Joined
Mar 14, 2012
Messages
29
Reaction score
1
First Language
English
Primarily Uses
I just switched over to MV and so far I am enjoying it. Though in my current project I have a bump I can't figure out.
 


I am trying to implement a sort of interrogation system into my game. The idea was inspired from Wild Arms 3


I have the video set to the tutorial for the system that inspired me if the timing is off skip to 8:52








I hope this video can help explain what I mean. I wanted something that would play out like.....


NPC: Welcome to the town A.


Player presses nothing dialogue ends


however, 


If Player presses button: This town is well known for its green summers and harsh winters.  


I found in the tabs the conditional branches and I found the 'Button is pressed down' bit. But that doesn't really have the intuitive flow I was hoping for the game because it requires the player to hold a button down while advancing the text where my goal would be more of a press a different button get a change in text so I tried to use a java script but I know next to no Java so I have made no real headway in this. 


If anyone could push me in the right direction I would GREATLY appreciate it.
 
Last edited by a moderator:

Maidlyn

Veteran
Veteran
Joined
Jun 9, 2016
Messages
354
Reaction score
115
First Language
English
Primarily Uses
RMMV
Code:
◆If:Button [OK] is pressed down
  ◆Text:None, Window, Bottom
  :    :[Insert Dialogue Here]
  ◆
:Else
  ◆
:End
 

Shikuroshi

Artist
Member
Joined
Mar 14, 2012
Messages
29
Reaction score
1
First Language
English
Primarily Uses
I tried to follow what you said, but it only confused me a bit. 


So I added my event window here to maybe get a better understanding.


I was trying to use the istriggered command earlier, this screenshot is changed 


trying to implement your suggestion

example.png
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,378
Reaction score
7,209
First Language
German
Primarily Uses
RMMV
Minty didn't tell you to use the script option, but to use the button option (one point above the script option).


However, that option check the button press in that single frame it is executed (1/60th of a second), you usually need that conditional branch in a loop to wait for player reaction.


In your specific case, I would place it in a loop inside that event, but that loop needs to contain an additional variable counting (+1 per loop) and a second conditional branch to check for that counter and break the loop once it is above a selected number (number of frames to wait before breaking the loop)
 
Last edited by a moderator:

Shikuroshi

Artist
Member
Joined
Mar 14, 2012
Messages
29
Reaction score
1
First Language
English
Primarily Uses
I did manage to get it to work with the 'is pressed' option above script, but it only works if the player is holding the button at the same time they press ok[Z] to advance the text. I could use it this way, but I would prefer a more streamlined approach. I'm not familiar with loops so I'm a bit confused by what you're trying to explain. 


I know that is pressed is checking for a constant hold of the button which is why I tried to switch over to the script option because I was looking for the player to press a button OTHER than the normal ok[z] button to trigger the extra dialogue. I don't care what button tab space bar anything so long as it's a one button click to change the path. That is honestly what pushed me into trying to use the java commands for button.istriggered('Q') but I had errors that my ignorance in Java couldn't fix. 


I apologize I don't want to inconvenience anyone if I'm being too difficult. 


*edit* this can be closed I think I need to learn more before I can do this the way I would like it. 
 
Last edited by a moderator:

Dad3353

Veteran
Veteran
Joined
Mar 9, 2016
Messages
421
Reaction score
109
First Language
English
Primarily Uses
...


I apologize I don't want to inconvenience anyone if I'm being too difficult. 


*edit* this can be closed I think I need to learn more before I can do this the way I would like it. 


The very fact of asking the question (too early, maybe, but it's a good question nevertheless...) has brought this option and its treatment to the eyes of the forum as a whole, and is therefore valuable. Thanks; I wouldn't have thought of doing anything like this, and the (very good...) replies to the question make sense to me. Thanks, then, for having posted the question at all, and good luck with your learning, and your Project.
 

consolcwby

(2015: afk...) 2018: BAK! :P
Veteran
Joined
Aug 25, 2016
Messages
205
Reaction score
334
First Language
English
Primarily Uses
RMMV
I'm not familiar with loops so I'm a bit confused by what you're trying to explain. 
All code in a loop is executed until a condition is met which breaks the loop. So, what @Andar was saying is to use a variable to count how many times the loop has run. Once it reaches a certain number (this is the max number of times the loop is run) you break the loop. The loop is where you'd be checking to see if the player presses the button in time. The number of loops is the time. So, it would kinda look like this:

Code:
	begin
	{
	      if (keypress("Q") == true)
	      {
	          goto label PRESSED;
	       }
	       else
	       {
	          if (variable_counter >= 60) // 60 is 1 second of time
	          {
	             break loop;
	           }
	           else
	           {
	              variable_counter++;
	            }
	          }
	}
	do loop
 
Last edited by a moderator:

Shikuroshi

Artist
Member
Joined
Mar 14, 2012
Messages
29
Reaction score
1
First Language
English
Primarily Uses
That makes a good amount of sense actually thank you for taking the time to explain the loop process to me. 


I'll definitely try this when I get back to working on the game. c:
 

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

Latest Threads

Latest Profile Posts

Small rant: While using SRD Hud maker for a battle hud, I typed in the wrong script call and got an error, but then forgot to delete the piece that caused the error before closed the Hud maker and hit F5 to restart the game. Now everytime I engage in a battle my game crashes...
:kaolivid:
Would Jump into Javascript be best off continuing to break down the MV core files, or would people prefer a quick detour to cover everything that's changed in the core from MV to MZ?
Not going to lie... PIXI Particles make fantastic graphics... But predicting the hitbox of something with a "fixed size" but whose graphics can stick out past that, is quite challenging. :kaoswt:
Would you like a glass of spiders?

Forum statistics

Threads
100,530
Messages
976,894
Members
132,081
Latest member
Kaezyelnatz
Top