Gambling System

carnorantor

Villager
Member
Joined
Jan 25, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
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?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,230
Reaction score
6,774
First Language
German
Primarily Uses
RMMV
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.
 

carnorantor

Villager
Member
Joined
Jan 25, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
What command can I use to make them randomly selected?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,230
Reaction score
6,774
First Language
German
Primarily Uses
RMMV
control variable: random 1..10
if variable =1 then show choice variant 1
if variable = 2 then show choice variant 2
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,488
Reaction score
12,033
First Language
English
Primarily Uses
RMMV
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).
 

carnorantor

Villager
Member
Joined
Jan 25, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
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
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,230
Reaction score
6,774
First Language
German
Primarily Uses
RMMV
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,488
Reaction score
12,033
First Language
English
Primarily Uses
RMMV
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,230
Reaction score
6,774
First Language
German
Primarily Uses
RMMV
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:
 

Attachments

Last edited:

carnorantor

Villager
Member
Joined
Jan 25, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
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?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,488
Reaction score
12,033
First Language
English
Primarily Uses
RMMV
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.
 

carnorantor

Villager
Member
Joined
Jan 25, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
OH CONTROL VARIABLE!
I am brain dead lmao.
Thank you for the help guys!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,488
Reaction score
12,033
First Language
English
Primarily Uses
RMMV
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,488
Reaction score
12,033
First Language
English
Primarily Uses
RMMV
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.

 

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

Latest Threads

Latest Profile Posts

This forum is a great source of procrastination for me.
Today I read "The mouth speaks what the heart is full of." Simple, and reminds me I have a ton of work to do.
Why are cats so darn cute when their tongues are sticking out? If I did that, it wouldn't have the same effect.
The joy when you see a notification, the down when it's just a unnecessary quote of one of your posts again.

Forum statistics

Threads
94,399
Messages
920,619
Members
124,179
Latest member
mybriguy
Top