I have a kind of armor. I want to assign traits to that armor. I could do this by listing the name, description, cost, weight, etc. for each until I fill out pages of text describing all the armor. For convenience, I want to assign these traits from a table so that I can see and compare them all together in one few-inch space.
Armor is a kind of equipment. Armor is wearable. Armor has a number called AC.
Table of Body Protection
Armor Cost Weight AC
padded robe 0.5 3.0 11
leather armor 15.0 20.0 13
chain mail 75.0 50.0 15
plate mail 400.0 80.0 17
shield wooden 1.0 5.0 1
shield metal 5.0 15.0 2
To initArmorTable:
repeat through the Table of Body Protection:
assign traits to Armor entry consulting Table of Body Protection;
now AC of armor entry is AC entry;
To assign traits to (LocalItem - a thing) consulting (LocalTable - a table name):
choose row with an item of Localitem in Localtable;
now cost of LocalItem is cost entry;
now weight of LocalItem is weight entry;
I get the error that the Armor entry is a kind, and cannot be assigned into a table. I donât understand this. I have done this elsewhere when I assign Spell traits when each spell is a kind.
A spell is a kind of thing. Bless is a spell. Light Healing is a spell.
Table of Clerical Master Spells
Spell (spell) Casting (number) Notes (text)
Bless 1 "+1 to hit, -1 to be hit for one battle"
Light Healing 1 "Heals d8+1 HP dmg"
to initClericalSpells:
repeat through the Table of Clerical Master Spells:
assign traits to Spell entry consulting Table of Clerical Master Spells;
To assign traits to (LocalItem - a thing) consulting (LocalTable - a table name):
choose row with Spell of Localitem in Localtable;
now casting of LocalItem is casting entry;
now notes of LocalItem is notes entry;
Can someone point out the difference between the armor and the spells, please; and what I should do differently?
EDIT: I should point out that Equipment has a real number called cost and weight;
and Spells have traits Casting and Notes.
For one thing, it doesnât seem like youâve defined what âpadded robeâ and âchain mailâ and such are. Youâll notice that you established âblessâ and âlight healingâ as spells outside of that table; thatâs a huge part of the difference. It wants to match existing armors there. You would need to:
A: declare them, orâŚ
B: Write âSome armor is defined by the table of body protection.â which, given how you want to initialize things at large, you probably donât want to do.
Aside from that, âchoose row with an item of Localitem in Localtable;â isnât doing anything here it seems. Inform doesnât know what âitemâ is, and my previous examples used it as a declared temporary variable. Do you want to use this âassign traits toâ line of code with other tables? If so, it would be best to give all of those âitemâ entries a universal name. Iâve chosen âgearâ for my example.
The garden is a room.
Equipment is a kind of thing. Armor is a kind of equipment. Armor is wearable. Armor has a number called AC.
Some armor is defined by the table of body protection.
Table of Body Protection
Gear (an armor) Cost Weight AC
padded robe 0.5 3.0 11
leather armor 15.0 20.0 13
chain mail 75.0 50.0 15
plate mail 400.0 80.0 17
shield wooden 1.0 5.0 1
shield metal 5.0 15.0 2
To initArmorTable:
repeat through the Table of Body Protection:
assign traits to gear entry consulting Table of Body Protection;
now AC of gear entry is AC entry;
To assign traits to (LocalItem - a thing) consulting (LocalTable - a table name):
choose row with a gear of Localitem in Localtable;
now cost of LocalItem is cost entry;
now weight of LocalItem is weight entry;
If âpadded robeâ is a single padded robe and not an entire categorization of padded robes within your world, this should be fine. If âpadded robesâ are a kind of armorâŚ
You might be better off going âA shield metal is a kind of armor. The cost of a shield metal is usually 5.0. The weight of a shield metal is usually 15.0. The AC of a shield metal is usually 2.â.
It sounds like what you want is possibly Some kinds of armor are defined by the Table of Body Protection.⌠but unfortunately that syntax was broken in 10.1.
A. I have previously defined all the armor with associated descriptions, which I use as a base for specific armors. I didnât want to include all those declarative lines of code here.
B. âSome armor is defined by the table of body protection" sounds like a plan. It seems like it will get around the parser error. Iâm not sure why I wouldnât want to add this statement.
Will it define a kind of armor object, or do I still have to declare it (e.g., padded robe is a kind of armor), then assign traits to the object I created by its declaration?
There will be multiples of everything in this table, placed at the appropriate location. These tables only assign values to the armor kinds so all subkinds have those traits. For example, all padded robes have a (base) cost of 0.5 and a weight of 3.
C. Yes, I erroneously used âitemâ instead of âarmorâ.
Yes, these are all going to be multiples. Your suggestion of individually declaring the object with every one having the same traits is what I am trying to avoid. (I have done that and for the number of Equipment (Armor, Weapons, Ammo, Outfitting), it works but is unwieldy.
Broken syntax?? What?! The docs already are incomplete for some of the things Iâm trying. If I canât use that syntax, is there something with the same goal I could use?
I think itâs a bug that was introduced by the huge refactor that went into Inform 10. I expect it will be fixed when the next version comes out. In the meantime, your options are to either not use a table (define each kind one by one as usual) or use an older version of the compiler (which you can do in the settings).
For convenience. See the original post. This table replaced PAGES of text for all the items that I have. Individual items (armor, weapons, ammo, equipment) with the same constants are repeated and repeatedâtoo me, bad programming, and inconvenient.
Some armor is defined by the table of body protection
does create a kind of armor defined by that specific armor in the table. I get the following error:
ERROR: You wrote ''A padded robe is a kind of armor, but that seems to say that some room or thing already created (âpadded robeâ, created by 'âSome armor is defined by the table of body protectionâ is now to become a kind.
It seems from this error that Padded Robe will be a kind of padded robe, which is exactly what I want. I removed the individual declaration for padded robe (outside the table), and the error went away.
btw, I am using Inform 1.82 (2014-2022). Not sure how that equates to 10.1.
EDIT: It seems that the table did NOT create the object, at least not in the room that I said it should be. Not sure what that means though. Is the room wrong, or does the object not exist?
Uhh, no, that line creates several objects of kind armor. The error youâre seeing is that you tried to define the same name as both an âobject of kind armorâ and a âkind of armorâ, which are two vastly different things.
I guess I want to go back to why can I assign traits to the magic spells but not to the armor?
Is it because the say, Bless spell is a spell object, and not a kind?
Is there no way then to put kinds into a table? and subsequently assign traits to the kind? Iâm forced into long list of kind declarations?