Viability of using a Subroutine File for Inventory

Hey, everyone!

I’m currently working on both the equipment and inventory systems for my WiP title. While doing so, my way of implementing inventory will truthfully create quite a large file. Right now, the actual items themselves are stored within the choicescript_stats file.

What I’m seeking to do instead (as I have many other functionalities built in my stats file) would be to create a separate file for the inventory. I would like it to still be linked to the Stats page, so my theory (I haven’t implemented it yet) would be to use this secondary file as a subroutine. Upon selecting a section of the inventory such as weapons, it would go to the subroutine file and read that weapons list. This would allow me to clean it up, use less dragdown code on the stats page itself, and work with a bit less stress.

My question would be if anyone has attempted something of this nature, and if you perceive that this could cause a later issue. I’d appreciate any insight/feedback.


I happened to code an inventory system, however, it’s not finished yet.

        *goto inventory
    *if body_e[1] = "false"
        #Equip $!{body[1]}.
            *set body_e[1] "true"
            *goto body
    *if body_e[1] = "true"
        #Unequip $!{body[1]}.
            *set body_e[1] "false"
            *goto body
    *if body_e[2] = "false"
        #Equip $!{body[2]}.
            *set body_e[2] "true"
            *goto body
    *if body_e[2] = "true"
        #Unequip $!{body[2]}.
            *set body_e[2] "false"
            *goto body
    *if body_e[3] = "false"
        #Equip $!{body[3]}.
            *set body_e[3] "true"
            *goto body
    *if body_e[3] = "true"
        #Unequip $!{body[3]}.
            *set body_e[3] "false"
            *goto body
    *if body_e[4] = "false"
        #Equip $!{body[4]}.
            *set body_e[4] "true"
            *goto body
    *if body_e[4] = "true"
        #Unequip $!{body[4]}.
            *set body_e[4] "false"
            *goto body
    *if body_e[5] = "false"
        #Equip $!{body[5]}.
            *set body_e[5] "true"
            *goto body
    *if body_e[5] = "true"
        #Unequip $!{body[5]}.
            *set body_e[5] "false"
            *goto body

You can code a system that allows the player to replace an item in the inventory if it becomes full. You will also need a way to figure out what item the player has equipped so it changes the MC stats.

This allows for a very compact inventory, but a subroutine for checking if the item are in the inventory and equipped will take a lot of coding. Edit: Don’t forget to add another variable to keep track of what the player equipped so they cant equip more than one type of equipment at a time.

Edit: Something like this to change stats.

*label sub
*if body_e[1] = "true"
    *if body[1] = "Bronze Body"
        *set p_defense +5
        *set p_agility -1
1 Like

Perfectly reasonable idea. How you implement it (beyond use of gosub_scene) is the devil in the details, but it’s perfectly plausible.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.