How to code an inventory system?

So i want to know how to make an inventory like thing. in future games i will use it to hold items but in born a king i would like to use it to keep track of what kinds of troops your army has and how many of them. How do i go about this?

you store variables for each type of troop or item you want to track. In choicescript_stats, you use a fairly simple series of IF statements to display the inventory. Here is sample code from my game (which I modified from Choice of Vampires):

*label BuildInventory *temp inventory *set inventory "" *temp comma *set comma false *if empty *set inventory &"You carry nothing." *set comma false *if revolver *set inventory &"Revolver" *set comma true *if pistol *if comma *set inventory &", " *set inventory &"Pistol" *set comma true *if rifle *if comma *set inventory &", " *set inventory &"Rifle" *set comma true

To list number of troops, you can just add the variable to each inventory row.
In the example, NumPikemen and NumKnights are used to store number of each unit.
*temp troops *set troops "" *if NumPikemen > 0 *set troops &"Pikemen: "&NumPikemen *set comma true *if NumKnights > 0 *if comma *set troops &", " *set troops &"Knights: "&NumKnights *set comma true

And keep building on it.

Thanks so much this helps a ton.

What should you write in Startup to have Inventory works?