tomkomaster

Veteran
Veteran
Joined
Sep 19, 2015
Messages
151
Reaction score
8
First Language
English
Primarily Uses
RMVXA
The script works flawlessly for me, even with nearly all add-ons for it. Are you sure you're writing the name tag correctly in the script? For example:
name: "Drawer",

or for a whole box setup:

{
name: "Drawer",
size: 10,
},
 
Last edited:

Millu30

Warper
Member
Joined
Jul 14, 2015
Messages
2
Reaction score
0
First Language
Polish
Primarily Uses
Ouu I was typing like this
Code:
$game_boxes.setup(7, Shelf, 5)
and not like this
Code:
$game_boxes.setup(7, "Shelf", 5)

I didn't know that I need quote mark in the name, Thanks !
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Glad you managed to fix it! Hope you're enjoying the script.

Also, thanks vFoggy for your addon stuff. I've linked to the request thread in the OP.

EDIT: I've also made some updates today. You can use :party as the box id for the remove_all and transfer_all methods. Which means you can move all the player's items into a box (or vice versa).

You can also now have a Take All option! Or even a Take 10 (for example). Let me know if you have any problems with any of this new stuff. The updates pertain to the base script and the item sizes addons, so update bost of those if you're using them.

*****

Minor Update:

I've done some little fixes and tweaks to the scripts. They've all been updated, so if you're using any then you should get the latest versions. The most notable change is that boxes that are created 'dynamically' with the setup method in a script call are now saved properly! Before their name and sizes would be reverted to the default values when you load a savegame, but this should be solved now.

Also, I realised that both the Theft and Type addons added new parameters to the setup method, so if you're using both, then put the type list before the theft probability.
 
Last edited:

tomkomaster

Veteran
Veteran
Joined
Sep 19, 2015
Messages
151
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Thank you, IMP1, for the updates of the scripts, and especially for the Take All option. As soon as I get home from work, I will try all of them.

A while ago, I requested another addon for this script, and Another Fen was kind enough to write it. Its an addon, which adds the possibility of setting some storage boxes to be "shared boxes", meaning you can transfer items between your save states. There is even a compatibility patch for Vlue's item randomization script if you're using it like me. You can find the addon and the patch in this link (post #12).

EDIT:

I've tested the new versions of the main script and Item sizes addon (I personally don't use the other two add-ons), and both works for me flawlessly :)

There are 2 minor notes, however:
1 - Currently, the Item sizes and the gold withdrawal addons doesn't work together, as both you, IMP1, and vFoggy provided a fix to the old version. I managed to combine them into one script, if someone wants to use both the item sizes and gold withdrawal addons together, like me.

Code:
#==============================================================================
# Storage Boxes Addon: Item Sizes v1.4
#   by IMP1
#------------------------------------------------------------------------------
# THIS SCRIPT REQUIRES THE 'STORAGE BOXES' SCRIPT BY IMP1
#------------------------------------------------------------------------------
#   Compatability:
#
# Aliased Methods:
#   IMP1_Game_Boxes.fullness
#   IMP1_Game_Boxes.space_for
#   IMP1_Game_Boxes.capacity
#   Scene_ItemStorage.can_move_item_to_inventory?
#   Window_BoxTitle.refresh
#
# New Methods/Fields:
#   Window_BoxTitle.draw_inventory_amount
#
# Overwritten Methods:
#   none.
#
#------------------------------------------------------------------------------
#   Version History:
# v1.4 [2018/04/04] : Added capacity method as well.
#                     Added compatibility for gold withdrawal addon. (by vFoggy)
# v1.3 [2015/06/27] : Use updates to base script.
# v1.2 [2014/11/16] : Fixed bug where inventory limit would not update.
# v1.1 [2014/11/15] : Added and displays the player inventory limit.
# v1.0 [2014/11/14] : Initial release.
#==============================================================================

