Table phrasing

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

It is probably:

choose row with an Item of leather armor in the Table of Body Protection

or

choose row with an Item of noun in the Table of Body Protection

then:

let LocalItem be Item entry;
increment qty of LocalItem;

Warning : if you want to increase the Nbr entry, you’ll have to write in the table.

1 Like

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.

1 Like

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.

1 Like

OK. Thank you for trying. This code works:

"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.

1 Like

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.

Is this different from the built-in phrase:

if there is a [column name] of [value] in [table]

?

1 Like

No, It works well, thank you, I can now remove my unnecessary phrase.

1 Like

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?

1 Like

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.

1 Like

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?

Perhaps what you need is:

let Q be the Nbr corresponding to a PID of 102 in tbl;

Just a guess, since I can’t test at the moment.

Thanks. I’ll give that a try. Inform has so many “magic chants” in its syntax it makes using the language frustrating.