I am trying to find an item in a table so that I can increment one of its properties, also in the table. The phrasing is so obscure in the examples. Can someone help me out.
Here is what is not working:
Carry out appraising:
now money of player is money of player - APPRAISAL_FEE;
say "You give Ganon [APPRAISAL_FEE] gp appraisal fee. You now have [cash][line break]";
let price be a real number;
now price is cost of noun * 0.80;
say "Ganon nods and examines the item closely. He looks up and says, 'Well! I'll give you [coinage of price] for that fine [noun].' [line break]";
say "Do you want to sell this?";
if player consents:
now money of player is money of player + price;
now weight of cash is cashWeight;
say "You now have [cash][line break]";
if there is an Item corresponding to the noun in the Table of Body Protection:
say "[current table row]";
increment qty of Item entry;
now noun is nowhere;
say "There are [qty of noun] [noun]'s now.[line break]";
otherwise:
say "Can't find that [noun] for sale here.";
otherwise:
say "Ganon returns the [noun] to you. Okay, maybe next time.";
The problem is finding the noun (leather armor) and incrementing the qty property in that item. What is the magic phrase, please? Iâm all out of guesses.
Here is the table:
Table of Body Protection
Item Nbr Cost Weight AC
padded robe 2 0.5 1.0 11
leather armor 3 15.0 20.0 13
chain mail 2 75.0 50.0 15
plate mail 1 400.0 80.0 17
shield wooden 3 0.9 5.0 1
shield metal 2 15.0 15.0 2
Thank you. I thought I tried all the combinations of phrasings but Iâll try your suggestion again. I had this working and canât recall how. I know that I only saw the qty increase when I redisplayed the table, which is ok.
Note that after I update the Item, I move it to nowhere bc the table is displayed from items sitting in nowhere. They are not really in the location.
Sorry. I get the same runtime error.
*** Run-time problem P21: Attempt to look up a non-existent correspondence in the table âTable of Body Protectionâ
I can see leather armor in the table, but it is not recognized.
"Lab"
Lab is a room.
Table of Body Protection
Item Nbr Cost Weight AC
padded robe 2 0.5 1.0 11
leather armor 3 15.0 20.0 13
a padded robe is a thing.
a leather armor is a thing.
Instead of jumping:
choose row with an Item of leather armor in the Table of Body Protection;
say "[Nbr Entry] - [Cost Entry] - [Weight Entry] - [AC Entry]";
Lab
>jump
3 - 15.0 - 20.0 - 13
>
Are padded robe, leather armor and the other ones things or kind of things ?
I can get a search for leather armor specifically to work in a test, but I donât know what the noun is in general when I try to appraise (something). All the items in the table are things. Inform wonât let me put kinds into tables.
I think the problem is that the noun comes in as text, and canât be matched with the object name in the table. Iâm going to try to associate the text name and object name with a UID in common.
But, if I understand well, you know that the item is enclosed by the player, otherwise Ganon wonât buy it.
May be this litlle experiment will help to illustrate a thing-to-thing approach:
Lab is a room.
The distant lab is north of Lab.
Table of Body Protection
Armor Nbr Cost Weight AC
padded robe 2 0.5 1.0 11
leather armor 3 15.0 20.0 13
An armor is a kind of thing.
a padded robe is an armor.
a leather armor is an armor.
a padded robe is in the distant lab.
a leather armor is in the distant lab.
a yellow duck is in the distant lab.
appraising is an action applying to one visible thing.
Understand "appraise [any thing]" as appraising.
Check appraising when (the noun is not enclosed by the player):
say "You do not have [a noun], little joker!";
Carry out appraising when (the noun is enclosed by the player) and (the noun is an armor listed in the Table of Body Protection):
choose row with an armor of the noun in the Table of Body Protection;
say "[Armor entry]: Nbr [Nbr entry], Cost [Cost entry], Weight [Weight entry], AC [AC entry].";
Check appraising when (the noun is enclosed by the player) and (the noun is not an armor listed in the Table of Body Protection):
say "I do not buy [a noun], go away, you looser!";
Lab
>appraise padded robe
You do not have a padded robe, little joker!
>n
distant lab
You can see a padded robe, a leather armor and a yellow duck here.
>take all
padded robe: Taken.
leather armor: Taken.
yellow duck: Taken.
>s
Lab
>appraise padded robe
padded robe: Nbr 2, Cost 0.5, Weight 1.0, AC 11.
>appraise yellow duck
I do not buy a yellow duck, go away, you looser!
>appraise my smartphone
That noun did not make sense in this context.
>
If you prefer : Understand "appraise [something]" as appraising.
then a distant armor and a non-existent item are treated in the same way :
You can't see any such thing.
which is probably better (and could be customized) to avoid spoilers.
Maybe I have found something that could interest you, I donât knowâŚ
Some time ago, I was also confronted with a problem of matching text entered by a player with its existence (as text) as a value in a table column. My problem was that if the player entered text that was not expected in the table, a statement such as:
choose row with PID of "[SequentialChoice]" in LocalTable;
systematically generated a Runtime error (which seems to be as expected).
Since we canât anticipate everything the player is going to grab and try to capture, for example (in the case of a number):
if (the player's command matches the regular expression "^\d+$"):
now SequentialChoice is the player's command;
Thatâs how I got away with it (I canât guarantee that the process is optimal):
To decide if a row with PID (PID - a text) exists in (T - a table name):
repeat through T:
if (the PID entry is PID), decide yes;
decide no.
which then enables:
if (a row with PID "[SequentialChoice]" exists in LocalTable):
choose row with PID of "[SequentialChoice]" in LocalTable;
and then establish links between texts and things in the table.
I think this is helpful, but I donât understand the distinction between âappraise [any thing]â and âappraise [something]â. It turns out all my things that can get appraised are subkinds of Equipment, so I say âappraise [equipment]â. Which option is that most similar?
When we use verb [any thing], this verb can apply to any thing even if itâs not in the playerâs scope. (i.e., things the player cannot currently see or interact with).
When we use verb [something], this verb applies to something in the playerâs scope. (Iâm not sure itâs as clear-cut as that here, perhaps the precise type of interaction possible comes into play, to be confirmed).
This is why [any thing] allows:
>appraise padded robe
You do not have a padded robe, little joker!
whereas [something] causes:
>appraise padded robe
You can't see any such thing.
when the player does not have the armour in question.
In the first case, the rule:
Check appraising when (the noun is not enclosed by the player):
say âYou do not have [a noun], little joker!
is triggered, even if the noun is elsewhere. This is because the noun exists in the world model. This could allow the player to guess what armour exists without having to move.
I think that in your case, [something] is the better of the two options, so that the appraise verb is universal and scalable, while preventing code bypass attempts to guess the items hidden in every room of the dungeon.
Yes, thanks. I have run into this problem before. I am trying âappraise [Equipment]â and âsell [Equipment]â to see how that works. All my armor, weapons, and other goods are subkinds of Equipment.
Well, âsell [Equipment]â didnât work, and neither did âsell [something]â. I get the same error for both:
â>â sell leather armor
I only understood you as far as wanting to sell my leather armor
I set up the action thusly:
Selling is an action applying to one thing.
Understand "sell [something]" as selling.
I would like to use this, but how do I specify the row in which it was found for later statements. Is it âthe chosen rowâ or the ârow understoodâ or do I need to count rows so that it becomes row N? I repeatedly get an error for undefined row, despite my say statement that it was found.
I use a PID to associate myLeatherArmor (worn) with leather armor, both of which have a PID of 102.
To carry out selling:
say "Trying to increment Ganon's inventory...[line break]";
let tbl be Table of Body Protection;
if there is a PID of 102 in tbl:
let Q be the Nbr of the row understood;
increment Q;
say "[Item] now has a Qty of [Q] ";
now noun is nowhere;
otherwise:
say "[PID of noun] not found in inventory. ";
The error I get says
In the sentence âlet Q be the Nbr of the row understoodâ, I was expecting to read a value, but instead found some text that I couldnât understand - âNbr of the row understoodâ.
Nbr is a column name in the table being searched, and it contains numbers. How is this possible?