Listing Descriptions Of Items

Hello,

I’m new to developing IF and I am using Inform 7.
I’ve reached an impasse. After going through all documentation I can’t figure out why this works and doesn’t
I can examine an item from my table in game but as soon as I take it and then examine it it causes a run time error.

Would anyone have a clue why this doesn’t work?

The code I have is as follows:

[code]Table of Point Values Descriptions
item score description1 description2
toilet brush 5 “A toilet brush. It’s painted black by the manufacturer for a reason you know. If I was you I would not pay any attention to it.” “Spiky and plastic, exactly how I like my women.”
piece of tile 2 “It’s a tiny piece of tile about two inches long, looks sharp.” “This is a small piece of tile. It looks like it could cut something.”
floormat 1 "It’s rubbery on one side. Blue and fluffy on the other. " “A regular every day floor mat. It absorbs bath water that falls off your body. Oh it is also blue.”

a piece of tile is in the bathroom.
the floormat is in the bathroom.
a toilet brush is in the bathroom.
instead of examining the noun:
say “[if the turn count is even][the description1 corresponding to a item of the noun in the Table of Point Values Descriptions][otherwise][the description2 corresponding to a item of the noun in the Table of Point Values Descriptions][end if]”.

Report taking an item listed in the Table of Point Values Descriptions:
increase the score by the score entry;
blank out the whole row.[/code]

Output:

Table of Point Values Descriptions
item score description1 description2
toilet brush 5 “A toilet brush. It’s painted black by the manufacturer for a reason you know. If I was you I would not pay any attention to it.” “Spiky and plastic, exactly how I like my women.”
piece of tile 2 “It’s a tiny piece of tile about two inches long, looks sharp.” “This is a small piece of tile. It looks like it could cut something.”
floormat 1 "It’s rubbery on one side. Blue and fluffy on the other. " “A regular every day floor mat. It absorbs bath water that falls off your body. Oh it is also blue.”

a piece of tile is in the bathroom.
the floormat is in the bathroom.
a toilet brush is in the bathroom.
instead of examining the noun:
say “[if the turn count is even][the description1 corresponding to a item of the noun in the Table of Point Values Descriptions][otherwise][the description2 corresponding to a item of the noun in the Table of Point Values Descriptions][end if]”.

Report taking an item listed in the Table of Point Values Descriptions:
increase the score by the score entry;
blank out the whole row.

The problem is that you’ve made your examining rule apply to any object whatsoever, whether or not it’s listed in the Table of Point Values Descriptions. But after you take one of those objects, its row gets erased from the Table of Point Values Descriptions (that’s what “blank out the whole row” does).

So when you examine it, Inform looks for “the description1 corresponding to a item of the noun in the Table of Point Values Descriptions,” which means finding the row in the table whose item entry is the noun. But there isn’t any such row anymore! So it throws a run-time error. I bet that if you examine something that was never in the Table of Point Values Descriptions, it will throw the same error (try “x me”).

One way to solve this would be to change the instead of examining rule to be like the report taking rule:

instead of examining an item listed in the Table of Point Values Descriptions: say "[if the turn count is even][the description1 corresponding to a item of the noun in the Table of Point Values Descriptions][otherwise][the description2 corresponding to a item of the noun in the Table of Point Values Descriptions][end if]".

This would let the normal examining mechanics apply when the item wasn’t listed in that table (anymore). If you want to keep the descriptions even after the player has examined the item and got the points, you could add another true/false column to the table that keeps track of whether it’s been taken–then instead of blanking out the row, change the entry to true when it’s been taken, and don’t award points if the entry is true. Or you could use the built-in “handled” property to, er, handle that (I think if you test “if the noun was not handled” then it will come out true only if the player never had the item before this turn).

(By the way, discouraging the player from paying attention to something and then giving them points for taking it probably isn’t the best design.)

Thanks a bunch! it was that blank out entire row. I thought that command was to do with screen display. not deleting from the table. I was playing around with the idea of all things / objects in a massive table.
I appreciate the info.

I will try it with report like you said.

Can I do an if statement like if there is an item corresponding the the noun in the table of whatever when I tried that it doesn’t let me.

instead of examining the noun: If there is a item corresponding to the noun in the Table of Items: say "[if the turn count is even][the description1 corresponding to a item of the noun in the Table of Items][otherwise][the description2 corresponding to a item of the noun in the Table of Items][end if]".

The problem there is that your “Instead of examining the noun” rule always runs (because you’re always examining the noun). And when “Instead” rules run, they by default stop the action even if they don’t do anything else. (After all, they’re rules for doing something instead of examining it.)

The rule I gave above, where the “instead” rule header is given more specificity, avoids that, because the rule doesn’t run at all when we aren’t examining an item listed in the Table of Point Values Descriptions; so you don’t get the normal “Instead” effects. Another way to do this would be end the rule like this:

instead of examining the noun: If there is a item corresponding to the noun in the Table of Items: say "[if the turn count is even][the description1 corresponding to a item of the noun in the Table of Items][otherwise][the description2 corresponding to a item of the noun in the Table of Items][end if]".; otherwise: continue the action.

“Continue the action” tells Inform not to stop the action, even though it’s an “Instead” rule.