Conditional Branch defaulting to one choice?

Hey guys,

My character select screen looks good - but it isn't 100% bug free yet and I need help. Right now it "defaults" to the boy selection - and sometimes even when the player presses right it still selects the boy option, but it seems random and I can't pinpoint why...help!

I'll share a video of what the system is supposed to look like for reference.

Spoiler: Video


Spoiler: Code
◆If:Button
is pressed down
◆Wait:1 frame
◆Erase Picture:#5
◆Wait:1 frame
◆Show Picture:#4, Character-Select-(Boy), Center (640,360), (100%,100%), 255, Normal
◆Play SE:Cursor2 (90, 100, 0)
◆Wait:15 frames
◆Stop SE
◆Wait:1 frame
◆
:End
◆If:Button [OK] is pressed down
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Is this BOY the appearance you choose?"
◆Show Choices:Yes, No (Dim, Right, #1, #2)
:When Yes
◆Show Animation:Player, Glowing Light (Pink) (Wait)
◆Change Party Member:Add Elias
◆Change Party Member:Remove Shade
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Now, what's your name?"
◆Name Input Processing:Elias, 8 characters
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"\N[7] - that's catchy! Let's continue..."
◆Fadeout Screen
◆Erase Picture:#3
◆Erase Picture:#4
◆Erase Picture:#5
◆Control Switches:#0003 Gender Complete = ON
◆Fadein Screen
◆
:When No
◆Wait:10 frames
◆
:End
◆
:End
◆If:Button
is pressed down
◆Wait:1 frame
◆Erase Picture:#4
◆Wait:1 frame
◆Show Picture:#5, Character-Select-(Girl), Center (640,360), (100%,100%), 255, Normal
◆Play SE:Cursor2 (90, 100, 0)
◆Wait:15 frames
◆Stop SE
◆Wait:1 frame
◆
:End
◆If:Button [OK] is pressed down
◆Wait:1 frame
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Is this GIRL the appearance you choose?"
◆Show Choices:Yes, No (Dim, Right, #1, #2)
:When Yes
◆Show Animation:Player, Glowing Light (Pink) (Wait)
◆Change Party Member:Add Rhoslyn
◆Change Party Member:Remove Shade
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Now, what's your name?"
◆Name Input Processing:Rhoslyn, 8 characters
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"\N[8] - that's catchy! Let's continue..."
◆Fadeout Screen
◆Erase Picture:#3
◆Erase Picture:#4
◆Erase Picture:#5
◆Control Switches:#0003 Gender Complete = ON
◆Fadein Screen
◆
:When No
◆Wait:10 frames
◆
:End
◆
:End
​

Thanks in advance!​
why are you using ingame events to control what should be a window class?

if that was a window, it would have it's own methods and functions, one of which is handling key presses.

what you want to do is already done within the code itself.... no need to fake it from within a scene of the game, just use the game-level code, which then passes information down to your scene-level action.

if you must do it with ingame events, though....
I wouldn't check for IF a button is being pressed.

as it is, you're evaluating a button press and processing for boy selection, and then evaluating a button press and processing for girl selection.
even if you select a girl, when the code loops back from the top, the boy selection evaluates first, because the part that tells the program to mark the boy for processing is outside of your evaluation: it doesn't validate because the button being watched wasn't pressed.

I'd give for granted that the player will press a button.
what happens when that button is pressed should be generic, only being different at the kind of data you're processing.
As in, you're adding an actor to the party. Regardless of selection. Granted.
Which actor? -> the one selected.
see the difference?

it can be done through events, but you'd have to work with variables and numbers, instead of using the default controls, just so you can check for actual position of the cursor rather than button presses.
Most likely, because he doesn't know javascript and MV's code.
Picture based menu are a great alternative to make basic UI.

I don't have access to my computer right now, so I can't check your event, but I helped someone set up an image menu, not long ago:
https://forums.rpgmakerweb.com/index.php?posts/728194/

If you don't want the touch controls, just look at my last post in that thread and copy the parts that don't deal with it.
If you want touch controls you'll have to use a small code snippet I made, which you can find in that thread.
Most likely, because he doesn't know javascript and MV's code.
Picture based menu are a great alternative to make basic UI.

I don't have access to my computer right now, so I can't check your event, but I helped someone set up an image menu, not long ago:
https://forums.rpgmakerweb.com/index.php?posts/728194/

If you don't want the touch controls, just look at my last post in that thread and copy the parts that don't deal with it.
If you want touch controls you'll have to use a small code snippet I made, which you can find in that thread.

@Astfgl66 So I did this but it's still non-responsive in some cases - it will allow me to click OK to proceed 75% of the time, but the other 25% even if I've pressed left or right and then OK it doesn't do anything. Is there something wrong with this?

Spoiler: Code
◆Control Variables:#0001 Character Select = 1
◆If:Character Select = 1
◆Show Picture:#3, Character Select (Neutral), Center (640,360), (100%,100%), 255, Normal
◆
:End
◆If:Script:Input.isPressed("left")
◆Control Variables:#0001 Character Select -= 1
◆
:End
◆If:Script:Input.isPressed("right")
◆Control Variables:#0001 Character Select += 1
◆
:End
◆If:Character Select ≥ 2
◆Control Variables:#0001 Character Select = 2
◆
:End
◆If:Character Select ≤ 0
◆Control Variables:#0001 Character Select = 0
◆
:End
◆If:Character Select = 0
◆Erase Picture:#5
◆Wait:1 frame
◆Show Picture:#4, Character-Select-(Boy), Center (640,360), (100%,100%), 255, Normal
◆Play SE:Cursor2 (90, 100, 0)
◆Wait:10 frames
◆Stop SE
◆Wait:1 frame
◆
:End
◆If:Character Select = 2
◆Erase Picture:#4
◆Wait:1 frame
◆Show Picture:#5, Character-Select-(Girl), Center (640,360), (100%,100%), 255, Normal
◆Play SE:Cursor2 (90, 100, 0)
◆Wait:10 frames
◆Stop SE
◆Wait:1 frame
◆
:End
◆If:Script:Input.isPressed("ok")
◆If:Character Select = 0
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Is this BOY the appearance you choose?"
◆Show Choices:Yes, No (Dim, Right, #1, #2)
:When Yes
◆Show Animation:Player, Glowing Light (Pink) (Wait)
◆Change Party Member:Add Elias
◆Change Party Member:Remove Shade
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Now, what's your name?"
◆Name Input Processing:Elias, 8 characters
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"\N[7] - that's catchy! Let's continue..."
◆Fadeout Screen
◆Erase Picture:#3
◆Erase Picture:#4
◆Erase Picture:#5
◆Control Switches:#0003 Gender Complete = ON
◆Fadein Screen
◆
:When No
◆Wait:10 frames
◆Control Variables:#0001 Character Select = 0
◆
:End
◆
:End
◆If:Script:Input.isPressed("ok")
◆If:Character Select = 2
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Is this GIRL the appearance you choose?"
◆Show Choices:Yes, No (Dim, Right, #1, #2)
:When Yes
◆Show Animation:Player, Glowing Light (Pink) (Wait)
◆Change Party Member:Add Rhoslyn
◆Change Party Member:Remove Shade
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"Now, what's your name?"
◆Name Input Processing:Rhoslyn, 8 characters
◆Text:None, Dim, Bottom
: :\auto\msgposx[640]\lspi[150]"\N[7] - that's catchy! Let's continue..."
◆Fadeout Screen
◆Erase Picture:#3
◆Erase Picture:#4
◆Erase Picture:#5
◆Control Switches:#0003 Gender Complete = ON
◆Fadein Screen
◆
:When No
◆Wait:10 frames
◆Control Variables:#0001 Character Select = 0
◆
:End
◆
:End
◆
:End
◆
:End
So I did this but it's still non-responsive in some cases - it will allow me to click OK to proceed 75% of the time, but the other 25% even if I've pressed left or right and then OK it doesn't do anything. Is there something wrong with this?
That sounds as if there is a timing problem - which means we need more data outside of the content.
Is that event on autorun or on parallel process?
What other parallel processes are running at the same time, and how are they triggered/controlled? (remember to check your common events as well)
Oh - and your code in the post above cannot work either. Character select will always be 1 because you set it to one in the first line, so the first condition will also always be true.
This might be the cause for the problems - that it works as intended if you're fast enough to complete the sequence before it resets at the beginning.
But we would need to see how that content is triggered to really analyse it - always remember that the content is only part of the event.
That sounds as if there is a timing problem - which means we need more data outside of the content.
Is that event on autorun or on parallel process?
What other parallel processes are running at the same time, and how are they triggered/controlled? (remember to check your common events as well)
Oh - and your code in the post above cannot work either. Character select will always be 1 because you set it to one in the first line, so the first condition will also always be true.
This might be the cause for the problems - that it works as intended if you're fast enough to complete the sequence before it resets at the beginning.
But we would need to see how that content is triggered to really analyse it - always remember that the content is only part of the event.
Wow, thanks for pointing out that super lame mistake. Changing the positioning of the audio effects and removing that from the top of the event fixed it. Thanks you guys for helping me out - this has been super eye-opening.

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-defaulting-to-one-choice.77948/