I think my game is stuck in a loop

Status
Not open for further replies.

alltheyuriz

They System is overrated
Veteran
Joined
Sep 18, 2020
Messages
448
Reaction score
247
First Language
English
Primarily Uses
RMMZ
Okay so I tried the method i used on the faux menu because that worked but it won't work for what im trying to do now which is activate a movement route when a button is clicked. It just takes me to the else. can you help me out here is a screen shot of the event

1623534656058.png

Edit: Also it doesn't wait til the box is closed before you hit the button to do the thing, how do i stop that would I use wait?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,692
Reaction score
8,495
First Language
German
Primarily Uses
RMMV
the button press in the conditional branch only checks if the button is pressed during a single frame, the frame when the event runs.
to wait for the press it needs to be inside a parallel or a loop.

also, please use better titles - everyone around here is looking for help and such titles are useless, better tell us what kind of help you're looking for in the title.
 

alltheyuriz

They System is overrated
Veteran
Joined
Sep 18, 2020
Messages
448
Reaction score
247
First Language
English
Primarily Uses
RMMZ
okay thank you and i'm sorry i'll think up a better title while i see if this works

Edit: @Andar I just realized I do not know how I would set that up could you help me with an example?
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,692
Reaction score
8,495
First Language
German
Primarily Uses
RMMV
the loop should have two options checked by conditional branches that will contain a break loop command plus whatever the options are.

the first one is the button pressed, which gives a signal or whatever to show that the button has been pressed (for example turning a switch) before breaking the loop.

the other option would be a timeout, counting a variable up by +1 each loop until it is high enoug to cause the timeout break loop
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,759
Reaction score
2,109
First Language
EN
Primarily Uses
RMMZ
E.g. something like this:

◆Text:None, None, Window, Bottom : :Press the dash/shift key to continue. ◆Loop ◆If:Button [Shift] is being pressed ◆Break Loop ◆ :Else ◆Comment:Check again next frame ◆Wait:1 frame ◆ :End ◆ :Repeat Above ◆Text:None, None, Window, Bottom : :Great, now you're ready to save the world!

The Wait command is very important here, otherwise the game will try to "complete" the loop in a single frame...which is pointless because the input only updates once per frame. :kaoswt2:
 

alltheyuriz

They System is overrated
Veteran
Joined
Sep 18, 2020
Messages
448
Reaction score
247
First Language
English
Primarily Uses
RMMZ
E.g. something like this:

◆Text:None, None, Window, Bottom[/INDENT] [INDENT]: :Press the dash/shift key to continue.[/INDENT] [INDENT]◆Loop[/INDENT] [INDENT] ◆If:Button [Shift] is being pressed[/INDENT] [INDENT] ◆Break Loop[/INDENT] [INDENT] ◆[/INDENT] [INDENT] :Else[/INDENT] [INDENT] ◆Comment:Check again next frame[/INDENT] [INDENT] ◆Wait:1 frame[/INDENT] [INDENT] ◆[/INDENT] [INDENT] :End[/INDENT] [INDENT] ◆[/INDENT] [INDENT]:Repeat Above[/INDENT] [INDENT]◆Text:None, None, Window, Bottom[/INDENT] [INDENT]: :Great, now you're ready to save the world!

The Wait command is very important here, otherwise the game will try to "complete" the loop in a single frame...which is pointless because the input only updates once per frame. :kaoswt2:
okay so it works but you have to hit the s button super quick and what if i put wait under break loop? i don't know how long to make it wait is the thing
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,759
Reaction score
2,109
First Language
EN
Primarily Uses
RMMZ
okay so it works but you have to hit the s button super quick and what if i put wait under break loop? i don't know how long to make it wait is the thing
I'm not sure how to interpret this. Are you talking about:
  1. How long the button has to be held?
  2. A delay before and/or after the input check?
  3. Something else?
Break Loop will immediately jump to the command after the end of the loop: Show Text in this case.
 