#==============================================================================
# Game_Boxes
#==============================================================================
class IMP1_Game_Boxes
  #--------------------------------------------------------------------------
  # Returns the space in a box.
  #--------------------------------------------------------------------------
  # Changes:
  #   * Added condition, if item is :gold only 1 is added to the total size.
  #--------------------------------------------------------------------------
  alias :default_size_fullness :fullness unless $@
  def fullness(box_id)
    if $imported[:Theo_LimInventory]
      i = 0
      box(box_id).each do |item, amount|
        if item == :gold
          i += 1
        else
          i += item.inv_size * amount
        end
      end
      return i
    else
      return default_size_fullness(box_id)
    end
  end
  #--------------------------------------------------------------------------
  # Returns true if there is enough room for multiple items.
  #--------------------------------------------------------------------------
  # Changes:
  #   * Added condition, if the item is :gold the amount is set to 1 (gold
  #     counted as 1 in boxes).
  #--------------------------------------------------------------------------
  alias :default_size_space :space_for unless $@
  def space_for(item, amount, box)
    if $imported[:Theo_LimInventory]
       if item == :gold
        amount = 1
      else
        amount *= item.inv_size
      end
    end
    return default_size_space(item, amount, box)
  end
  #--------------------------------------------------------------------------
  # Returns how many of said item can fit into the box.
  #--------------------------------------------------------------------------
  alias :default_size_fit :how_many_fit unless $@
  def how_many_fit(item, box_id)
    if $imported[:Theo_LimInventory]
      return (capacity(box_id) / item.inv_size).to_i
    else
      return default_size_fit(item, box_id)
    end
  end
 
  #--------------------------------------------------------------------------
  # Returns the remaining space in a box.
  #--------------------------------------------------------------------------
  alias :default_size_capacity :capacity unless $@
  def capacity(box_id)
    if $imported[:Theo_LimInventory]
      $game_party.free_slot
    else
      return BOXES[box_id][:size] - fullness(box_id)
    end
  end
 
end # IMP1_Game_Boxes

#==============================================================================
# Scene_ItemStorage
#==============================================================================
class Scene_ItemStorage
  #--------------------------------------------------------------------------
  # Returns true if there is enough room in the player's inventory.
  #--------------------------------------------------------------------------
  # Changes (For gold withdrawal addon):
  #   * Added variable item_size that stores the size of the item. If it is
  #     :gold its size is set 0.
  #--------------------------------------------------------------------------
  alias :default_can_move? :can_move_item_to_inventory? unless $@
  def can_move_item_to_inventory?(item)
    return false if !default_can_move?(item)
    space_in_inventory = true
    if $imported[:Theo_LimInventory]
      item_size = item == :gold ? 0 : item.inv_size
      space_in_inventory =
          $game_party.total_inv_size + item.inv_size < $game_party.inv_max
    end
    return space_in_inventory
  end
 
end # Scene_ItemStorage

#==============================================================================
# Window_BoxTitle
#==============================================================================
class Window_BoxTitle
  #--------------------------------------------------------------------------
  # Draws the contents.
  #--------------------------------------------------------------------------
  alias :non_limited_inventory_refresh :refresh unless $@
  def refresh(*args)
    non_limited_inventory_refresh(*args)
    if is_inventory_title?
      draw_inventory_amount
    end
  end
  #--------------------------------------------------------------------------
  # Displays how full the inventory is.
  #--------------------------------------------------------------------------
  def draw_inventory_amount
    if $imported[:Theo_LimInventory]
      text = "#{$game_party.total_inv_size}/#{$game_party.inv_max}"
      draw_text(0, 0, (Graphics.width/2)-32, line_height, text, 2)
    end
  end
 
end # Window_BoxTitle

2 - The new storage box script doesn't work with TheoAllen - Command Help Popup script, as it gives this error, when the new "Take all" window is created and then selected something on it (either the take 1 or take all option):

