Sweetmayham

Villager
Member
Joined
Feb 13, 2022
Messages
6
Reaction score
2
First Language
English
Primarily Uses
Other
Storage Boxes 1.10
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.
Roninator2 has written an edit to set the sizes of the boxes to use game variables, as requested by
Lionheart123. That edit can be found here. I think this was previously doable by using the manual setup, but I guess this is easier for some people.

Coming (Not So) Soon:
  • Box organisation

I'm almost completely inactive on these forums. I do get emails about new posts, so I'm happy to reply, but I don't use RMVXAce any more, so don't expect any major additions to this by me.
Howdy! im trying to implement this into my game but i dont think i understand how to use it! is it possible if you could explain me how to actouly use it? am i suppose to make an event and then what? i dont get it
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
67
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Howdy! im trying to implement this into my game but i dont think i understand how to use it! is it possible if you could explain me how to actouly use it? am i suppose to make an event and then what? i dont get it

You'll need events for any time you want the player to be able to interact with any boxes. And I suppose you would also use events for any times you wanted the game/story to change the contents of any boxes. But you also need to edit the script to setup any boxes you'd like to use throughout the game.

The first section of the script (the lines that start with the hash symbol '#') outlines what you can do with events.

Let me know if you have any other questions. It might also be useful to know what, specifically, you're trying to do.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,130
Reaction score
1,108
First Language
English
Primarily Uses
RMVXA
There seems to be a bug.
Adding items, then saving and quitting then loading save game and adding more of the same item creates a new slot entry.
1650488107809.png

This works, but maybe you can come up with a better way.
*Updated
Ruby:
class IMP1_Game_Boxes 
  def add_item(item, amount, box_id, overfill=:max)
    if overfill == :force || space_for(item, amount, box_id)
      new_part = true
      box(box_id).each do |itm|
        if itm[0].is_a?(RPG::Item)
          if itm[0].id == item.id && item.is_a?(RPG::Item)
            item = itm[0]
            box(box_id)[item] += amount
            new_part = false
          end
        elsif itm[0].is_a?(RPG::Weapon) && item.is_a?(RPG::Weapon)
          if itm[0].id == item.id
            item = itm[0]
            box(box_id)[item] += amount
            new_part = false
          end
        elsif itm[0].is_a?(RPG::Armor) && item.is_a?(RPG::Armor)
          if itm[0].id == item.id
            item = itm[0]
            box(box_id)[item] += amount
            new_part = false
          end
        end
      end
      box(box_id)[item] ||= 0 if new_part == true
      box(box_id)[item] += amount if new_part == true
    elsif overfill == :max
      new_part = true
      box(box_id).each do |itm|
        if itm[0].is_a?(RPG::Item) && item.is_a?(RPG::Item)
          if itm[0].id == item.id
            item = itm[0]
            box(box_id)[item] += amount
            new_part = false
          end
        elsif itm[0].is_a?(RPG::Weapon) && item.is_a?(RPG::Weapon)
          if itm[0].id == item.id
            item = itm[0]
            box(box_id)[item] += amount
            new_part = false
          end
        elsif itm[0].is_a?(RPG::Armor) && item.is_a?(RPG::Armor)
          if itm[0].id == item.id
            item = itm[0]
            box(box_id)[item] += amount
            new_part = false
          end
        end
      end
      box(box_id)[item] ||= 0 if new_part == true
      box(box_id)[item] += capacity(box_id) if new_part == true
    end
  end
end
 
Last edited:

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
67
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Thanks for the bug report. I also got a PM relating to this issue.

Also, thanks for the fix suggestion. I dunno how active these forums are, but I'm wondering if another more active/experience scripter could weigh in here.

My assumption is that this will only occur when closing the game and opening it again. And so therefore, if I update the pre-save values to the post-load values then it should work.

I've had a look at how the player inventory is stored, and it just stores the IDs in separate arrays for items, weapons, and armours.