alltheyuriz

They System is overrated
Veteran
Joined
Sep 18, 2020
Messages
448
Reaction score
247
First Language
English
Primarily Uses
RMMZ
@caethyril 2 a delay after the text so they have time to press the button before the wrong button thing comes up
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,759
Reaction score
2,109
First Language
EN
Primarily Uses
RMMZ
Oh, I see! As-is, the example I posted should wait forever until the player presses the right button.

This can be used to check if any button is being pressed in Conditional Branch > Script:
JavaScript:
Object.values(Input.keyMapper).some(key => Input.isPressed(key))
Might be helpful if you wanted to wait until any key is pressed, then fail if it's not the correct key, e.g.
Code:
◆Comment:Wait for no keys pressed
◆Loop
  ◆If:Script:Object.values(Input.keyMapper).some(key => Input.isPressed(key))
    ◆Comment:Some key is being pressed
    ◆Wait:1 frame
    ◆
  :Else
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Comment:Wait for any key press
◆Loop
  ◆If:Script:Object.values(Input.keyMapper).some(key => Input.isPressed(key))
    ◆If:Button [Down] is being pressed
      ◆Text:None, None, Window, Bottom
      :    :Yay
      ◆Comment:Success
      ◆
    :Else
      ◆Text:None, None, Window, Bottom
      :    :Nay
      ◆Comment:Fail
      ◆
    :End
    ◆Break Loop
    ◆
  :Else
    ◆Wait:1 frame
    ◆
  :End
  ◆
:Repeat Above

To add a timeout instead (or as well?), you can use a variable to count down the frames and show the "fail" message when it hits 0, e.g.
Code:
◆Comment:5 seconds = 300 frames to press the button
◆Control Variables:#0023 time = 300
◆Comment:Ask for input
◆Text:None, None, Window, Bottom
:    :Press [down] to walk.
◆Comment:Check for input
◆Loop
  ◆If:Button [Down] is being pressed
    ◆Comment:Success!
    ◆Break Loop
    ◆
  :Else
    ◆Comment:1 frame closer to failure
    ◆Control Variables:#0023 time -= 1
    ◆If:time ≤ 0
      ◆Comment:Time's up!
      ◆Break Loop
      ◆
    :Else
      ◆Comment:Check again next frame
      ◆Wait:1 frame
      ◆
    :End
    ◆
  :End
  ◆
:Repeat Above
◆Comment:Say something
◆If:time > 0
  ◆Text:None, None, Window, Bottom
  :    :Congratulations! You learned the "Walk" skill!
  ◆
:Else
  ◆Text:None, None, Window, Bottom
  :    :OK I guess you're staying here.
  ◆
:End
For timed stuff you might find this tutorial helpful~

(It's ~01:40 here so I'm going to bed now.)
 

alltheyuriz

They System is overrated
Veteran
Joined
Sep 18, 2020
Messages
448
Reaction score
247
First Language
English
Primarily Uses
RMMZ
@caethyril I really appreciate the help but it's just not working
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,355
Reaction score
15,171
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.



@alltheyuriz we usually like it if people who got solutions elsewhere post the final solution before having the thread closed. Means other people who have a similar issue and find your thread here can see what they need to do.
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Added a small refining scene to my game.

It makes sense that you try to focus on the squishy mages at the back of the party first, right? If the mage can out-DPS the enemy DPS before the latter can kill the tank in front, the fight becomes boring.
finally got footage of my main character running around the main hub world. I've fixed a few things tho even since this video unsurprisingly lol.
 …I think I might need to switch from standard ATK/DEF up/down buffs to parameter altering states. I just had an actor whose usual attack against an enemy does ~25 do a buffed attack against a debuffed enemy for ~600…
just saw that titan quest is free on steam until the 23rd

Forum statistics

Threads
115,228
Messages
1,088,251
Members
149,824
Latest member
Shin092
Top