Increased bag size

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Increased bag size

Post by maunderingcabal »

Is it possible to make an equip-able item that increases inventory size?
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

First, you want to set an "is equipped TAG" on the item editor. Then you'll want to write a plotscript that checks whether that tag is on, and uses "set inventory size(new size)" to resize the inventory.

Code: Select all

plotscript, custom items menu script, begin
    if(check tag(tag:bigger bag)) then(
        # set this value to whatever you want
        set inventory size(30))
    else(
        # set this value to whatever you want
        set inventory size(12))
    
    # this opens the items menu as if done so by the
    # default menu item. 
    items menu
end
You'll have to set this plotscript to run at some point between when the item is equipped and when the inventory is next opened. I would recommend changing the menu item "Items" in the main menu to be of type "4 Run Script" and change the subtype to "custom items menu script" or whatever you call the script.
My pronouns are they/them
Ps. I love my wife
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

YOU ROCK MAN! That was exactly what I was looking for! Thanks a ton.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Happy to help :)

Glad it worked, too. Let me know if there are any bugs with it or anything like that.
My pronouns are they/them
Ps. I love my wife
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

EDIT: Oops! look how much I miss while I am typing! :)

Hmmm...

This is tricky.

A script that changes inventory size is not hard, you can use the "set inventory size" command.

Triggering the script in response to equipping an item is a little more complicated. You could edit your main menu and replace the "Equip" menu with something like this

Code: Select all

plotscript, equip menu wrapper, begin
  equip menu
  if(check tag(tag:bag of holding)) then(
    set inventory size(500)
  )else(
    set inventory size(100)
  )
end
This might seem to work, but it has an obvious problem, which is if you unequip the bag and your inventory shrinks, stuff past slot 100 becomes unusable until the bag is re-equipped.

There are different ways of handling that, depending on what behavior you want.

I think the easiest way to do this is to make the bag a one-time-usable item that expands your inventory and is then consumed. That would be much easier than an equippable item.
Last edited by Bob the Hamster on Tue Nov 08, 2016 10:04 pm, edited 1 time in total.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

EDIT: Oops! look how much I miss while I am typing! :)
Beat you to it!
This might seem to work, but it has an obvious problem, which is if you unequip the bag and your inventory shrinks, stuff past slot 100 becomes unusable until the bag is re-equipped.
I hadn't considered this. I thought I might be overlooking something. I would have assumed it would wipe memory of the items in those slots. Is there any way to prevent the player from unequipping something? Where would you set that script to be run?
My pronouns are they/them
Ps. I love my wife
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

Bob the Hamster wrote:EDIT: Oops! look how much I miss while I am typing! :)

Hmmm...

This is tricky.

A script that changes inventory size is not hard, you can use the "set inventory size" command.

Triggering the script in response to equipping an item is a little more complicated. You could edit your main menu and replace the "Equip" menu with something like this

Code: Select all

plotscript, equip menu wrapper, begin
  equip menu
  if(check tag(tag:bag of holding)) then(
    set inventory size(500)
  )else(
    set inventory size(100)
  )
end
This might seem to work, but it has an obvious problem, which is if you unequip the bag and your inventory shrinks, stuff past slot 100 becomes unusable until the bag is re-equipped.

There are different ways of handling that, depending on what behavior you want.

I think the easiest way to do this is to make the bag a one-time-usable item that expands your inventory and is then consumed. That would be much easier than an equippable item.
I couldn't do it as a consumable. This definitely requires equiping
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

No, reducing the size of the inventory definitely doesn't delete stuff past the new end, just makes it unreachable.

I just checked the plotscripting dictionary and was surprised that I couldn't find a command to trigger the built-in auto-sort. I could possibly add one.

It is also completely possible to write your own inventory sorting using the commands that get/set inventory items by slot.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

It would be more correct to run the script after using the equip menu instead of before opening the inventory, in case the player doesn't go to the inventory immediately.
Although reducing the inventory size doesn't delete anything past the end, you can't gain more items once it's full (they just disappear into the void).

You might want use a script to delete anything past the end of the inventory. If you sort the inventory first so that all the important items (like quest items) are at the front and unimportant ones at the end, you can more safely delete them. (BTW, Giz recently posted a script to sort the inventory alphabetically.)

Here's an even easier solution: if you unequip the item, use a for loop to check whether any of those inventory slots that will become unusable have anything in them, and if so forcibly re-equip the item and show a textbox telling the player they need to dump something first.
Last edited by TMC on Wed Nov 09, 2016 1:50 am, edited 1 time in total.
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

TMC wrote:Here's an even easier solution: if you unequip the item, use a for loop to check whether any of those inventory slots that will become unusable have anything in them, and if so forcibly re-equip the item and show a textbox telling the player they need to dump something first.
Where would one set this script to be run? Can we manipulate special screens yet?
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Run it after the equip menu. Yes, that means that you can't undo the player's action until they leave the menu, which isn't ideal.
Post Reply