So I have a couple of ways I think this could be solved.

  1. First idea is that I change the way boxes work. Instead of using $data_item[id] as a key, it could use the array [:item, id] as a key, and arrays will hash to the same value if their contents are the same, so this should work, but won't be backwards compatible.
  2. Second idea is something along the lines of Roninator2's solution: adding some checks to see if an existing item is of the same type and the same id, and if so, adding to it. This feels like sticking a plaster over the problem, and so would be unsatisfying to me, but would be backwards compatible.
  3. Third idea would be to reload the items when a savegame is loaded to update to the latest $data_item /weapon/armor objects, essentially updating their hash values. This feels a bit like ignoring the underlying issue, and also maybe feels a bit brittle? Like if there was some other way that some particular $data_item object might change then this wouldn't address that. This feels a bit like a compromise between solutions 1 and 2.


Any input from more active/experience scripters before I go ahead with one of these solutions?
 
Joined
Aug 13, 2019
Messages
69
Reaction score
12
First Language
english
Primarily Uses
RMVXA
Thanks for the bug report. I also got a PM relating to this issue.

Also, thanks for the fix suggestion. I dunno how active these forums are, but I'm wondering if another more active/experience scripter could weigh in here.

My assumption is that this will only occur when closing the game and opening it again. And so therefore, if I update the pre-save values to the post-load values then it should work.

I've had a look at how the player inventory is stored, and it just stores the IDs in separate arrays for items, weapons, and armours.

So I have a couple of ways I think this could be solved.

  1. First idea is that I change the way boxes work. Instead of using $data_item[id] as a key, it could use the array [:item, id] as a key, and arrays will hash to the same value if their contents are the same, so this should work, but won't be backwards compatible.
  2. Second idea is something along the lines of Roninator2's solution: adding some checks to see if an existing item is of the same type and the same id, and if so, adding to it. This feels like sticking a plaster over the problem, and so would be unsatisfying to me, but would be backwards compatible.
  3. Third idea would be to reload the items when a savegame is loaded to update to the latest $data_item /weapon/armor objects, essentially updating their hash values. This feels a bit like ignoring the underlying issue, and also maybe feels a bit brittle? Like if there was some other way that some particular $data_item object might change then this wouldn't address that. This feels a bit like a compromise between solutions 1 and 2.


Any input from more active/experience scripters before I go ahead with one of these solutions?

Thanks for the bug report. I also got a PM relating to this issue.

Also, thanks for the fix suggestion. I dunno how active these forums are, but I'm wondering if another more active/experience scripter could weigh in here.

My assumption is that this will only occur when closing the game and opening it again. And so therefore, if I update the pre-save values to the post-load values then it should work.

I've had a look at how the player inventory is stored, and it just stores the IDs in separate arrays for items, weapons, and armours.

So I have a couple of ways I think this could be solved.

  1. First idea is that I change the way boxes work. Instead of using $data_item[id] as a key, it could use the array [:item, id] as a key, and arrays will hash to the same value if their contents are the same, so this should work, but won't be backwards compatible.
  2. Second idea is something along the lines of Roninator2's solution: adding some checks to see if an existing item is of the same type and the same id, and if so, adding to it. This feels like sticking a plaster over the problem, and so would be unsatisfying to me, but would be backwards compatible.
  3. Third idea would be to reload the items when a savegame is loaded to update to the latest $data_item /weapon/armor objects, essentially updating their hash values. This feels a bit like ignoring the underlying issue, and also maybe feels a bit brittle? Like if there was some other way that some particular $data_item object might change then this wouldn't address that. This feels a bit like a compromise between solutions 1 and 2.


Any input from more active/experience scripters before I go ahead with one of these solutions?

Why should we look for another solution? I already tried the roninator one and it works perfectly.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,130
Reaction score
1,108
First Language
English
Primarily Uses
RMVXA
I already tried the roninator one and it works perfectly.
It's not perfect. I actually just updated it since I was only testing items and hadn't finished correcting the weapons and armor.
But my solution still has an issue. But I can fix that. Currently it checks the boxes contents and compares the id's, but if you were storing a hand axe and had a potion in there, it would add 1 to the potion and you would lose the hand axe since the id's are the same. I need to add in another check for the item class.
*done
 
