I want to match a property of an item with inventory with a property being bought.
The property is the PID of the parent kind. The player can not buy a second PID if he/she already has one. For example, if the player already has armor (PID = 100), the player cannot buy another one. There are many kinds of armor, but all have PID = 100.
This is the check purchase rule:
say "Noun is [noun]. It has a PID of [PID of noun][line break]";
if noun is not purchasable:
stop the action;
if player has PID of something with PID of noun:
say "You already have [the noun]. You can't wear another one, and it's too bulky to carry around with you.";
stop the action;
The parser flags my line if player has PID of something with PID of noun: but I donât know what works.Any advice in phrasing?
I guess, in general, I donât know how to search through inventory. Do I use a loop to traverse inventory, or âcontents of inventoryâ or âlist of inventoryâ? Inform seems to be smart enough to know inventory is a list.
This uses some fancy Inform features, but I think itâs the most elegant way:
Matching relates a thing (called X) to a thing (called Y) when the PID of Y is the PID of X.
The verb to match means the matching relation.
...
if the player encloses something (called the alternative) that matches the noun:
say "You already have [the alternative]." instead.
...
I revised my code, but these statements give me a parsing error.
Error: In the sentence âif the player encloses something (called owned) that matches the nounâ, I was expecting to read a value, but instead found some text that I couldnât understand - âplayer encloses something (called owned) thatâ.
I was trying to match one of these phrases:
(player encloses something ( called owned ) that - value) matches (noun - description of values)
(player encloses something ( called owned ) that - snippet) matches (noun - topic)
I recognised:
noun = a non-temporary variable, holding an object
But I didnât recognise âplayer encloses something ( called owned ) thatâ.
Your code inserted into my code is
[Set parent-child relationship.]
Matching relates a thing (called X) to a thing (called Y) when the PID of X is the PID of Y.
The verb to match means the matching relation.
This is the check purchase rule:
say "Noun is [noun]. It has a PID of [PID of noun][line break]";
if noun is not purchasable:
stop the action;
if the player encloses something (called owned) that matches the noun:
say "You already have [owned]. You can't wear another one, and it's too bulky to carry around with you.";
stop the action;