Here's a code snippet to show what I have currently in my source code:
A morph is a kind of thing.
A morph has some text called animal name.
A serum is a kind of thing.
Revelation relates one serum to one morph. The verb to reveal (he reveals, he revealed, it
is revealed, he is revealing) implies the revelation relation.
In my game, I want drinking a serum to allow the player to transform into a specific animal. The name of that animal is stored as a text property called "animal name". I want to be able to reference this name given just the serum itself, so I added the relation between a morph and a serum object.
Then I add this rule:
Instead of drinking a serum:
say "You can now become a [animal name of
morph revealed by noun].";
now the morph revealed by the noun is held by the player;
What I'm doing here is printing this message, and then moving the relevant morph into the player's inventory. I'm doing this for other reasons, but I need to do this.
So for instance, given these assertions:
Felis morph is a morph. Cat serum is a serum.
Cat serum reveals felis morph.
The animal name of felis morph is "cat".
I would expect drinking the cat serum ingame to print "You can now become a cat.", and put felis morph into the player's inventory.
I get two errors though, that I'm not sure how to solve.
1) In the sentence 'say "You can now become a [animal name of morph revealed by noun]."' , it looks as if you intend 'animal name of morph revealed by noun' to be a property, but 'a morph' is not specific enough about who or what the owner is.
2) You wrote 'now the morph revealed by the noun is held by the player' : but this is not explicit enough, and should set out definite relationships between specific things, like 'now the cat is in the bag', not something more elusive like 'now the cat is carried by a woman.' (Which woman? That's the trouble.)
It seems the rule I added just doesn't want to work. It revolves around the [animal name of morph revealed by noun] part, and the 'morph revealed by the noun' part. Those sound like perfectly reasonable things to put down though. Animal name of morph revealed by noun should be a sayable statement. Morph revealed by the noun should be perfectly specific -- I specified that revelation relates ONE serum to ONE morph, after all.
What's the issue? Or rather, how do I get the animal name of the revealed morph as a text substitution, and how do I change the state of the morph revealed by the serum?
The problem here is that when you write a phrase like the morph revealed by noun
, where you are accessing an object through a relation, Inform assumes that multiple objects can have this property, even if that's not actually possible (such as this case, where the revealing relation is one-to-one).
The solution here is to use the determiner a random
to actually select an item from the list. This determiner will select a random object from the list it acts on, but as both lists here can only contain one object, you will get the same object each time. Here's a working example:
Instead of drinking a serum:
say "You can now become a [animal name of a random morph revealed by noun].";
now a random morph revealed by the noun is held by the player;
You can also use the determiner every
, but as that also gives you a list, it won't work for all applications (the second statement in the example above works, but not the first).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With