So, I’ve been trying to make a kind of a potion system with various potions doing various things upon drinking. Now, me being lazy, I thought if I could set up phrases on the potions, I could then just run the respective phrases during the drinking action. Unfortunately, I have been completely unable to do so, and I’m not entirely sure it’s even possible in I7. Basically, something like this (the intended parts being in comments):
[code]“A Drinking Game” by Birion
A potion is a kind of thing. [A potion has a phrase called effect.]
A red potion is a kind of potion.
[
The effect of the red potion is heal for 2 HP.
]
A blue potion is a kind of potion.
[
Instead of drinking a potion:
effect of the noun.
]
The player has a number called health.
When play begins:
now the health of the player is 5;
Maximum health is a number that varies. Maximum health is 10.
To heal for (X - a number) HP:
now the health of the player is the health of the player + X;
if the health of the player is greater than maximum health:
now the health of the player is maximum health;
Mainroom is a room.
There are two red potions in mainroom.[/code]
The advantage (at least to me) of this approach over something like
Instead of drinking a potion:
if the noun is a blue potion:
refresh for 2 MP;
if the noun is a red potion:
heal for 2 HP;
...
is that I can set the drinking part once and then define the potions as I need them and don’t have to go back to the drinking action and update it every time I come up with an idea for an effect.
As I was scrolling through the documentation, I thought that stored actions might be what I was looking for, but as far as I could tell, it was another red herring. Therefore I pose this question to people way better at Inform than me: is this actually possible? Can this be done?