How do I use an if statement within a while loop?

Get help using Construct 2

Post » Mon Aug 17, 2015 1:56 am

Hi guys.

I'm rewriting a game so that dialogue is done via a while loop. I'm not of high enough reputation to link anything yet, so I'm going to describe what I have as clearly as I can. Hopefully you will be able to help!

There is a global variable called dialog. As long as this variable is less than or equal to 5 (the number of dialogs a player will click through when talking to a particular NPC), while (dialog <= 5) is true and still running. Now inside of the while loop, if the player clicks the 'next dialog' button, the next dialog should show up and the dialog variable should increment by 1. This does not go as planned, however. When I try starting the game, the screen stays black and it hangs at a percent. I'm guessing this is because the while loop never has a chance to stop itself.

I don't know how to fix this. I've tried all day with no luck. Any takers? That is literally all I have by the way. There aren't any other variables or things to worry about. I figured I'd narrow the issue down to make it work. But...I'm stuck.
Posts: 1
Reputation: 177

Post » Mon Aug 17, 2015 5:28 am

@agaman - Does sound like you have an infinite loop there...

You don't really need the while loop. An Event sheet automatically loops already. At the start of layout, just show the first dialog. Then have an event for when the player clicks the next button to increment the global variable and display the next dialog.

Kyatric just did a tutorial on making a dialog system last month:

so you might want to check that out.
Posts: 438
Reputation: 17,950

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests