Conditional branch doing both things

I have made a slider game where you have to stop a slider over the max button pic16.PNG


But i'm having trouble with the conditional branch that decides if you stopped it in the correct place.  If you stop it correctly the pull slider should move faster but if you don't you hear a buzzer and take 20 damage.  Instead my event is doing both these things at the same time. The second else branch is blank as I don't want it to do anything if you are not pressing the down key.  (the conditional variables did originally check the y coordinates as well but as it only ever moves side ways so i removed them, but the problem still existed when they were there.)  Each event page is the same just moving the slider faster and changing its and the max events position.  


pic15.PNG


Thanks to anyone that came help me solve it, it is probably something really simply I've missed.
Are you certain this is the page that's active?  You don't have a very similar but not-quite-right page on tabs 2, 3, or 4 do you?


So the event moves on its own, and you press the down arrow when you want to 'stop' it?


Which one is being executed first?  If you're not sure, add a Show Text command as the first command in both blocks - that'll let you know for sure which one it is.


Could be that you need to use the Script part of the conditional branch to check the button trigger rather than use the 'button being pressed' option - I just don't recall if that option looks for the initial press or also runs when the button is continually pressed (repeated).
Are you certain this is the page that's active?  You don't have a very similar but not-quite-right page on tabs 2, 3, or 4 do you?


So the event moves on its own, and you press the down arrow when you want to 'stop' it?

It is definitely this page that goes first as i put some text in like you suggested, although the text played repeatedly.  The other pages I just copied and pasted from this one and changed the event location and self switches.


Your right the event moves on its own and you press the down key to stop it.


Do you have any idea what the script would be?  I tried looking on the script list for MV but couldn't see one for button checking.


Thanks
I think you'll need to change what is checked, as right now that code is running every frame (1/60th of a second) unless the down key is pressed and since most of us don't hold down the key for just 1/60th of a second it is running multiple times per button press. As it is, I see 2 ways to fix that.


1: Turn off the event after it runs once. You could do that with a self switch. It looks like you do that under the if they line up, but you'll need it under the if they miss too. Maybe use a regular switch to flag the event as done 1x, then turn it back off when you retry it?


2: Change it to input trigger like Shaz suggested. This way it only runs when the key is pressed, and not repeatedly if the key is down.


3: Move the wait 60 call outside the if down key is pressed. This way it will only check if the key is down every second. Still an issue if someone holds the key down form more than 1 second, but might fix some of the issues.
I tried typing in the script call: (Input.isTriggered(down)), I've also tried (Input.isTriggered(ok)) but it kept producing an error of down is not defined/ok is not defined, I can't seem to find a list of script calls for the buttons within MV.  I saw something that said press F1 in playtest for a list but my F1 key does nothing.
put 'down' in quotes
Thanks for the suggestion but instead you get an error 'unexpected string'.  I tried asking on the script call thread but no-one replied.
Please give us a screenshot of the current event and the exact error message.


Scripting requires specific attention to detail - we had cases where nothing worked because there was a space too much at the wrong place, or because the user placed the wrong brackets [] instead of () and so on. Simply describing what you have done has too much risk of misunderstanding.
I based these off of the script calls list.   I have tried replacing the word 'Pressed' with 'Triggered'  -  (Input.isTriggered(down)).  


I have tried giving the word down a capital D.  


pic17.PNGpic18.PNG


pic19.PNGpic20.PNG


pic21.PNGpic22.PNG


Then I looked up Java script and used this


pic23.PNG


which doesn't give an error, but nothing happens either when you press the down key, so there should obviously be more to the script call i'm just not sure what to write and how to do it.  I used this info, from this website http://stackoverflow.com/questions/5597060/detecting-arrow-key-presses-in-javascript


arrow keys are only triggered by onkeydown, not onkeypress


keycodes are:


left = 37


up = 38


right = 39


down = 40


Thanks again for the help
ispressed('down')


You should simply have added the '' - no one said anything about removing the ()
Thanks


I just tried it, but it still causes both parts of the conditional branch to run when down is pressed.  


I'm beginning to think there is no way of solving this issue,  


pic24.PNG
@mashpotato unless you have a script modifying the engine, that cannot happen - but what could happen is that something else interferes with your timing. You should place a wait(3) or so after the last end to slow down the parallel, and you should give us screenshot of the other event pages to see if something else could cause this.


Also, I suggest reading my tutorial on bughunting (see my signature) for it's background information about parallel processes.
There is absolutely a way to solve it - we're just having trouble finding the source of the issue.


If you could zip up your project, load it up online somewhere (dropbox?) and provide a link, I'll be able to grab it and have a look for you.  That will make it easier to debug than to continually ask you questions and get you to test things out.

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-doing-both-things.61581/