Getting the kind of an object

I’d like to know if there’s any way to return or check the kind (or kind of kind) of an object without “knowing beforehand” in code (to easily check “if Sam Clemens is a man” or “if the big cat understood is a tiger.”)

Say I’ve got a flower kind of thing, a rose kind of flower, and a daffodil kind of flower.
Roses and daffodils both have a value called smell, with roses smelling “like summertime” and daffodils smelling like “Aunt Marguerite.”

There are 20 kinds of rose, and 20 kinds of daffodil, as well as 15 other kinds of flower each with their own 20 kinds.

The kind of flower is needed in a function that would basically be using [kind of the flower] as a cross-reference to a value every person has, “favorite flower”.

Without using laborious “if” statements, or doing the (impossible in my particular, non-example case) “Before/Instead/After smelling a rose/daffodil/tyulip” routine, how can I get the kind of the flower in question/understood?

Thanks to you fine gentlemen for all of your help!

Kinds might not be the best way to go about this, but if you really want to, the most straightforward way would probably be something like this.

A flower has some text called species. A flower has some text called genus. The genus of a daffodil is always "Narcissus". [...] The species of a wild daffodil is always "pseudonarcissus". The species of a jonquil is always "jonquilla". The species of a poet's daffodil is always "poeticus".

You don’t need to use scientific names, just make another property that identifies the type of flower.

Another way would be:

[code]Genus is a kind of value. The genuses are narcissus, rosa, and viola.
Species is a kind of value. The specieses [I don’t think Inform understands the irregular plural here] are pseudonarcissus, jonquilla, poeticus, caninae, carolinae, cinnamomeae, sororia, and arvensis.

A flower has a genus. A flower has a species.[/code]

And the third, and probably best, method is:

[code]A scientific name is a kind of value. Some scientific names are defined by the Table of Scientific Names.

Table of Scientific Names
scientific name common name
Narcissus pseudonarcissus “daffodil”
Narcissus jonquilla “daffodil”
Narcissus poeticus “daffodil”
Rosa caninae “rose”
Rosa carolinae “rose”
Rosa cinnamomeae “rose”
Viola sororia “violet”
Viola arvensis “violet”

A flower has a scientific name.

Definition: a flower is a daffodil if the common name of its scientific name is “daffodil”. [And so on.][/code]

So as it turns out I figured that I didn’t need to find the kind of an object, but just use tables instead. (With the code below, I was originally referencing a weapon carried by the player and trying to get its kind) but I’ve hit a snag in the code below;

I’d like to be able to reference a personal variable (X Proficiency of a person) by looking at a weapon they are carrying, but I get the errors of “I don’t know what to do with the Lookup Num column in the Table of Weapon Proficiencies.” It seems to me like this should work, but it doesn’t. Am I just missing something simple?

A person has a number called Bladed Proficiency.
A person has a number called Hafted Proficiency.
A person has a number called Reach Proficiency.

A weapon is a kind of thing.
Some kinds of weapon are defined by the Table of Weapon Kinds.

Table of Weapon Kinds
Name		Associated Prof
Sword		Bladed
Mace		Hafted
Spear		Reach

Weapon Prof is a kind of thing.
Some weapon profs are defined by the Table of Weapon Proficiencies.

Table of Weapon Proficiencies
Name		Lookup Num
Bladed		Bladed Proficiency
Hafted		Hafted Proficiency
Reach		Reach Proficiency

Broken Straight Sword is a kind of sword.
The Arena is a room. The player is in the Arena. The player carries a Broken Straight Sword.

When play begins: [just for proof-of-concept testing]
	repeat with weap running through weapons held by the player:
		let weapprop be the associated prof of weap;
		let profnum be the lookup num corresponding to a name of weapprop in the Table of Weapon Proficiencies;
		let finalnum be the profnum of the player;
		say "[Weap]: [weapprop] is [finalnum]."

Part of the problem is you aren’t actually defining anything, only kinds of things. Remember, you can’t carry a kind of a sword. Here’s a quick rework of your code that compiles in 6G60.

[code]“The Arena”

A person has a number called the Bladed Proficiency. The Bladed Proficiency of the player is 1.
A person has a number called the Hafted Proficiency. The Hafted Proficiency of the player is 1.
A person has a number called the Reach Proficiency. The Reach Proficiency of the player is 1.

A weapon is a kind of thing. A weapon can be bladed, hafted, or reach.

A sword is a kind of weapon. A sword is always bladed.
A mace is a kind of weapon. A mace is always hafted.
A spear is a kind of weapon. A spear is always reach.

A Broken Straight Sword is a sword. The description is “You should see the other guy’s weapon.”

Report examining a weapon (called W):
say "[the printed name of W]: ";
if W is bladed, say “Your bladed proficiency is [bladed proficiency of the player].”;
if W is hafted, say “Your hafted proficiency is [hafted proficiency of the player].”;
if W is reach, say “Your reach proficiency is [reach proficiency of the player].”.

The Arena is a room. The player carries the broken straight sword.

test me with “x sword”.[/code]