Script 'Theo Command Help' line 96: RGSSError occurred.
disposed window

I cannot fix this, so if you or someone could provide a simple compatibility patch, I would be grateful.

Link to Theo Command Help script


Sorry for the long post.
 
Last edited:

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
I think i've incorportated your gold-only-counts-as-one-item fix in to the base script, and I also think I've fixed the incompatability with Theo's script.

I've also added an option to keep the Take One, Take 5, etc. option open if there's still enough of the item in the box.

I guess next will be the same system but for putting /into/ the box.

Let me know if there any (other) problems.
 

tomkomaster

Veteran
Veteran
Joined
Sep 19, 2015
Messages
151
Reaction score
8
First Language
English
Primarily Uses
RMVXA
Yes, both the bug and incompatibility is fixed, thank you, IMP1 :)

And while you're adding buttons to it, it would be nice to have a "deposit all" button on the left side (your inventory), and a "withdraw all" button on the right side (storage box), where you could either deposit all your stuff from your inventory into the box and vice versa with a push of a button.
 

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Storage Boxes 1.9
by IMP1

Link to Script

Description:
Storage boxes allows you to set up containers (barrels, chests, banks, whatever you want) that can hold items. You can specifiy a limit for how many items a container can hold, and a name for a container. This script also includes a scene whereby you can move items between a container and the party. You can specify an item to be unstorable in its notebox, and set it so all key items are unstorable.

Screenshot(s):
8ZmsPWj.png

(Forgive the funky windowscreen)

Instructions:
Copy the script from the link and paste it into a new script in your project, above Main Process, and below Materials

Credit:
IMP1

Add-ons:
vFoggy has written some scripts to better allow gold withdrawals from boxes, as requested by tomkomaster, here.

Coming Soon:
  • Box organisation
Nice Script by the way, how do i change the width of the window, Im thinking of fallout 4 like loot size window
 

Waveclaw

Veteran
Veteran
Joined
Apr 20, 2018
Messages
114
Reaction score
19
First Language
English
Primarily Uses
RMVXA
Can anyone make a demo for this?
 

Waveclaw

Veteran
Veteran
Joined
Apr 20, 2018
Messages
114
Reaction score
19
First Language
English
Primarily Uses
RMVXA
after I quit the game and load a save, I stashed an item that was already stashed in the box (x1), and now, there are 2 slots of the same item both x1
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
@Ansilvund216: Glad you like it. Not sure exactly about Fallout 4, but the code that sets the size of the windows are on lines 869, 924, and 982. They all look a bit like this:

Code:
  def initialize
    y_pos = fitting_height(IMP1_Storage_Boxes::HELP_WINDOW_LINES)
    super(x, y_pos, Graphics.width/2, fitting_height(1))

You can play around with the values in super(x, y, width, height) if you want.

Also, in response to your second query. It would be super trivial for any coder to whip up a little script for you to get a random item (maybe from a selection?). You can then use the (randomised) item's id when you add the item to the box. Maybe you can make a script request. But also, it should just be something like (in a script event command):

Code:
items = [1, 5, 2, 4, 7, 9] # these are the available options
chosen_item = $data_items[items[rand(items.size)]]
$game_boxes.add_item(chosen_item, 5, 1)

And you can mess with the probabilities by adding more of a number to that items list (like [1, 1, 1, 5] would make 1 3 times more likely than 5). These numbers correspond to the item IDs, by the way.

* * * * *

@Waveclaw: Can't really make a demo at the moment (but sounds like you might now need it now). Thanks for the bug report as well.
I'm not really in a position to be looking into it at the moment (I don't really use RMVXA anymore), but hopefully one of the kind coders who've helped out in the past will do so again. And if not, I will take a look when I get a chance.

* * * * *

If either of you have got any questions, let me know.
 

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
@Ansilvund216: Glad you like it. Not sure exactly about Fallout 4, but the code that sets the size of the windows are on lines 869, 924, and 982. They all look a bit like this:

Code:
  def initialize
    y_pos = fitting_height(IMP1_Storage_Boxes::HELP_WINDOW_LINES)
    super(x, y_pos, Graphics.width/2, fitting_height(1))

You can play around with the values in super(x, y, width, height) if you want.

Also, in response to your second query. It would be super trivial for any coder to whip up a little script for you to get a random item (maybe from a selection?). You can then use the (randomised) item's id when you add the item to the box. Maybe you can make a script request. But also, it should just be something like (in a script event command):

Code:
items = [1, 5, 2, 4, 7, 9] # these are the available options
chosen_item = $data_items[items[rand(items.size)]]
$game_boxes.add_item(chosen_item, 5, 1)

And you can mess with the probabilities by adding more of a number to that items list (like [1, 1, 1, 5] would make 1 3 times more likely than 5). These numbers correspond to the item IDs, by the way.

* * * * *

@Waveclaw: Can't really make a demo at the moment (but sounds like you might now need it now). Thanks for the bug report as well.
I'm not really in a position to be looking into it at the moment (I don't really use RMVXA anymore), but hopefully one of the kind coders who've helped out in the past will do so again. And if not, I will take a look when I get a chance.

* * * * *

If either of you have got any questions, let me know.
thanks a lot for the reply, ill try to understans it now
 

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
items = [1, 5, 2, 4, 7, 9] # these are the available options chosen_item = $data_items[items[rand(items.size)]] $game_boxes.add_item(chosen_item, 5, 1)
hello again sir, I cant quite understand it. how will I randomize the items stored in for example box 3? and the quantity of the items?
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
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)
 

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Thank you for the reply, im using the random variable in common events, i will try to understand the rand script call
 

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
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)
I finally did it, but there is another problem the contents of 1 box are being passed to one another heres my event
 

Attachments

  • e1.png
    e1.png
    44 KB · Views: 9
  • e2.png
    e2.png
    41.7 KB · Views: 9
  • c1.png
    c1.png
    57.6 KB · Views: 9

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
I need help!!!!!!!!! I've set up a box name "Metal Crate" with the ID of 2, I have a bunch of it in the map, the problem is the contents are being passed to all the other crates.
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
You'll need to give each different crate its own id.
 

Ansilvund216

Veteran
Veteran
Joined
Apr 28, 2018
Messages
50
Reaction score
2
First Language
English
Primarily Uses
RMVXA
You'll need to give each different crate its own id.
okay thanks I hope you are not irritated to me because I have another question...

So the script call for rand would be like this?

SceneManager(SceneItemstorage[4], true)
game.boxes.add_item($data_items[1 + rand(6), 10 + rand(25), 4)

i did that but Im getting an game interpreter.
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
If you want to just add the item (and not go to the item storage scene), then you just need the second line. And it looks like it's missing a close-square-bracket, so it'd be something like :

Code:
$game_boxes.add_item($data_items[1 + rand(6)], 10 + rand(25), 4)

I'm not at all irritated, just didn't have a lot of time to respond. I hope this works for you!
 

Latest Threads

Latest Posts

Latest Profile Posts

I genuinely like the default MZ actor sprites, and the character creator. I think I will draw new headshots for them, but part of me doesn't want to replace the default sprites. But should I? I want to eventually release my game.
Someday, I hope they make a game where 95% of the animation budget went to turning valves and opening door animations, leaving every other animation looking like a CDI zelda cutscene.
programming at 12 years old: "I love how it works!"
programming at 18: "I love that it works."
programming at 25: "I love why it works."
programming at 30: "I love when it works."
programming at 50: "How did this work?"
Why can't I insert picture in this profile post? Only insert image -> by URL. No option to upload from my pc?
Trying out a new Battle Ui.
BattleUI.png

Forum statistics

Threads
129,758
Messages
1,204,889
Members
170,849
Latest member
YujiHero
Top