Looping with switches randomly not working

Hello, 


I am trying to make a bar tending mini-game which involves a loop that makes one of eight patrons randomly show an explanation point bubble signaling that you need to serve that patron. That part of the program is working fine, but I have it so that whenever one of the patrons randomly shows an exclamation, a switch is triggered so that it is possible to have a variable tipping mechanism. The problem I am encountering is that even though the exclamation shows, the switches seem to randomly decide whether or not they want to be triggered. By this I mean that sometimes the switches work, and allow the player to trigger another event that serves as serving the patron and receiving a tip, but, seemingly randomly, there are times when those "serving the patrons" events will not trigger, even though the exclamation bubble shows up and therefore the switch should be switched. I have narrowed it down to the event I have included, but I cannot seem to isolate the error, because of the seemingly randomness of when the switches work and when they do not. There are 8 possible patrons, and a number between 1~8 is randomly assigned to the bartending_control variable, this then leads to the exclamation bubble being shown over the proper patron and should allow for the player to trigger that event to "serve" the patron and collect a tip. Every one of the events can be triggered, as I have discovered through testing, but as I said, seemingly at random, the events do not always work. I assume that there must be an issue with my looping, but I just cannot figure out what it could be. I would greatly appreciate it if another set of eyes could take a look and tell me if there are any obvious errors. It may be a bit sloppy because I tried changing up several different things to see if they might be causing the error, but I have had no luck. Thank you for reading.

loopswitcherror.jpeg
There is no randomness in a computer, it always has a cause.


Unfortunately your information doesn't help, because the usual causes for switch problems are not visible in the picture you gave:


The most often cause is either a double use of a switch (for example when one of your plugins needs a switch and you didn't reconfigure the default switch number of the plugin to an unused switch), or if the page priority on the event controlled by the switch is mixed up.
I know that there is no randomness in a computer and that is why I am having so much trouble and why I said it seemed to be random. I'm not using any plugins. Page priority is in proper order as far as I can tell, like I said, each of the 8 events works, just not every time. Here are some more pictures of the events in question, in the pic in my first post, at the end it turns off a self switch because I had the "Bartending_minigame" event as a page in another event, I have changed that to it's own event and the same error is happening. Instead of turning off self switch d in the last line, it now turns off a var called bartending_minigame. I would also like to add that I know it is not from the "serving#" events because I have tried it with only a text prompt and the same error happens. Thank you for the quick reply.


bartending_minigame.png


serving1.png


serving2.png


serving3.png


serving4.png


serving5.png


serving6.png


serving7.png


serving8.png
Alright, well, I have no idea how, but apparently the events that I had representing the patrons were all labeled incorrectly. Probably because I made those events when I had very little sleep. Anyways thank you for the response Andar. This has been solved.
OK, but one more tip:


you don't have to use every switch and variable, you can skip some.


And that would have been a lot better here, skipping some switches and variables to get the numbers aligned - switch 28 and variable 28 for event 8 instead of switch 27 and variable 29 for it.

Original thread: https://forums.rpgmakerweb.com/threads/looping-with-switches-randomly-not-working.56670/