Hey Ansilvund216, I'll try and break it down and let me know if there's still anything you're not sure of.

**I also realised half-way through writing this that there's a simpler way, I reckon. Skip down to ***Using Game Variables*.
I'm assuming you've set up box 3 (for example), and that you get that bit, and that's working.

The following is also assuming you've created an event (and are triggering it somehow), and we're now working in the event's scripbox:

To add an item to a box, you use the following code. The first part ($game_boxes.add_item) has been defined by me, and is a way I've set up for people to use my script. The part in the round brackets (separated by commas) are specified by you. The first is the item to add, the second is how many to add, and the third is which box to add it to.

Code:

`$game_boxes.add_item($data_items[4], 12, 3)`

So this will add 12 copies of item #4 into box 3. If you want to add a weapon, change $data_items to $data_weapons. If you want to add armour, change $data_items to $data_armors. You can change the 4 to be the id of whichever item you want to add. You can change the 12 to be how many of the item you want to add, and you can change the 3 to which box you want to add the item to.

So far, so good?

To add a

**random amount** of an item, we will need to use a ruby function called rand (short for random).

The random function returns a number between 0 and whatever number we give it. This can include 0, but cannot include the number we give. So if we want to simulate rolling dice (on a fair six sided die), we would use

rand(6). But this would return a number from 0-5. So if we wanted a number from 1-6, we just have to add one to the result. So

rand(6) + 1 will return a random number from 1-6.

If we wanted a more complicated random number, like a random number between 10 and 15, we would have to do a bit of mental maths. the

rand function can only do 0 to whatever number, but we want to start with 10, so we're going to have to add 10 to the result. So if we do

rand(15) + 10, then we get a random number from 0-14, and then add 10, getting something from 10-24. Whoops! That's not what we want. What we actually want is

rand(6) + 10. Because then we get a random number starting from 10, and going up to 10 + 6, in this case 16. The reason it's 16, and not 15, is because we want to include 15 in our possibilities.

So to add a random number between 15 and 25 of weapon #2 to box number 8, we would use the following:

Code:

`$game_boxes.add_item($data_weapons[2], 15 + rand(11), 8)`

Hopefully you get up to here. Now we'll move onto adding

**random items**. Because we get the item/weapon/armour we want using its ID (which is a number), we can use the same technique. The following code will add 2 of the a random item from 1 to 6 into box 11.

Code:

`$game_boxes.add_item($data_items[1 + rand(6)], 2, 11)`

And of course you can combine the two above approaches.

However, there is a more advanced way to get different random numbers. Also, I'm now realising that you can do all of this randomness in events, so maybe that's the best way.

**Using Game Variables** is probably the way that's simplest to do this for non-scripters.

If you, using eventing, set game variable 15 (for example) to the ID of whichever item you want to add (using events to get random item IDs), and set game variable 21 (for example) to the amount you want to add, then you can use the following code to get what you want (adding to box 3 for example):

Code:

`$game_boxes.add_item($data_items[$game_variables[15]], $game_variables[21], 3)`