A recent question is related to this old thread, which I think is worth reviving for two reasons:
-
This type of setup almost works in 6M62, and the reasons that it doesn’t seem to have less to do with any inherent limitations and more to do with the compiler’s ability to parse property names in certain contexts.
-
Code that works around this in 6M62 won’t work at all in 10.1.2, which may be a regression.
Why this looks like a table parsing problem in 6M62
The OP’s goal was to create a table linking skills
to particular properties. Any of these properties would always be a number valued property
, so the kind of value is pretty specific.
A table like this will not be accepted in 6M62:
Table of Alt Skill Difficulties
Skill Ability (number valued property) Difficulty
brawl strength 4
dodge agility 4
However, a table like this will be (if the skills are first defined elsewhere):
Table of Alt Skill Difficulties
Skill Ability (number valued property) Difficulty
brawl -- 4
dodge -- 4
and in fact it will be possible to assign property values to the empty fields at run-time. For example, in 6M62:
When play begins:
choose row 1 in Table of Alt Skill Difficulties;
now the Ability entry is strength;
choose row 2 in Table of Alt Skill Difficulties;
now the Ability entry is agility;
showme the contents of Table of Alt Skill Difficulties;
will yield
Table of Alt Skill Difficulties
(row 1) | brawl | property 271 | 4 |
(row 2) | dodge | property 272 | 4 |
and those are the correct property IDs, as can be seen with:
showme strength;
showme strength of player;
showme agility;
showme agility of player;
yielding
numbers valued property: property 271
“strength of player” = number: 5
numbers valued property: property 272
“agility of player” = number: 3
This implies that the template code for tables is capable of handling this type of column, but the parser for table rows is not prepared to read the name of a property as a table column value in the same manner that it would for a showme
statement.
The following when play begins
rule (with a small I6 workaround for the compiler’s unwillingness to recognize a <table column> of <object>
phrase) pretty much works to get the table setup being sought, and should allow definition of phrases making use of the stored property:
To decide which number is (stat - number valued property) for (P - person): [note "for" not "of"]
(- ({P}.({stat})) -).
When play begins:
choose row 1 in Table of Alt Skill Difficulties;
now the Ability entry is strength;
choose row 2 in Table of Alt Skill Difficulties;
now the Ability entry is agility;
showme the contents of Table of Alt Skill Difficulties;
showme strength;
showme strength of player;
showme strength for player;
showme agility;
showme agility of player;
showme agility for player;
showme ability entry;
[showme (ability entry) of player;] [6M62 compiler doesn't accept, but it could]
showme (ability entry) for player;
(EDIT: removed incorrect comment about out-of-memory error in previous code block; that happened in an earlier version but not in what’s posted here.)
Possible regression in 10.1.2
The 10.1.2 compiler doesn’t like the code here at all. Attempting to compile the Table of Alt Skill Difficulties
results in an internal error, so it’s not possible to do a very good comparison between the two versions.
However, as shown by the 6M62 notes above, it certainly seems like a viable option for the compiler to do a better job of handling properties as first-class values in a way that would be beneficial to this type of scenario and others like it.
Sample code
For reference, here’s the full scenario that I was playing with:
Brawl and Dodge
"Brawl and Dodge"
Lab is a room.
A person has a number called strength.
A person has a number called agility.
Skill is a kind of value. Some skills are brawl and dodge.
Table of Alt Skill Difficulties
Skill Ability (number valued property) Difficulty
brawl -- 4
dodge -- 4
To decide which K is (stat - arithmetic value of kind K valued property) for (P - person): [note "for" not "of"]
(- ({P}.({stat})) -).
When play begins:
choose row 1 in Table of Alt Skill Difficulties;
now the Ability entry is strength;
choose row 2 in Table of Alt Skill Difficulties;
now the Ability entry is agility;
showme the contents of Table of Alt Skill Difficulties;
showme strength;
showme strength of player;
showme strength for player;
showme agility;
showme agility of player;
showme agility for player;
showme ability entry;
[showme (ability entry) of player;] [6M62 compiler doesn't accept]
showme (ability entry) for player;
The strength of the player is 5. The agility of the player is 3.