Pokémon SDK Wiki
Credits

Mining Game (Diamond/Pearl/Platinum mini-game)

This tutorial will give everything needed to successfully launch and operate the Mining Game system. It'll include the way to launch the mini-game, setup the number OR the list of item(s) to find, and of course how to add new items to the system. You will even be able to easily customize the music played during the mini-game. Finally, this tutorial will talk about the little secondary features which may be useful to you.

Launch the Mining Game

To launch the Mining Game, you only need one command. You simply need to call the command mining_game in your event and PSDK will handle everything (your player will have to possess the Explorer Kit in order for the Mining Game to begin). It's also possible to give parameters to this command. Two routes exist: the first one is to give a number as the parameter, while the second is an array containing the wanted items. The next chapters will show how this is done.

First Route: Pick the number of items to be dug up.

Let's see an example on how to write this command:

mining_game(4, 'audio/bgm/alternate_music', delete_after: false)

Here, we gave it three arguments:

Second Route: Tell the item(s) you want

This specific way is useful in some cases: for example, you can create some types of events in which the player must retrieve a special object in the Mining Game. You can then check if the player did find the item and delete the event accordingly. Let's see how we can tell the system what we want:

mining_game([:fire_stone, :claw_fossil, :yellow_shard])

Here, we have only one argument:

So, for example, if you want to launch a game with the four primary evolutionary stones, you'll have to write this : mining_game([:fire_stone, :water_stone, :leaf_stone, :thunder_stone])

Change the "Do you want to mine that?" texts

The system possesses two different texts concerning the "Do you want to mine that?". By default, the system will assume your event is a wall (in D/P/Pl you mine in wall) and so the message displayed will concern mining into a wall. But, it is possible, by changing the name of your event, to change the text displayed. To do that, you just have to rename your event miningrock. That's all there is to it.

Add new items to the Mining Game

In this section, we'll talk about how you can add your own items in the Mining Game database. First, we'll talk about how your resource should be, then we'll talk about how to script it in the database (it's really easy, you'll see).

Create the resource for the item

First, before creating your resource, you need to know some things: the system uses resources based on a 16x16 grid and the system itself does NOT detect if the image is placed correctly in the grid or not. It'll be your job to do it right. Now, let's see an example:

PlaceItemInGrid
Placing your Item in a Grid

As you can see, the item is placed within a grid of 16x16 squares. The image's width and heigth should consequently be divisible by 16. Please make sure you respect this.

tip!

When you're done with creating it, name it after the db_symbol of the item and save it in graphics/interface/mining_game/items. Example, the image for the Water Stone is named water_stone.png.

tip! tip!

Create an entry for an item in the Mining Game database

Now that we have the needed image we can insert your item into the Mining Game. To that end, you'll have to create a new script in the scripts folder of your project. If you don't know how to do that, we suggest you check the written tutorial about that: Install a script Tutorial

Create a new script in your scripts folder, name it how you want as long as it respects the norm described in the linked tutorial, then paste this in it:

module GameData
  module MiningGame
    register_item(:your_item, 20, [[x,x,x],[x,x,x],[x,x,o]], 3)
  end
end

Here, 4 arguments are ABSOLUTELY necessary, let's explain each one of those:

GoodGrid
Get the right pattern for your item
As you can see, the red squares indicate where your item exists in the pattern (signified in the argument as a x) while green squares indicate that your item does not exist in that square (signified in the argument by a o). To write the pattern correctly, first write the first [], then inside it write one new [] per line. In the case of that image, the pattern will be the following: [[o,x,x,x,o],[o,x,x,x,o],[x,x,x,x,x],[o,x,x,x,o]]
Even if your item has one line only, you must write it with two [], like that [[x,x,x]].

Create an entry for an iron (obstacle) in the Mining Game database

Creating an iron in the Mining Game database follows the same logic as for the items, just for one difference. Instead of copying the code given in the previous chapter, please copy this one.

module GameData
  module MiningGame
    register_iron(:your_iron, 20, [[x,x,x],[x,x,x],[x,x,o]], 3)
  end
end

Here, the arguments are the same, unless for the first: now, you have to put the symbol corresponding to the name of the image of your iron.

Unlock the dynamite, access the statistics for the Mining Game and activate the Hard mode

Yes, you read that right: PSDK's Mining Game has dynamite, statistics AND a Hard mode. Some commands are available for you to access everything. Here is a list:

tip!

Here is everything you need to know about the Mining Game! Have fun with it, and good luck mining!!