I7: Scoring/Table Problem

I’m trying to set up a table-based system for keeping track of achievements that result in scoring points. I’ve tried the following code:

[code]“Scoring Test” by RPR

This Place is a room.

Scoring for is an action applying to one topic.

Carry out scoring for:
Choose the row with an achievement of “[topic understood]” in the table of score awards;
If earned entry is false:
Now the score is score + points entry;
Now earned entry is true.

There is a gizmo in This Place. There is a gadget in This Place.

After taking the gizmo:
Try scoring for “getting the gizmo”.

After examining the gadget:
Try scoring for “examining the gadget”.

Table of Score Awards
Achievement Points Earned
“getting the gizmo” 1 false
“examining the gadget” 2 false

[/code]

This compiles fine, but results in a run-time error as follows:

Except for generating the error, the “scoring for” action seems to have worked correctly; it in fact increased the player’s score appropriately. I’m sure I’m missing something very basic here, but any help would be appreciated.

Thanks.

Robert Rothman

The problem is, I believe, that you’re trying to compare a topic with text. You could convert the topic to indexed text and specify that the achievements in the table are also indexed text, but it’s easier to drop the action completely and use a simple to-phrase so you can operate with plain text:

[code]To score for (description - text):
Choose the row with achievement of description in the table of score awards;
If earned entry is false:
Now the score is score + points entry;
Now earned entry is true.

After taking the gizmo:
score for “getting the gizmo”.

After examining the gadget:
score for “examining the gadget”.[/code]

Thanks.

Robert Rothman

[UPDATE: yay cross-post with Juhana. Added value in this post is that you need “continue the action” in these After rules, and maybe you need to make sure that they don’t get preempted by other After rules?]

Bad news: The scoring action doesn’t seem to be working correctly, as you can see by trying “x gadget.” You’ll only get one point, which suggests to me that after the run-time erroryour code is just picking the first row of the table.

The problem seems to be a type mismatch between what you’re looking for and what you’re checking. I was able to work around this by forcing both of them to be indexed text:

[code]“Scoring Test” by RPR

This Place is a room.

Scoring for is an action applying to one topic.

Carry out scoring for:
let accomplishment be indexed text;
let accomplishment be the topic understood;
Choose the row with an achievement of accomplishment in the table of score awards;
If earned entry is false:
Now the score is score + points entry;
Now earned entry is true.

There is a gizmo in This Place. There is a gadget in This Place.

After taking the gizmo:
Try scoring for “getting the gizmo”;
continue the action.

After examining the gadget:
Try scoring for “examining the gadget”.

Table of Score Awards
Achievement (indexed text) Points Earned
“getting the gizmo” 1 false
“examining the gadget” 2 false[/code]

But that’s a very kludgy solution, and indexed text is probably best avoided if you don’t need it. (Also, I fear it might goof up other actions involving topics.) I think you really want a “to” phrase rather than an action, since “to” phrases can take text arguments (and don’t involve the rest of the action machinery):

[code]“Scoring Test” by RPR

This Place is a room.

Scoring for is an action applying to one topic.

To score for (accomplishment - text):
Choose the row with an achievement of accomplishment in the table of score awards;
If earned entry is false:
Now the score is score + points entry;
Now earned entry is true.

There is a gizmo in This Place. There is a gadget in This Place.

After taking the gizmo:
score for “getting the gizmo”;
continue the action.

After examining the gadget:
score for “examining the gadget”.

Table of Score Awards
Achievement Points Earned
“getting the gizmo” 1 false
“examining the gadget” 2 false[/code]

By the way, you want to continue the action in your after rules – otherwise they’ll cut off the report stage. (I lazily only did that for taking; the text for examining the gadget gets printed in a Carry Out rule so it happens before the After stage ends the action.)

So why not make it a “carry out” rule? Given that it seems to happen silently anyway.

I’d probably make the achievement a kind of value rather than a text. I’m not sure it makes a difference in this case, but it seems more appropriate to the intent. In fact, if you do that, you don’t even really need a table.

[code]An achievement is a kind of value. Some achievements are defined by the Table of Score Awards.

Table of Score Awards
Achievement Points Earned
getting the gizmo 1 0
examining the gadget 2 0

To score for (item - an achievement):
if earned of item is 0:
Now the score is score + points of item;
now earned of item is the turn count;

This Place is a room. There is a gizmo in This Place. There is a gadget in This Place.

Carry out taking the gizmo:
Score for getting the gizmo

Carry out examining the gadget:
Score for examining the gadget
[/code]