Hello, I am having a problem with trying to loop a code 4 times and then making the counter activate after the 4th turn and doing its job?
Check if Turn counter is changing with each turn. It might always be at zero causing an infinite loop.
No it is not counting.
Where are you incrementing “TurnCounter?”
Turn counter needs to equal turn current turn counter + 1 with each new turn.
I was following : https://www.youtube.com/watch?v=3XJ8J94zmKw&t=1929s
And this how the looping for each turn was done. I tried to add a turn variable but to no luck.
How would I set that up exactly?
You would need to increment it during the end round just before the call functions. (though the amount to check with the modulo will depend if the number starts from 1 or 0)
The video shows them looping based on whether or not the “RoundOrder” array is empty, you’re looping based on whether or not 4 % TurnCounter is not zero.
Ryan (the youtube guy) is ensuring there’s not an infinite loop by removing the first element of the “RoundOrder” array on every pass, but you’re not doing anything to change the value of TurnCounter.
If TurnCounter was initialized to anything other than zero, or a multiple of 4, (so 1, 2, 3, for example) that branch is true and it runs the minigame event.
If TurnCounter was initialized to 0 or a multiple of 4, the branch will execute the TurnEnded and CollectTicket events.
The problem is you’re not changing TurnCounter. After every turn, you need to increment it. That’s the only way to get different execution paths from the branch.
I may also be wrong about the “truth” value of “4 % TurnCounter” if TurnCounter is greater than 4 I think it always fails… I think you may want the other way: “TurnCounter % 4” or really just test for TurnCounter < 4.
So, just to be clear, it looks like you want, after (or on) turn 4 that, instead of looping, it executes a minigame?
I think something like this, maybe…
EDIT: @3dRaven is right! you want to do that increment BEFORE call the event dispatchers…
And again, not exactly sure what you’re trying to accomplish 3 times, and what you want a final time through the loop, so maybe you’d swap true/false paths.