I’m a little confused on this point-- I’ve been able to have people carry kinds of kinds before, because I want more than one “Broken Straight Sword” to exist in the world, and check/return/fiddle with those items without a problem. That’s what I was trying to do in my original post was get the “kind” of Broken Straight Sword and the associated proficiency from that so I could grab the correct value from the player, in this fashion:

A person has a number called the Bladed Weapons Proficiency. The Bladed Weapons Proficiency of the player is usually 50.
Associated proficiency is a kind of thing.
A weapon is a kind of thing. A weapon has an associated proficiency.
Sword is a kind of weapon. The associated proficiency of sword is Bladed Weapons Proficiency.
Broken Straight Sword is a kind of sword.
The player is carrying a Broken Straight Sword.

The Arena is a room.
The player is in the Arena.
Skeleton is a person in the Arena. Skeleton is carrying a Broken Straight Sword.

After attacking someone:
    let currweap be a random weapon carried by the player;
    let assocprof be the associated proficiency of currweap;
    say "The proficiency we shall use (because you are carrying a [currweap]) is [assocprof], and you have a score of [assocprof of the player]."
 

But this throws errors at trying to figure out what the associated proficiency of a sword is.

But if I can’t, in fact, do that without creating a definite Broken Straight Sword object, how can I create multiples of it to exist in the game world?

There are three broken straight swords in the Arena.

Right, but I’m still getting an error of

Problem. You wrote 'The player carries a broken straight sword' , but also 'Skeleton carries a broken straight sword' : that seems to be saying that the same object (Broken Straight Sword) must be in two different places (yourself and Skeleton). This looks like a contradiction.

When I try to run this (based off of your code):

[code]
“The Arena”

A person has a number called the Bladed Proficiency. The Bladed Proficiency of the player is 10.
A person has a number called the Hafted Proficiency. The Hafted Proficiency of the player is 10.
A person has a number called the Reach Proficiency. The Reach Proficiency of the player is 10.

A weapon is a kind of thing. A weapon can be bladed, hafted, or reach.

A sword is a kind of weapon. A sword is always bladed.
A mace is a kind of weapon. A mace is always hafted.
A spear is a kind of weapon. A spear is always reach.

A Broken Straight Sword is a sword. The description is “You should see the other guy’s weapon.”

The current relevant proficiency score is a number that varies.

To get the relevant proficiency of (attacker - a person):
let weap be a random weapon carried by attacker;
if weap is bladed, now the current relevant proficiency score is bladed proficiency of attacker;
if weap is hafted, now the current relevant proficiency score is hafted proficiency of attacker;
if weap is reach, now the current relevant proficiency score is reach proficiency of attacker;

Instead of attacking someone:
get the relevant proficiency of the player;
let weap be a random weapon carried by the player;
say “You strike at the enemy with [weap], with a base chance to hit of [the current relevant proficiency score]!”.

The Arena is a room. The player carries a broken straight sword.
Skeleton is a person in the Arena. Skeleton carries a broken straight sword.

test me with “x sword”.[/code]

You need to create a kind and then some instances of that kind. (buster is wrong here; your original code did both, and that wasn’t the problem.) The following is fine:

[code]A broken straight sword is a kind of thing.

The player carries a broken straight sword.[/code]

Doh, I was wrong! I like how Inform is smart enough to know you are carrying an instance of the kind simply by saying you are carrying the name of the kind, without having to define the instance first.

The relevant section of the manual on duplicates.

I was wondering about that; previously I’d had no problems with assigning kinds to inventories.

But regardless, with you guys’ help I’ve got code that works just the way I need it to, so thank you all very much!

"The Arena"

A person has a number called the Bladed Proficiency. The Bladed Proficiency of the player is 10.
A person has a number called the Hafted Proficiency. The Hafted Proficiency of the player is 15.
A person has a number called the Reach Proficiency. The Reach Proficiency of the player is 20.

A weapon is a kind of thing. A weapon can be bladed, hafted, or reach.

A sword is a kind of weapon. A sword is always bladed.
A mace is a kind of weapon. A mace is always hafted.
A spear is a kind of weapon. A spear is always reach.

A Broken Straight Sword is a kind of sword.
An Iron-headed Shortspear is a kind of spear.
A Cudgel is a kind of mace.

The current relevant proficiency score is a number that varies.

To get the relevant proficiency of (attacker - a person) using (weap - a thing):
	if weap is bladed, now the current relevant proficiency score is bladed proficiency of attacker;
	if weap is hafted, now the current relevant proficiency score is hafted proficiency of attacker;
	if weap is reach, now the current relevant proficiency score is reach proficiency of attacker;
	
Instead of attacking someone:
	let weap be a random weapon carried by the player;
	get the relevant proficiency of the player using weap;
	say "You strike at the enemy with [weap], with a base chance to hit of [the current relevant proficiency score]!".

The Arena is a room.  The player carries a broken straight sword. The player  carries an iron-headed shortspear. The player carries a cudgel.
Skeleton is a person in the Arena. Skeleton carries a broken straight sword.