Main Menu
  • Welcome to The RPG Maker Resource Kit.

Limited Inventory

Started by modern algebra, April 27, 2009, 10:11:22 PM

0 Members and 2 Guests are viewing this topic.

wnhero

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.

modern algebra

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.

wnhero

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.

wnhero

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.

modern algebra

Alright; yeah, that would definitely cause the problem. I am happy that you have resolved it :)

Fizzly

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

Regards,
Mike

modern algebra

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

Fizzly

#57
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!
Regards,
Mike

rofl1337

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

modern algebra

If I recall correctly, then no there is not. Sorry.

rofl1337

#60
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).

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?


modern algebra

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:


#==============================================================================
# ** 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.

rofl1337

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

modern algebra

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:


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:


$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.

rofl1337

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

Kureigu

#65
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 :|?

modern algebra

Well, the "x" is a label set up by in the configuration region. Maybe you changed it from "x" to "10 "

Kureigu

yeah i was thinking that was the problem  :-[ . haha im so stupid at times :P
thanks for the script again, i LOVE it!!

TwilightYagami

Sorry for the late post, but would it be possible for the script to work with Yanfly Engine Melody Item Scripts? Thanks.

modern algebra

I don't know. What are they and can you link me to them?

wsensor

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.

Rinkachi

Nice script, just what I needed! :D

hiromu656

Could I have the loot screen come up at all times?

Mitsarugi

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?

modern algebra

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.