Joined
Aug 13, 2019
Messages
69
Reaction score
12
First Language
english
Primarily Uses
RMVXA
It's not perfect. I actually just updated it since I was only testing items and hadn't finished correcting the weapons and armor.
But my solution still has an issue. But I can fix that. Currently it checks the boxes contents and compares the id's, but if you were storing a hand axe and had a potion in there, it would add 1 to the potion and you would lose the hand axe since the id's are the same. I need to add in another check for the item class.
*done

Ok, i
It's not perfect. I actually just updated it since I was only testing items and hadn't finished correcting the weapons and armor.
But my solution still has an issue. But I can fix that. Currently it checks the boxes contents and compares the id's, but if you were storing a hand axe and had a potion in there, it would add 1 to the potion and you would lose the hand axe since the id's are the same. I need to add in another check for the item class.
*done
did you put "done"?

Is that error already updated or should I wait?
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
67
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Why should we look for another solution? I already tried the roninator one and it works perfectly.
I think this has come up before in this thread. I think for me it boils down to the fact that I want the script I provide to work as it should. So I might just incorporate an equivalent of Ronanator2's solution, but I also have particular preferences when I'm scripting, and I would like my scripts to be what I consider elegant and readable and maintainable and extensible.

You are more than welcome to use Roninator's solution, but I will still probably work out my own solution and update the script.
 

Sweetmayham

Villager
Member
Joined
Feb 13, 2022
Messages
6
Reaction score
2
First Language
English
Primarily Uses
Other
Thanks for the bug report. I also got a PM relating to this issue.

Also, thanks for the fix suggestion. I dunno how active these forums are, but I'm wondering if another more active/experience scripter could weigh in here.

My assumption is that this will only occur when closing the game and opening it again. And so therefore, if I update the pre-save values to the post-load values then it should work.

I've had a look at how the player inventory is stored, and it just stores the IDs in separate arrays for items, weapons, and armours.

So I have a couple of ways I think this could be solved.

  1. First idea is that I change the way boxes work. Instead of using $data_item[id] as a key, it could use the array [:item, id] as a key, and arrays will hash to the same value if their contents are the same, so this should work, but won't be backwards compatible.
  2. Second idea is something along the lines of Roninator2's solution: adding some checks to see if an existing item is of the same type and the same id, and if so, adding to it. This feels like sticking a plaster over the problem, and so would be unsatisfying to me, but would be backwards compatible.
  3. Third idea would be to reload the items when a savegame is loaded to update to the latest $data_item /weapon/armor objects, essentially updating their hash values. This feels a bit like ignoring the underlying issue, and also maybe feels a bit brittle? Like if there was some other way that some particular $data_item object might change then this wouldn't address that. This feels a bit like a compromise between solutions 1 and 2.


Any input from more active/experience scripters before I go ahead with one of these solutions?
1653506752381.png
So i did a little test to see if it works and everytime i playtest it it dosnt work am i doing something wrong?
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
67
Reaction score
45
First Language
English
Primarily Uses
RMVXA
View attachment 227288
So i did a little test to see if it works and everytime i playtest it it dosnt work am i doing something wrong?

The hash symbols (#) at the start of those lines will cause the script to ignore them. Try removing them and see what happens.
 

Sweetmayham

Villager
Member
Joined
Feb 13, 2022
Messages
6
Reaction score
2
First Language
English
Primarily Uses
Other
The hash symbols (#) at the start of those lines will cause the script to ignore them. Try removing them and see what happens.
Then i get this 1653508167951.png
 

Latest Threads

Latest Profile Posts

Watch Studio Blue play Numina by starlit in our latest RPG Maker Games Critique stream starting NOW!

Wish me luck. One of the leading experts on certain false shuffle is going to check if my skill is good enough to be called "not total trash".
Not an RPG Maker Update but I'm happy to say that I finally passed my drivers written test. Which makes me a happy guy.
FWRu-cYXkAAAUbl
Have you ever been in such a luck streak you felt fear something was wrong?
I'm going to be adding in combat animations, revamping the UI and putting in a new cutscene this week, so this is your last chance to play the MC:RIS demo in its original form! Say you were there since the beginning! https://qos.itch.io/infinite-sadness

Forum statistics

Threads
123,120
Messages
1,154,119
Members
161,453
Latest member
arnedidden
Top