How to wait/pause until [...]

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Hi. Is it possible for us to pause at a particular part in code until another condition becomes true?
Or alternatively, prevent the playable character (and potentially other events) from moving until another condition becomes true?


For example:

> Text: Hello
> Change Variable 2 = 10
> Wait until [Shift] button is pressed
> Text: Bye


In the past I tried using a loop:

*Loop
> If: Button [Shift] is pressed down { do something }
> If: Button [Cancel] is pressed down { Break Loop }
*Repeat Above

But it can be laggy and I don't think it's quite efficient.

I also came across a setInterval method:
Code:
var wait = setInterval(click, 2000);

function click() {
  console.log("Hi");
  if (TouchInput.isTriggered()) {
  clearTimeout(wait);
  }
}
but after it reaches the code above, it moves on to the next Event Command (while outputting "Hi" every 2 seconds until I click somewhere).

What I am currently trying to achieve is to prompt the Player with "select where I should go", whereby the Player clicks somewhere on the map (via mouse or touch) and an event (the "I" from the message) - not the Player - moves to the coordinates of the click.

I'm not sure of a good way to "pause" the game to await a particular input.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
Stopping player input or movement is not the same as pausing the game - and a simple loop is even worse than a wait.
This might sound as a useless technical difference for people who aren't programmers, but it is a very important distinction and the reason why some of your tries didn't really work.

There are several different ways to simulate something to the player depending on what exactly is needed.

In your last case I wouldn't pause at but do something entirely different:
Have events pretending to be the actors placed on their current position, disable follower display, change actor 1 sprites to the cursor.
Then the player/cursor can go to the point selected, and you just have to remember to change the party back to normal at the coordinates you want.
The player will never know that the cursor was bis party if it is done correctly
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
Its the Loop.
If your Event is on Auto Run, than the Player cant move aslong as the Eventpage is executed.
Than the Loop for the Button Input, but you need a 1Frame Wait, else you create an Endless Loop which would result in game crash.
1Frame not more, else the button whill not be recogniced fluently.

I believe other Events will continue there Autonomous Moveroute but iam not sure.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
@Andar @Bex

Okay, so I tried implementing your suggestion, Andar, and it basically works - just need to fine-tune stuff. However my set-up involves the event-to-be-guided calling a common event to alter the player image, etc, then enabling a parallel event that awaits for a touch trigger, moving the icon (player) to that location, then (how I have it set-up at the moment) having an enabled switch activate a page on the event-to-be-guided to move to that same location. Then clean-up stuff afterwards.

The 1-frame wait loop method is way simpler, though lacks the fancy icon visualisation at the moment. I should be able to fine-tune both further, but can you inform me of downfalls to using the 1-frame wait method? From my perspective, I don't know what foreseeable errors can happen.

Also, for the sake of learning, are there alternatives to this with javascripting? (Like the setInterval method I tried).
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top