If you want, there’s something else you can do to go with what @will posted above. By using arrays you can define items and their stats so you don’t have to set them when calling the *gosub.
Let’s assume each armor will have a name, DR, price, a boolean to represent if it’s equipped or not and another boolean to represent if the item was acquired or not (either found or bought from a shop for example).
*create armors_1_1 "Leather Helmet"
*create armors_1_2 2
*create armors_1_3 100
*create armors_1_4 false
*create armors_1_5 false
*create armors_2_1 "Leather Gauntlets"
*create armors_2_2 1
*create armors_2_3 50
*create armors_2_4 false
*create armors_2_5 false
So what we have is a two dimensional array (like a table); the first bracket will be the ID of the item (either 1 for helmet or 2 for gauntlets) while the second bracket is the attribute (either 1 for name, 2 for the DR or 3 for the price).
Suppose we wanted to display the price of the leather gauntlets, we would use ${armors[2][3]}
since we are looking at ID 2 (the gauntlet) and attribute 3 (the price). In the end, what would be displayed would be 50
.
So that we don’t need to remember the numbers of each, we can assign some simple variables.
*create id_helmet 1
*create id_gauntlet 2
*create item_name 1
*create item_dr 2
*create item_price 3
*create item_equipped 4
*create item_acquired 5
These will make it simple so we don’t have to remember which number is what. To use the same example again, trying to display the leather gauntlets price, now we could say it as: ${armors[id_gauntlet][item_price]}
which would be the same as ${armors[2][3]}
like before; this is just a way so you don’t have to remember which number is what.
So applying this to @will’s example, you could have the subroutine very similar and have it take the values from the array instead of you always having to type it in when calling the *gosub.
*gosub equip id_helmet
...
*label equip
*params
You @{armors[param_1][item_equipped] remove|equip} your ${armors[param_1][item_name]}, @{armors[param_1][item_equipped] reducing|increasing} your damage resistance by ${armors[param_1][item_dr]}.
*if (armors[param_1][item_equipped] = true)
*set armors[param_1][item_equipped] false
*set DR - armors[param_1][item_dr]
*else
*set armors[param_1][item_equipped] true
*set DR + armors[param_1][item_dr]
*return
So when you make an inventory screen to the player, you can show them only what item they have acquired.
*label inventory_screen
Current DR: ${DR}.
*choice
*if (armors[id_helmet][item_acquired]) #@{armors[id_helmet][item_equipped] Remove|Equip} the helmet.
*gosub equip id_helmet
*goto inventory_screen
*if (armors[id_gauntlet][item_acquired]) #@{armors[id_gauntlet][item_equipped] Remove|Equip} the gauntlets.
*gosub equip id_gauntlet
*goto inventory_screen
#Go back.
*return
This will let you do all the things by simply sending id_helmet
or the id of whatever item you want the equip
*gosub to run.
This also simplifies you making any sort of shop. Here is a way to make one subroutine for any armor you want to sell.
*label shop_screen
"So, gonna buy anything?"
*choice
*if (armors[id_helmet][item_acquired] = false) #"Show me the helmet."
*gosub shop id_helmet
*goto shop_screen
*if (armors[id_gauntlets][item_acquired] = false) #"Let me take a look at the gauntlets."
*gosub shop id_gauntlets
*goto shop_screen
#Leave the shop.
*return
..........................
*gosub shop
*params
"Sure, have a look."
The ${armors[param_1][item_name]} provides ${armors[param_1][item_dr]} points of damage resistance; it costs ${armors[param_1][item_price]} gold.
*fake_choice
*selectable_if (player_gold >= armors[param_1][item_price]) #Buy the ${armors[param_1][item_name]}. (${armors[param_1][item_price]} gold)
*set player_money - armors[param_1][item_price]
*set armors[param_1][item_acquired] true
The shopkeeper packs the ${armors[param_1][item_name]} and hands it to you. "Thanks for the purchase!"
#Go back.
*return
You could use *set armors[param_1][item_acquired]
true for items you find on the ground at any time too. About the ring thing you could edit the equip *gosub
to have similar effects into your attributes or just make other *gosubs
to handle that too.
Here’s more info on the @{}
(multireplace).