Gambling System

Hello again! I was planning on adding a system to a room in my dungeon. There is no door to exit once you enter, but there are 3 slot machines. The slot machines once clicked on give you 4 randomly generated answers, and chooses one answer correct, while mixing up which choice is the right one (example: have it be first option correct one play through, third option next play through etc.)
What coding would make this work?
There are two different ways to do this depending on how much javascript you know.

The first solution would be without any javascript: you'll just make a dozen different show choices commands and randomly select one of them to be presented. This would be a tedious and long event, but no problem there.

The second solution would require quite a lot of javascript and programming knowledge.
You can take the script equivalent of the show choice command and use javascript to program each option independently before triggering the command. This requires knowledge of string operations and how to write basic javascript commands at minimum.
What command can I use to make them randomly selected?
control variable: random 1..10
if variable =1 then show choice variant 1
if variable = 2 then show choice variant 2
Maybe I misunderstand the question, because I'm thinking of something along completely different lines.

You didn't fully explain your mechanic. If the correct answer is random, and the player has to get 3 random correct answers in order to progress, then it's going to be nearly impossible to do. The player would have one chance in 64 of guessing it correctly. So I would rethink your strategy on this one.

I will assume you will let the player use the one slot machine over and over until they get the right answer, then that slot machine becomes inactive. And once the slot machines are all correct, the "puzzle" is over and the player can leave the room somehow. And that this whole puzzle will only happen once.


Put these event commands onto the first slot machine

Code:
Control Variables: Random = Random number between 1 and 4
Show Choices [A] [B] [C] [D]
When [A]
  If Variable Random = 1
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
When [B]
  If Variable Random = 2
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
When [C]
  If Variable Random = 3
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
When [D]
  If Variable Random = 4
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
Branch End

Then add a second event page conditioned by self switch A, that does nothing.

Do exactly the same to the other two slot machines - same variables, same self switches.

Finally, have your "exit" or "win" event conditioned by Variable: Slot Success being greater than or equal to 3.

So what will happen is that the player will interact with slot machine 1 and guess an answer. If they guess incorrectly, they can try again, and again, until they get the correct answer. When that happens, the Slot Success variable will increase, and the slot machine will become inactive. They do the same thing with the other two slot machines. By the time they guess all 3 correctly, all machines will be inactive, the variable will be set to 3, and the "exit" event will be activated.


If you want to be able to repeat this each time you enter that room, then create one more event with a parallel process trigger, and the following event commands:
Code:
Control Variables: Slot Success = 0
Script: $gameSelfSwitches.setValue([map, event, 'A'], false);
Script: $gameSelfSwitches.setValue([map, event, 'A'], false);
Script: $gameSelfSwitches.setValue([map, event, 'A'], false);
Erase Event

and on the script lines, replace map with the map id with no leading zeros (so map 015 will be just 15), and replace event with the id of your three slot machine events, again with no leading zeros (this is the event NUMBER, not its NAME).
Thank you!
Maybe I misunderstand the question, because I'm thinking of something along completely different lines.

You didn't fully explain your mechanic. If the correct answer is random, and the player has to get 3 random correct answers in order to progress, then it's going to be nearly impossible to do. The player would have one chance in 64 of guessing it correctly. So I would rethink your strategy on this one.

I will assume you will let the player use the one slot machine over and over until they get the right answer, then that slot machine becomes inactive. And once the slot machines are all correct, the "puzzle" is over and the player can leave the room somehow. And that this whole puzzle will only happen once.


Put these event commands onto the first slot machine

Code:
Control Variables: Random = Random number between 1 and 4
Show Choices [A] [B] [C] [D]
When [A]
  If Variable Random = 1
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
When [B]
  If Variable Random = 2
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
When [C]
  If Variable Random = 3
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
When [D]
  If Variable Random = 4
    Control Variables: Slot Success += 1
    Control Self Switch A = ON
  End
Branch End

Then add a second event page conditioned by self switch A, that does nothing.

Do exactly the same to the other two slot machines - same variables, same self switches.

Finally, have your "exit" or "win" event conditioned by Variable: Slot Success being greater than or equal to 3.

So what will happen is that the player will interact with slot machine 1 and guess an answer. If they guess incorrectly, they can try again, and again, until they get the correct answer. When that happens, the Slot Success variable will increase, and the slot machine will become inactive. They do the same thing with the other two slot machines. By the time they guess all 3 correctly, all machines will be inactive, the variable will be set to 3, and the "exit" event will be activated.


If you want to be able to repeat this each time you enter that room, then create one more event with a parallel process trigger, and the following event commands:
Code:
Control Variables: Slot Success = 0
Script: $gameSelfSwitches.setValue([map, event, 'A'], false);
Script: $gameSelfSwitches.setValue([map, event, 'A'], false);
Script: $gameSelfSwitches.setValue([map, event, 'A'], false);
Erase Event

and on the script lines, replace map with the map id with no leading zeros (so map 015 will be just 15), and replace event with the id of your three slot machine events, again with no leading zeros (this is the event NUMBER, not its NAME).
New Issue: I keep getting the Syntax Error: Unexpected Identifier popup, whenever the slot machine is triggered
syntax error means that you made a typo somewhere, either mistyped or misread what you should have entered.

The only way to find such an error is to give us screenshots of what you placed where so that we can compare what should have been there.
There is nothing in the slot machine code that would cause that error, unless you tried to enter the whole thing as a script command. Those are event commands.

If you believe you've entered them correctly, please show a screenshot of your event, and a screenshot of the Console tab (hit F8 when you get the error, and go to the Console tab).

I suspect there is more in the error message than just "Syntax Error: Unexpected Identifier" - I expect it should show what the identifier was. Please make sure you always post the full error message, because the missing bit is the most important bit.
syntax.PNG
nothing of what we gave you is a script, so you should never have typed in anything as part of a script command.

everything we described used event commands to be clicked on in the event command list.
Control variable for example is one of the first commands on the first page left middle

EDIT:
I don't have time for the full variant, but this should show you your mistake:
I'm newer to RM MV, so I do not know where i would be able to access event commands. Can you post a screen shot so I know what to look for?
The Script command is an event command. If you accessed the Script command, then you were already in the Event Commands window.

That is a Control Variables event command, followed by a Show Choices event command. The "If" is the Conditional Branch event command.
OH CONTROL VARIABLE!
I am brain dead lmao.
Thank you for the help guys!
Did I do it properly?
A screenshot would be much better. If you need more than one, take more than one.

The A, B, C, D are just placeholders for whatever your slot machine is going to produce.

Play it. You will know if you've done it properly (you may have to play it over and over and over, based on what I said in my first post - that only one combination out of 64 will be "correct").

I don't see the second page in there. And I don't know if you've set up your "win" event that has the variable >= 3 as the condition.
screenshot1.PNG
Your EV004 should not have a self switch as a condition. Only the slot machines should. Give THEM a second page conditioned by self switch A, with the appropriate sprite, and no event commands.

I suggest you go through some tutorials, as using switches, variables and multiple event pages is going to be key to the progression of your game, and if you don't understand how they work, you are going to be stopping every 5 minutes to come here and ask for help.

Very interesting topic, thank you. And it is very important to know for such people as I am my work is betting and I have to know how is the atmosphere in NBA teams before betting to know if they would be in a good mood, or they have argues in the team. Argues affect the result of the game very often and other people who bet do not pay attention to this. But I do and I win. I also use promo codes form https://bet-country.com/dk/bonus/bwin to double my income.
I was always wondering how people reach the idea to involve this games in video games, you should think a bit.

Original thread: https://forums.rpgmakerweb.com/threads/gambling-system.117655/