Tutorial by Carrigon
sims2Workshop.com
Full credit to CACAO for his Mini Game Scripts
http://cacaosoft.web.fc2.com/
Beginners Level Tutorial:
This tutorial will show you how to add a mini Casino Slots game to your own game. I don't even have to translate this one. I can show you how to add CACAO's Slots mini game script in a quick, easy beginner's level way.
This tutorial uses CACAO's Casino Slots Mini Game script demo.
http://cacaosoft.web.fc2.com/tkool/script/rgss3/pslot.html
Yes, he does allow shareware use of his script for your games, but you must give him credit and a link back to his site and TOS.
http://cacaosoft.webcrow.jp/rule.html
http://cacaosoft.web.fc2.com/
What you will need: You must download CACAO's demo from here:
http://cacaosoft.webcrow.jp/sample/file/rgss/pslot_ace.zip
The reason I want you to download his demo, even though you probably don't speak Japanese, is because you will need both the script and the picture files from it. Plus, his examples will show you more ways to work with the code. Even if you don't speak the language, you should look at his examples if you want to try different things from what I'm going to show you. Get the demo, don't just get the script because without his picture files, it's just going to error on you, unless you're experienced enough to know where to take that out of the code.
Step one: Download the demo from CACAO's site.
Step two: Copy the script into your game from the demo. Put it in the usual place, under Materials, but above Main. Copy the picture files into Graphics/Pictures.
For this tutorial, we aren't actually using the pictures at all. We are using your iconset. For beginners, that's the pictures you use when you make a new item in the game. To find the number of each icon picture, go into items, click on where you would change the item's picture, you will see how the icons are numbered. You can use any icons you want to or even make your own on your icon sheet. This tutorial only uses eight icons. They can be done in any order you like.
To edit the script: We are using the section CACAO calls Pattern 2. This is what we are calling in the event. Look for this:
PATTERN[2] = [ # ????
:icon, nil, "", "",
[184,185,186,187,188,189,190,191],
[191,188,186,190,187,184,189,185],
[188,184,189,191,186,190,185,187],
The numbers are your icon numbers on your icon sheet. Pick eight icons you want to use. Change the numbers here. Follow how it was done here. The first line is your first row for the slots. See how the second line uses the same numbers, but your icons are now moved. Follow doing it this way for all rows, no matter what icon numbers you are using. Like if you're using fruit, you have grapes, lemons, apples for the first row, then for the second row you would have lemons, grapes, apples and so on. It is important to follow how this was done here or your slots probably won't work right for you. They won't line up right.
Step three: Most all the coding is done in the Event. I'll give you a screenshot from my game of how to do it.
The only things I've edited in the script for my game were to put my own icon numbers in, and to change the speed of how fast the slots go. This is a really important point to remember. Everyone's computer may not be the same speed. You might have a player whose pc will run this so fast that it's impossible to play the slots. Or you could get someone whose pc is slower. It's really best to set the speed to one. You can experiment with that. I would recommend adding an option for the player to skip the puzzle in case they really cannot do this on their pc. I've included that in my event.
You can edit the speed in the script here:
DEFAULT_SPEED = 4
I changed that to a 1.
Basically, my event has it set so that when the player wins, my game switch is turned on. And then I give them an option to play again unlimited for fun and gold. For my game, I'm using fruit icons. I'll also tell you the trick to winning if it's going by a bit fast, look at the icon that comes before the one you need to click on, click when you see that one and most of the time you can get it.
This is what we are calling in the event:
start_pslot(2, pos: 2)
p SceneManager.result
But you need to look at how I did it in my screenshot. If you follow my event exactly, you shouldn't have any problems with this at all. It will do what it's supposed to do. And there are many things you can do with the event. You can give your player a prize on winning instead of just turning on a switch. My way is just a typical game event way.
To learn other things you can do with the script, study CACAO's examples in the demo. You can add pictures, you can make it look like a real slot machine. There are other ways of controlling the speed of the slots and he gives examples of that.
CACAO's script fully supports using a mouse, if you have a mouse script working in your game, just put the mouse call at the top of the event. See my event screenshot.
Screenshots here:
My Event:

Game Screens:



