The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on April 27, 2009, 10:11:22 PM

Title: Limited Inventory
Post by: modern algebra on April 27, 2009, 10:11:22 PM
Limited Inventory
Version: 1.1c
Author: modern algebra
Date: September 27, 2009

Version History



Description


Essentially, this allows you to limit the number of items a party can carry. Rather than being able to hold 99 of all items, this script divides inventory space into a limited number of slots, each of which can hold a single item type, and for which you can set a maximum stack size. So, for instance, if you have 6 potions, and the maximum stack size for potions is 5, then potions will take up two slots in the inventory, one with 5 in it and the other with only 1. This script allows you to change the number of slots in the inventory in-game with ease, as well. It allows you to discard items easily (and set items as non-discardable), and if there is ever a time in which you get more items than you have space for, it will call a loot screen so you can choose which items to discard.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg382.imageshack.us%2Fimg382%2F2628%2Fliminvscreen1.png&hash=254b0b9aa82ea1d4e2a3caee522e8a4858f66bd5)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg382.imageshack.us%2Fimg382%2F6115%2Fliminvscreen2.png&hash=65ba88ac5bbe864106414f65afc0e5cc344b5f7f)

Instructions

Quote from: Header
Place this script above Main and below other custom scripts.

To set a number of the default conditions for this script, please see the Editable Regions at 53, 84, and 109. Be sure to read the comments next to each consant to see what it does.

To set an item as non-discardable, put this command into its note box:

Code: [Select]
    \NONDISCARD

To set an item to have a stack size different from the default, use this command in its note box:

Code: [Select]
    \STACKMAX[x]

where x is and integer and the new maximum stack size for that item.

To resize the party inventory in-game, say after an event where the get a new backpack or whatever, then all you need to do is put this code into a call script:

    
Code: [Select]
resize_inventory (x)
 
where x is an integer and the new number of slots in the party inventory.

Script


It is a large script. Please see the text document or retrieve the script from the demo. They are both attached at the bottom of this post.

Credit



Thanks


Support


With such a large script, there are bound to be bugs. Please post in this topic at rmrk.net for swiftest support, and be as detailed as possible.

Known Compatibility Issues

No known compatibility issues, yet. But anything that heavily modifies Scene_Item or Window_Item would likely be incompatible.

Demo


Limited Inventory 1.1b Demo (http://rmrk.net/index.php?action=dlattach;topic=32918.0;attach=17902)


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Limited Inventory
Post by: Grafikal on April 27, 2009, 10:50:17 PM
woo!
Title: Re: Limited Inventory
Post by: mortigneous on April 27, 2009, 11:38:10 PM
lol, modern... I got so used to seeing the other avatar and sig that when I saw on the other post you had finished, I was like... Who the hell?

Anyway, thanks for making this, I had thought about a limited inventory before, but as I think I somewhat said in the other post I had found the request already.

This'll be a nice addition to my game.

and, for this, I love you in a purely professional way.

Edit: Found a bug :D, if you go into your equip screen and attempt to equip an empty slot anything (I think) it pops up with
Quote
"line465: NoMethodError occurred. undefined method 'ma_discardable?' for nil:NilClass"
It unequips fine, Its just equipping something into an empty slot, as equipping into an already filled slot works as well. So basically, if you try to equip something into an empty slot it'll result in that error.
Title: Re: Limited Inventory
Post by: modern algebra on April 28, 2009, 01:29:07 AM
Thanks for catching that.

To fix it, replace that line with:

Code: [Select]
      if item != nil && !item.ma_discardable?

EDIT::

Actually, that's not entirely true. That will fix the syntax error, but could potentially cause other problems in the script. Just get the script from the new demo or the new text file that I just uploaded, as that has the complete fix in it.
Title: Re: Limited Inventory
Post by: mortigneous on April 28, 2009, 02:50:21 AM
Also, would it be possible for you to make this script so that it has an option for something like the non-discardable items, but have them called key items, in a different page, but have up, say, above the help box have something like, Items, or inventory or something, then, beside that something like key items, then selecting key items brings you to a different menu that would basically just be an inventory for key items that wouldn't take up the players inventory space? I know that's long and probably has a lot of errors with grammar, but I'm kinda tired and changed where I was going with it a couple of times... (just ignore that random mess, unless you feel like you absolutely must read it... the lower description is better by far.)

Anyway, picture!

-Sorry about it being an off-site picture, I was having some odd issues with attaching.... (This site doesn't show any recognition of it being attached? Too used to RRR lol) but I hope that explains what I mean (basically just if you label an item as a 'key item' some way [possibly an item note?] it goes under Key items, and does not take up space in the inventory whatsoever. This way your not filling up your players' inventories with a bunch of useless crap that are basically just trophies that serve no purpose other than giving players that reminiscent feeling of that one very special quest.
Title: Re: Limited Inventory
Post by: modern algebra on April 28, 2009, 02:58:56 AM
I might add that later. How do you want ot be able to switch over to Key Items?
Title: Re: Limited Inventory
Post by: mortigneous on April 28, 2009, 03:05:01 AM
not entirely sure on this, but I guess something where you have it to where you select item in the game menu, and it goes into the inventory, you hit the cancel button (esc?) and it moves the selection up to inventory and key items, and there you can select either one. Or if you have another way that's easier to script that's fine as well :D

I'm going to sleep pretty much right after I post this, but I'll check it tomorrow when I get home and see if you have questions/specifications.
Title: Re: Limited Inventory
Post by: mortigneous on May 22, 2009, 02:12:56 AM
I just now noticed something, when you are able to scroll down, it doesn't show the cursor at the bottom that basically says 'Hey! there's more!' it just shows the one up at the top. (see attached)

Also, how's the key items thing going? :P
Title: Re: Limited Inventory
Post by: modern algebra on May 22, 2009, 11:27:11 PM
Yeah, it would show the cursor if you actually had items down there and not just empty slots. I've noted the concern though and will add it when I look at this script again. I haven't started working on the Key Items thing, and to be honest, it's pretty low in my queue.
Title: Re: Limited Inventory
Post by: Zero2008 on May 23, 2009, 03:03:39 AM
Edit: Never mind.... LOL :-\


Nice script Algebra!
Its very usefull. You think you can do the same but making every actor in ones party have their own inventory or something?
Title: Re: Limited Inventory
Post by: Fizzly on August 14, 2009, 10:00:56 PM
Thanks, it's really nice! But I found a bug: even if an item is non-discardable, the "discard" option is faded to gray, but it's still active and you can select this -> item goes to the Loot... Can you fix this? ^ ^;
Title: Re: Limited Inventory
Post by: modern algebra on August 14, 2009, 11:13:38 PM
Hmm, you're right. Around line 1011, change this:

Code: [Select]
         slot = @item_window.ma_grfkl_lim_nvtry_item_8rn
          type, id, n = slot.item_type, slot.item_id, slot.amount

Replace it with:

Code: [Select]
         slot = @item_window.ma_grfkl_lim_nvtry_item_8rn
          unless slot.item.ma_discardable?
            Sound.play_buzzer
            return
          end
          type, id, n = slot.item_type, slot.item_id, slot.amount

That ought to fix it.
Title: Re: Limited Inventory
Post by: Fizzly on August 14, 2009, 11:18:44 PM
Yup, it's working fine right now. ^^ Thank you!
Title: Re: Limited Inventory
Post by: modern algebra on August 14, 2009, 11:20:39 PM
Good to hear. Tell me if you encounter any other problems.
Title: Re: Limited Inventory
Post by: Fizzly on August 15, 2009, 01:09:05 AM
Hmm, I think there is one more. But not sure if I can call this a bug or glith. Anyway, if you change default amount of items in script for more than (default) one, they just can't group together. I mean, I've got for example 3x apples, and they are in inventory as: apple, apple and apple. When I'll get another two one, I have: apple, apple, apple, apple x2. Shouldn't they be as: apple x5?  ;) If you can fix this, would be great. =)

EDIT: And another one! ^^; This should be fixed for sure:
There is non-discardable item in inventory. I want to throw away some stuff (discardable) to make space for new one. When I'll use "Change" option, from Loot window, I can change discardable stuff (from Loot) with non-discardable one (from the inventory). So in fact, I can use a trick to throw something really important... ^^; <LOST MY KEYYY!! T_T>
Title: Re: Limited Inventory
Post by: modern algebra on August 15, 2009, 02:37:24 AM
I'll look into those bugs. They definitely shouldn't be happening.
Title: Re: Limited Inventory
Post by: Fizzly on August 17, 2009, 09:56:14 PM
Bump? =p

Anyway, modern algebra, can I have a little request about that script? I thin kthat would be pretty useful for others too. I mean:
Weapons can be "clickable" too, but instead of inactive "Use" option, they'll be "Equip" option. Same could be with armors and shields. :) That would be really great.
Title: Re: Limited Inventory
Post by: modern algebra on August 17, 2009, 10:12:32 PM
Then I'd have to introduce a targetting window, as well as an equip window to show what is being replaced and a stats window to show the difference in stats. Further, it's make the Equip scene useless, meaning that anyone wanting to use it would probably want to get rid of it, which is even more :( Also, any scenes which are so extensive would mean that anybody who has a nice custom Equip scene probably wouldn't want this script.

It's a nice idea, but it's a lot more trouble than it's worth. I'd rather not.

I will look into those errors though. Sorry for the time, but I've been busy.
Title: Re: Limited Inventory
Post by: Fizzly on August 19, 2009, 02:42:37 PM
No problem, and thanks. Still waiting for fixes, by the way.  ;)
Title: Re: Limited Inventory
Post by: modern algebra on August 19, 2009, 06:43:50 PM
Updated to 1.1. Those bugs should be fixed now.

It does tell me that grafikal hasn't been using the script he requested though :P I should be upset with him >: (
Title: Re: Limited Inventory
Post by: Grafikal on August 19, 2009, 06:46:43 PM
Haha, I was using it for a while, but never got around to extensively testing it since I didn't progress enough in the game to use the inventory a whole lot .______.
Title: Re: Limited Inventory
Post by: modern algebra on August 19, 2009, 07:42:43 PM
 ;D

Also, @mortigenous - the new version does show the white arrow when there are more spaces down
Title: Re: Limited Inventory
Post by: Fizzly on August 19, 2009, 09:08:06 PM
Now it works just perfect!! Thanks, modern algebra.  ;)
Title: Re: Limited Inventory
Post by: Grafikal on August 19, 2009, 09:12:16 PM
Bump? =p

Anyway, modern algebra, can I have a little request about that script? I thin kthat would be pretty useful for others too. I mean:
Weapons can be "clickable" too, but instead of inactive "Use" option, they'll be "Equip" option. Same could be with armors and shields. :) That would be really great.

Curious if that was implemented? That sounds really convenient O_O
Title: Re: Limited Inventory
Post by: modern algebra on August 19, 2009, 09:39:06 PM
No, I decided against it. It's not a bad idea but it's a lot of work:

Then I'd have to introduce  an equip window to show what is being replaced and a stats window to show the difference in stats. Further, it'd make the Equip scene useless, meaning that anyone wanting to use it would probably want to get rid of it, which is even more :( Also, any scenes which are so extensive would mean that anybody who has a nice custom Equip scene probably wouldn't want this script.

Maybe one day. Lots of other scripts to fix before that though.
Title: Re: Limited Inventory
Post by: Grafikal on August 19, 2009, 10:13:12 PM
Lol, I was just thinking like, click it once (Message box pops up "Equip this?" [yes, no], then if yes, it'll just unequip what ever you have on at the moment and put that on instead.) I wasn't thinking new windows and crazy stuff lol.
Title: Re: Limited Inventory
Post by: modern algebra on August 19, 2009, 11:18:38 PM
What if it's Two Swords Style?

Not to mention that it would automatically make the script incompatible with any scripts that alter equipment, such as Usable Equipment, Extra Equipment, new Equipment scenes, etc...
Title: Re: Limited Inventory
Post by: SeMcDun on August 23, 2009, 10:45:46 PM
Hey me again MA.

I found another glitch :P

If I have too many items... I can go to discard and they go into the Loot window yeh? BUT, I can leave the menu then aquire more items and repeat this process to have as many items as I want. See what I mean? It's like the Loot window is another Item menu with unlimited slots :P

Just thought I'd let you know, because this script is pretty banging haha (good)

Thanks.
Title: Re: Limited Inventory
Post by: modern algebra on August 24, 2009, 12:39:38 AM
I';m not receiving that error when I test. Is the warning window not coming up?
Title: Re: Limited Inventory
Post by: SeMcDun on August 24, 2009, 12:43:28 AM
Is a warning message meant to come up so that you can't leave the item menu when the loot menu is up?

No error comes up or anything =/ I'm just allowed to leave items in the loot window to free up inventory slots.
Title: Re: Limited Inventory
Post by: modern algebra on August 24, 2009, 01:55:57 AM
I attached a picture.

If you have a script which overwrites return_scene of Scene_Item, then it would skip it. Do you have Yanfly's Scene Menu Redux or any Custom Commands script, by chance?

For now, try putting the Limited Inventory script below the menu script. If that causes problems, I will look into it, but hopefully it will resolve your error.
Title: Re: Limited Inventory
Post by: SeMcDun on August 24, 2009, 04:02:59 AM
Yeh that's it fixed man, just moved the Scene Redux below Limited Items like you said and it works like a charm.

Thank you very much :D
Title: Re: Limited Inventory VERSION 1.1
Post by: adamass on September 01, 2009, 12:55:55 AM
Hi there. I love this script but I need to tell about a bug.
Here is the setting:
-Your inventory is full
-Lets say find a leather shield and wanna take it in exchange of anything in your inventory.
-Once the trade is done and you get the leather shield,
you want to equip it for you hero.
-BUG IS even tho you do HAVE the item listed in inventory, it just does not appear in the equip screen, nor is it equipable for anyone normally able to.
-I double checked the classes compatibility, nothing to do with it.

There you go.

I admire all your scripts nonetheless. Genius you are dude!
Title: Re: Limited Inventory
Post by: modern algebra on September 01, 2009, 12:54:25 PM
There must be a hash updating problem when gaining item through the loot. Thanks for the report; I will look into it.
Title: Re: Limited Inventory
Post by: adamass on September 02, 2009, 01:11:16 AM
There must be a hash updating problem when gaining item through the loot. Thanks for the report; I will look into it.

Very nice of you Modern because I'd really like to use your script for my game :)

Also, about limited inventories (just asking by the way)... I was wondering if you planned to create a script to
limit inventories à la Dragon Quest. You know, each character with limited carryable items(equiped items included), useable by them in battle according to they very own inventory (can't explain better, gotta play DQ to know otherwise. Indeed, if you ask me, THAT would be the perfect ''limited items'' script ever my friend. Just telling :-X
Title: Re: Limited Inventory
Post by: modern algebra on September 02, 2009, 01:12:33 PM
I have no plans currently to make an individual limited inventories script as of now, but my Grid Inventory script has those capabilities. Obviously, it's quite different graphically and may not be what you are looking for, though.
Title: Re: Limited Inventory
Post by: modern algebra on September 20, 2009, 10:23:33 PM
Updated to Version 1.1b

Fixed the bug where the hash was not updating when gaining or destroying items through loot.
Title: Re: Limited Inventory
Post by: munkis on October 08, 2009, 07:34:31 PM
Would it be possible to add a "hero chest" feature to this script?  Let me explain what I mean:

I make a chest through quick event creation.  Then I go into the event and remove the "Show Text" and "Change Items" commands.  Finally I add a script call that would take the form of "$scene = Hero_Chest.new" or something like that.

Other than that, it's perfect!
Title: Re: Limited Inventory
Post by: modern algebra on October 08, 2009, 07:55:48 PM
It's a good idea and definitely possible. I did much the same thing with my Grid Inventory.

In any case, I will put it on my To Do list (which is unfortunately very long, so it might be a while)
Title: Re: Limited Inventory
Post by: munkis on October 10, 2009, 11:48:48 AM
I don't suppose there's a way to limit the amount of stacks? i.e.: in a inventory with 99 slots, you can only have, say, 3 stacks of potions.
Title: Re: Limited Inventory
Post by: modern algebra on October 10, 2009, 04:07:32 PM
No, there isn't. Sorry.
Title: Re: Limited Inventory
Post by: munkis on October 13, 2009, 02:50:48 PM
Might not be a bad idea to add that then...
Title: Re: Limited Inventory
Post by: munkis on November 16, 2009, 06:37:19 PM
Just curious as to how far along you are with my requests...
Title: Re: Limited Inventory
Post by: modern algebra on November 16, 2009, 07:21:03 PM
Nowhere. I haven't worked on it at all. And I have a lot more to do before I will even look at it. Plus, I'm playing Dragon Age now so I probably won't do any scripting for a while.
Title: Re: Limited Inventory
Post by: munkis on November 16, 2009, 08:07:14 PM
Actually, I've just come across (and implemented) a different "hero chest" system.  So no worries!  However, I am having a minor issue with this and KGC_CategorizeItem.  For the most part they work together, but when I select a category, it automatically uses the first item in that category rather than simply going into it.
Title: Re: Limited Inventory
Post by: Krmona on December 04, 2009, 12:49:44 PM
Hi.
I'm a brazilian maker and I don't write english very good. I'm using the Babel Fish Tradutor  ;D
I would like to know if I could take this script until my Brazilian community Reino RPG (http://www.reinorpg.com/forum)

Thanks  :lol:
Title: Re: Limited Inventory
Post by: Grafikal on December 04, 2009, 04:44:27 PM
Oh, I've seen that website before. It's a very nice website. I would imagine that ModernAlgebra would allow you to post it on that website as long as you credit him as the creator and placed a link to this webpage incase someone would need help with the script.
Title: Re: Limited Inventory
Post by: Krmona on December 04, 2009, 07:54:45 PM
Yes! All credits for he and me (I translated the script to portuguese) and I will place a link to this site  ;)

All rights reserved  ;D
Title: Re: Limited Inventory
Post by: modern algebra on December 04, 2009, 09:27:26 PM
Yeah, that's fine with me :) Like grafikal said, I would appreciate the link to this site, but by all means you can post it on reinorpg.
Title: Re: Limited Inventory
Post by: h3llh0und on December 16, 2009, 02:14:12 AM
Lol, edited the post and forgot to say what is this xD

this is a fix for those who are using Kgc's categorize item script
they will work fine now, just put kgc BEFORE this one (dunno if this matter but just do it)




Discard the other one, just found a better way to do it
Quote
====
on this line  (805 +/-)

Code: [Select]
class Scene_Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start processing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start
    super
    create_menu_background
    @activated_frame = false

do this

Code: [Select]
class Scene_Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start processing
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start
    super
    @@btpresses = 0
    create_menu_background
    @activated_frame = false


then search for " Input.trigger?(Input::C) "

you'll get this line

Code: [Select]
elsif Input.trigger?(Input::C)
      # If exchanging
      if @loot_window.index > -1 && @item_window.active
        slot = @active_window.ma_grfkl_lim_nvtry_item_8rn

change to...

Code: [Select]
elsif Input.trigger?(Input::C)
      # If exchanging
      if @@btpresses == 0 then @@btpresses += 1 and return end
      if @loot_window.index > -1 && @item_window.active
        slot = @active_window.ma_grfkl_lim_nvtry_item_8rn

now do the same search again for the second line

Code: [Select]
elsif Input.trigger?(Input::C)
      if @active_window == @item_window
        case @command_window.index

change to

Code: [Select]
elsif Input.trigger?(Input::C)
      if @@btpresses == 0 then @@btpresses += 1 and return end
      if @active_window == @item_window
        case @command_window.index


and that's it

not the best fix but it does work.
Title: Re: Limited Inventory
Post by: wnhero on April 25, 2010, 05:34:27 PM
Ok so I'm not very good with scripts first off. I have quite a bit of them in this game I'm putting together. It's non-commercial just kind of something to do to pass the time. I decided to put your script in there too cause I loved the idea. Problem is every time I try to open my item menu an error pops up saying...

Script 'Limited Inventory 1.1b' line 567:NoMethodError occured.

undefined method 'slots' for nil:NilClass

I'm sorry if it's something simple that I'm missing but your help would be much appreciated.
Title: Re: Limited Inventory
Post by: modern algebra on April 25, 2010, 05:57:41 PM
It's an incomptibility with one of your other scripts. First try to move the Limited Inventory below every other custom script you have but still above Main. Beyond that, I'd need to know which script is causing the error before I could help you.
Title: Re: Limited Inventory
Post by: wnhero on April 25, 2010, 08:48:34 PM
Ok. Well would you mind if I PM you with all the scripts I'm using? I already have the limited inventory at the bottom right above main.
Title: Re: Limited Inventory
Post by: wnhero on April 25, 2010, 10:52:39 PM
Ok so never mind. It seems to work now. I think the problem was I was using the script on a saved game that I had made before I had added your script. I started a new game and it works just fine now. Thank you.
Title: Re: Limited Inventory
Post by: modern algebra on April 26, 2010, 03:13:16 AM
Alright; yeah, that would definitely cause the problem. I am happy that you have resolved it :)
Title: Re: Limited Inventory
Post by: Fizzly on August 10, 2010, 03:02:20 AM
Okay, I found another bug. I send you PM, but you didn't answer yet, so I'll post it anyway, to make sure you'll remember ^^'

The problem is, the game crushes every time, when I want to set item amout to variable. I've got this:
http://ifotos.pl/img/error_wxrqeq.PNG

Title: Re: Limited Inventory
Post by: modern algebra on August 10, 2010, 03:14:32 AM
That's not a bug from Limited Inventory; if you notice, it will occur whether Limited Inventory is there or not. This is because it's a bug that enterbrain didn't fix when they released RMVX. Just get the Game_Interpreter fix - http://rmrk.net/index.php/topic,25243.0.html

Go through the entire topic

This post will fix the error you are reporting: http://rmrk.net/index.php/topic,25243.msg316194.html#msg316194

This post will fix another error with multiplying variables - http://rmrk.net/index.php/topic,25243.msg322221.html#msg322221
Title: Re: Limited Inventory
Post by: Fizzly on August 10, 2010, 10:18:04 AM
Oh!  :o You're right. Didn't notice this error earlier, sorry for bothering you. And thank you, anyway! It works fine now. Thanks for the multi-variable fix too!
Title: Re: Limited Inventory
Post by: rofl1337 on September 19, 2010, 03:38:12 PM
sorry for epic necroposting,
but is there a way to change the stacksize through a script command or an event?
i would be thrilled if you could help me.
sincerly
rofl1337
Title: Re: Limited Inventory
Post by: modern algebra on September 19, 2010, 03:39:16 PM
If I recall correctly, then no there is not. Sorry.
Title: Re: Limited Inventory
Post by: rofl1337 on September 20, 2010, 02:37:59 PM
ok, i will try to work out a way on my own.
i will post results, if i succeed.
sincerly

update:
I defined a new function in the game_interpreter, called change_stacksize (new), which should change
the MA_STACK_AMOUNT to (new).
Code: [Select]
def change_stacksize (new)
    @ma_stack_amount = (new)
end
although the game doesnt give out any errors, the stacksize keeps the same.
anyone able to help me?

Title: Re: Limited Inventory
Post by: modern algebra on September 20, 2010, 10:44:21 PM
That... is nothing like how you would go about doing it. That creates an instance variable in Game_Interpreter that is unrelated to how the script retrieves the maximum stack size. You are on the right track in a distant sort of way though. You want to change MA_DEFAULT_STACK_AMOUNT. Well, it's a constant and it's newly defined every time, so even if you had succeeded in changing the value of the constant (which you didn't and shouldn't do), then that change wouldn't be saved in the save file and would revert back to the default the next time the player starts the game.

So, not really the way to do it. A much simpler way is to insert the following code somewhere below the Limited Inventory:

Code: [Select]
#==============================================================================
# ** RPG::BaseItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    redefined method - ma_stack_amount
#==============================================================================

class RPG::BaseItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Stack Amount
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_stack_amount
    return $1.to_i if self.note[/\\STACKMAX\[(\d+)\]/i] != nil
    if $game_variables && $game_variables[RPG::MA_DEFAULT_STACK_AMOUNT] > 0
      return $game_variables[RPG::MA_DEFAULT_STACK_AMOUNT]
    else
      return 1
    end
  end
end

I haven't tested it, but what that does is repurposes the MA_DEFAULT_MAX_STACK constant. Instead of holding the default stack maximum, it now holds the ID of a variable, and the value of that variable will determine the max stack size (though it can never be less than 1).

So now, if you set MA_DEFAULT_MAX_STACK to 20, for instance, then default stack size for items is going to be whatever the value of variable 20 is. So, that will allow you to change it by changing the value of variable 20 through a simple Control Variable command. Note that if the stack max is set individually through an item's notebox, then that will still take priority.

Anyway, tell me if you have any problems with that.
Title: Re: Limited Inventory
Post by: rofl1337 on September 21, 2010, 01:59:04 PM
thank you so much, it worked perfectly.
i dont know anything about scripting in rgss2, so this is really helpful for me.
there is one tiny problem with it though.
if you already have a stack of lets say 20 items in your inventory, they keep their size even after the maximum-stacksize is changed/lowered.
same problem the other way around. if i have stacks of 5 and the stacksize is increased, the stacks keep small and take up inventory space, that they wouldnt need with the new stacksize.
i suppose there isnt some update command for the inventory?

again thank you so much for the script
sincerly
Title: Re: Limited Inventory
Post by: modern algebra on September 21, 2010, 10:31:37 PM
I really don't know. I wrote this script a very long time ago and don't really have the time to take a look now. If not, then it would be a rather simple procedure. Essentially all you would need to do is go through every item, lose them and then gain them. It would be something like:

Code: [Select]
class Game_Party
  def refresh_inventory
    items.each { |item|
      n = item_number (item)
      lose_item (item, n)
      gain_item (item, n)
    }
  end
end
You'd put that in a separate slot.

And every time you change the max stack size you could just put the following code in a script call right after:

Code: [Select]
$game_party.refresh_inventory

There may be an error since it isn't tested and, as I've said, I haven't looked at the script for a long time. I'm not sure whether it would properly work with loot either, but I think it should if I recall loot correctly.
Title: Re: Limited Inventory
Post by: rofl1337 on September 22, 2010, 01:47:19 PM
one word: AWESOME!
i cant say how much i apprechiate your help.
everything works perfectly and just the way i imagined it. ;D
thanks, that you took time to code this.
respectfully
rofl1337
Title: Re: Limited Inventory
Post by: Kureigu on October 17, 2010, 08:42:13 PM
hey, perfect script works really well but is ther any way i can remove a part of it  :o
i didnt wont the loot idea, i wanted it to just have my inventory and the 50 slots i have placed, and items that stack to 10, with the option to discard i wanted them to just disapear, rather than go into a loots box.
it would be "REALLY" helpful if you could help me here, thanks :)
- Kureigu


oh , i found another way round it. i got confused but i just changed the name loot to "items to be discarded"
so it makes abit more sense. Thank you for the script, its great ;)


third edit haha!
yea its all working great until i changed the stack limit on items.
instead of it saying cake X5 or potions X3
it says cake 10 5 or potion 10 3
have no clue why :|?
Title: Re: Limited Inventory
Post by: modern algebra on October 18, 2010, 01:27:41 AM
Well, the "x" is a label set up by in the configuration region. Maybe you changed it from "x" to "10 "
Title: Re: Limited Inventory
Post by: Kureigu on October 18, 2010, 04:30:59 PM
yeah i was thinking that was the problem  :-[ . haha im so stupid at times :P
thanks for the script again, i LOVE it!!
Title: Re: Limited Inventory
Post by: TwilightYagami on December 21, 2010, 06:07:15 PM
Sorry for the late post, but would it be possible for the script to work with Yanfly Engine Melody Item Scripts? Thanks.
Title: Re: Limited Inventory
Post by: modern algebra on December 21, 2010, 07:04:14 PM
I don't know. What are they and can you link me to them?
Title: Re: Limited Inventory
Post by: wsensor on December 21, 2010, 08:35:50 PM
I am guessing he wants you to see if you can make it compatible to http://wiki.pockethouse.com/index.php?title=Item_Overhaul ...
It's part of Yanfly's Melody scripts.
Title: Re: Limited Inventory
Post by: Rinkachi on December 30, 2010, 03:36:38 PM
Nice script, just what I needed! :D
Title: Re: Limited Inventory
Post by: hiromu656 on January 03, 2011, 03:56:56 AM
Could I have the loot screen come up at all times?
Title: Re: Limited Inventory
Post by: Mitsarugi on January 06, 2011, 08:38:22 PM
it works perfectly , but it still asks if i want to discard the items when leaving the item menu how could i take it away?
Title: Re: Limited Inventory
Post by: modern algebra on January 07, 2011, 06:01:02 AM
Well, I gave you two solutions since I wasn't sure which you wanted from your request - one was if you wanted them to go to loot but not to open, while the other was if you wanted to immediately destroy the items and not go to loot at all. It sounds like you chose the first one instead of the second. Go back to the PM and test the second one.
Title: Re: Limited Inventory
Post by: Mitsarugi on January 12, 2011, 01:41:16 PM
Well, I gave you two solutions since I wasn't sure which you wanted from your request - one was if you wanted them to go to loot but not to open, while the other was if you wanted to immediately destroy the items and not go to loot at all. It sounds like you chose the first one instead of the second. Go back to the PM and test the second one.
okay i will thanks ^^
Title: Re: Limited Inventory
Post by: Mitsarugi on January 16, 2011, 06:10:51 PM
Quote
Anyway, I'm a little confused as to what you're asking. Do you want it to go to Loot but just not immediately open the loot window? Or do you want the item to be immediately destroyed?

If the former, a possible solution is as follows: no guarantees as I haven't looked at the script for a very long time and I forget how it was supposed to work, but try replacing line 1036:


           
Code: [Select]
show_loot

with:

           
Code: [Select]
@item_window.refresh ($game_party.limit_inventory)
If the latter, try replacing this whole section from lines 1026 - 1039:

         
Code: [Select]
$game_temp.slots_to_discard.add_item (type, id, n)
          # Deactivate Command Window
          @command_window.active = false
          @command_window.index = -1
          @command_window.visible = false
          # Reactivate previous Window
          if @loot_window.visible
            @item_window.refresh ($game_party.limit_inventory, 1)
            @loot_window.refresh ($game_temp.slots_to_discard, 1)
          else
            show_loot
          end
          @item_window.active = true
          RPG::SE.new (Sound::MA_DISCARD_SE).play
with:


         
Code: [Select]
RPG::SE.new (Sound::MA_DESTROY_SE).play
          @command_window.active = false
          @command_window.visible = false

Again, I don't remember the script well enough to know if those changes would break anything. I don't think they should, but you should try it out in a test project first
.

as you told me in your PM only the first solution works for me, the second freezes once you click on discard (destroy) the item.
the only problem now is that once closing the item window it asks me if i'm okay with discarding the items , i would like it not to show this question. thanks for the help so far it works like a charm :p
Title: Re: Limited Inventory
Post by: modern algebra on January 16, 2011, 06:28:33 PM
Well, instead of just:

Code: [Select]
          RPG::SE.new (Sound::MA_DESTROY_SE).play
          @command_window.active = false
          @command_window.visible = false

try making it:

Code: [Select]
          RPG::SE.new (Sound::MA_DESTROY_SE).play
          @command_window.active = false
          @command_window.visible = false
          @item_window.refresh ($game_party.limit_inventory, 1)
          @item_window.active = true

Like I said, I don't really remember this script very well and certainly don't feel like relearning it. Hopefully that will work fine.
Title: Re: Limited Inventory
Post by: Mitsarugi on January 18, 2011, 09:10:55 PM
Well, instead of just replacing:


Code: [Select]
$game_temp.slots_to_discard.add_item (type, id, n)
          # Deactivate Command Window
          @command_window.active = false
          @command_window.index = -1
          @command_window.visible = false
          # Reactivate previous Window
          if @loot_window.visible
            @item_window.refresh ($game_party.limit_inventory, 1)
            @loot_window.refresh ($game_temp.slots_to_discard, 1)
          else
            show_loot
          end
          @item_window.active = true
          RPG::SE.new (Sound::MA_DISCARD_SE).play

with

Code: [Select]
          RPG::SE.new (Sound::MA_DESTROY_SE).play
          @command_window.active = false
          @command_window.visible = false

try making it:

Code: [Select]
          RPG::SE.new (Sound::MA_DESTROY_SE).play
          @command_window.active = false
          @command_window.visible = false
          @item_window.refresh ($game_party.limit_inventory, 1)
          @item_window.active = true

Like I said, I don't really remember this script very well and certainly don't feel like relearning it. Hopefully that will work fine.

yes that worked thanks Modern algebra, just one little thing

make it

Code: [Select]
RPG::SE.new (Sound::MA_DESTROY_SE).play
          @command_window.active = false
          @command_window.visible = false
          @item_window.refresh ($game_party.limit_inventory)
          @item_window.active = true

instead, you'll see why (it gives a little bug if you don"t )

thanks again :p
Title: Re: Limited Inventory
Post by: JiM83 on January 22, 2011, 11:50:57 AM
I received this error when I obtained a Non-Discard item from a
chest while my inventory was already full. This happened in the
Limited Inventory 1.1 Demo. I'm not using any other scripts.

Script 'Limited Inventory 1.1c' line 480: NoMethodError occurred.
undefined method 'item_type' for nil:NilClass
Title: Re: Limited Inventory
Post by: Fizzly on February 05, 2011, 07:54:03 PM
I received this error when I obtained a Non-Discard item from a
chest while my inventory was already full. This happened in the
Limited Inventory 1.1 Demo. I'm not using any other scripts.

Script 'Limited Inventory 1.1c' line 480: NoMethodError occurred.
undefined method 'item_type' for nil:NilClass
Yup, checked this and you're right. <waiting for fixing this>  ::)

Hmmm, I wonder is it possible to had the free slots number in variable? Could you help, modern_algebra? :)
Title: Re: Limited Inventory
Post by: Foghart on February 09, 2011, 12:25:43 AM
Its a good script to make the player build a strategy to fight a tough boss or a quest boss.
Congrats!
Title: Re: Limited Inventory
Post by: Infinate X on May 15, 2011, 09:33:03 PM
This is an awesome script but I was wondering if I could use the normal Items window with the limited Items features.

EXAMPLE:
-No dark blue rectangles
-Can not scroll down to empty slots

BTW i forget what I was gonna post here (after the BTW)


EDIT: Another thing I wonder if it is possible:
Can the loot be disabled without disabling the ability to discard items?
Title: Re: Limited Inventory
Post by: modern algebra on May 15, 2011, 10:03:36 PM
Well, you could remove the loot scene, but it would be reckless. What if the player's inventory was full and you wanted someone to give them a key item? Without a loot scene it would destroy the item.

As for getting rid of the blocks, I haven't worked with this script for a very long time so no guarantees, but you could try finding this in the refresh method of the Window_Item class (still inside the Limited Inventory script - I do not mean the default Window_Item class):

Code: [Select]
    @item_max = inventory.max_size == -1 ? @data.size : inventory.max_size
    create_contents
    # Calculate number of empty slots to draw
    empty_slots = (inventory.max_size == -1 || !$scene.is_a? (Scene_Item)) ? 0 : inventory.max_size - inventory.slots.size

and changing it to:

Code: [Select]
    @item_max = @data.size
    create_contents
    # Calculate number of empty slots to draw
    empty_slots = 0
Title: Re: Limited Inventory
Post by: rofl1337 on June 11, 2011, 11:00:30 AM
Is there a way to specify items, that do not use up item slots?
I would love that feature.
Title: Re: Limited Inventory
Post by: modern algebra on June 12, 2011, 10:47:41 PM
There isn't, though that would be a good idea for the future.
Title: Re: Limited Inventory
Post by: rofl1337 on June 13, 2011, 04:47:24 PM
Exactly  ;D
Title: Re: Limited Inventory
Post by: rofl1337 on June 16, 2011, 05:40:01 PM
Double-Post-Bump, because I love this script.
I have another suggestion.
Could you add the option to "hide" items? You should still be able to check if there are present in the inventory, via events, but they don't show up in the
inventory screen.
I think there are a few possible uses for that.

Edit:
In the discard-window, the description box always displays the description of the last item in the inventory and not the one that is selected in the discard pile.
Is this a bug, or caused by this script conflicting with KGC_CategorizeItem?

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww7.pic-upload.de%2F17.06.11%2Fkqwu1a3qcmap.png&hash=2db8a14c5add66de98b60afccf5b16669df001e3) (http://www.pic-upload.de/view-10358078/screen.png.html)
Title: Re: Limited Inventory
Post by: IXFURU on July 30, 2011, 12:03:01 PM
Question about this script:

Is it possible, or would it be possible to use only one part of the script?

I need only the part which does the item stacking limitations. 

DRIACS system gives the ability to discard items, and it seems to be incompatible when the two scripts are running together.  So, if there was a way to limit via switch or some sort of boolean flag the parts of this script which do the same thing as DRIACS, just so I could use the stack-size limits that would be very beneficial.  Thanks.
Title: Re: Limited Inventory
Post by: Dimosthennis on December 13, 2011, 01:15:14 PM
I tried some stuff to fix this bug that I found but I can't fix it :(
When I open the Item Manu I get this error:

Script 'Limited Inventory 1.1b' line 851: ArgumentError occurred.
Wrong number of arguments(2 for 0)

I am useing YEMs scripts I removed YEMs Item Overhaul.
Anyway of fixing this? :/
Title: Re: Limited Inventory
Post by: digdarkevil on December 14, 2011, 01:09:08 PM
AWESOME MA  ;)
Title: Re: Limited Inventory
Post by: hiromu656 on January 01, 2012, 06:20:39 AM
Is there any way to add inventory slots rather than change the amount of slots there are. For instance instead of acquiring a specific backpack ingame, you can find multiple pouches throughout the game that just add more slots to your total inventory space.
Title: Re: Limited Inventory
Post by: pacdiggity on January 01, 2012, 06:29:02 AM
Code: [Select]
s = $game_party.limit_inventory.slots.size
s += 6 # The amount you're adjusting the size by. This can be any operation (+, -, *, /)
# Then either:
$game_party.limit_inventory.resize(s)
# Or:
resize_inventory(s)
Title: Re: Limited Inventory
Post by: hiromu656 on January 03, 2012, 03:10:15 AM
There's no way I missed that...

Is that in the script? Or should I be adding that to it in some way?
Title: Re: Limited Inventory
Post by: pacdiggity on January 03, 2012, 03:27:29 AM
No, it's a command I whipped up just then. Use it in an event script call when you want to adjust the inventory. It should work, though I didn't test it.
Title: Re: Limited Inventory
Post by: hiromu656 on January 03, 2012, 04:08:31 AM
Sounds good. Thanks a lot.

But... How exactly do I get this to work? Should I make this its own script? Or is that entire thing one script call.
Title: Re: Limited Inventory
Post by: pacdiggity on January 03, 2012, 04:17:02 AM
It's a script call you use when you want to adjust the inventory relative to what it already is.
Essentially, it's only three lines:
Code: [Select]
s = $game_party.limit_inventory.slots.size
s += 6 # Or whatever
resize_inventory(s)
Title: Re: Limited Inventory
Post by: hiromu656 on January 03, 2012, 07:03:18 PM
I used this:
Code: [Select]
s = $game_party.limit_inventory.slots.size
s += 6 # Or whatever
resize_inventory(5)
All it did was change the inventory size to 5.

Then I used:
Code: [Select]
s = $game_party.limit_inventory.slots.size
s += 6 # Or whatever
resize_inventory(s + 5)
And what that did was for some reason subtract 5 from the total size. So I tried using a minus sign instead, and that did the same as what my initial test had done.

 ;9
Title: Re: Limited Inventory
Post by: pacdiggity on January 04, 2012, 01:34:08 AM
Check the last line of my code. It's an s, not a 5.
Title: Re: Limited Inventory
Post by: hiromu656 on March 04, 2012, 03:01:27 AM
Sorry, this is an extremely late reply, but I only used 5 because I thought that s was just a placeholder for a number. But at first, I used the s as it is but still nothing beneficial happened.

What I did was create an event in which you get a new pouch, then I called the script, (copying what you typed). When I tested the event, it resized my inventory to 6. So it didn't add more spaces.
Title: Re: Limited Inventory
Post by: pacdiggity on March 04, 2012, 03:16:17 AM
s stores the number $game_party.limit_inventory.slots.size
You can alter this number once you store it, i.e. s += 6, s *= 2, s -= 3, whatever.
Once you alter the number, you can resize the inventory with this altered number.
Code: [Select]
resize_inventory(s)
Title: Re: Limited Inventory
Post by: Mitsarugi on March 07, 2012, 11:05:14 AM
Modern Algebra could you add an option to have items that don't take up place at all please?