I'm looking to do two things:
1) Printing the kind of an object. So for instance:
[code]
The Underwater Gallery is a room. "Whoozits and whatsits galore adorn
this room."
A whoozit is a kind of thing. A whatsit is a kind of thing.
The fork is a whoozit in the Underwater Gallery. The comb is a whatsit
in the Underwater Gallery. The toothbrush is a whatsit in the
Underwater Gallery.
After printing the name of something:
say " ([the kind of the noun])".
[/code]
Now, that won't compile, but you get the idea. And no, I'm not making
a Little Mermaid game, that's just an example. ;)
2) Can you convert object names to a text token somehow? I7 doesn't
seem to be able to handle any kind of implicit conversion but I'm
hoping that I can somehow access the name of an object and store that
in a different text variable. Yes? No?
Thanks in advance.
Roger wrote:
> 1) Printing the kind of an object. So for instance:
My huge kind-related feature request might make it into Inform 7 one day
:), but in the meantime, let me present to you this code by Mike Tarbert
with some minor addition by me. It does a lot more than you're asking
for here, but that might save you from re-inventing the wheel (I don't
know what you're trying to do).
Kind regards,
Victor
"Kind Variables Test" by Mike Tarbert
Section - New Phrases to Compare
To decide if (X - an object) is identical to (Y - an object):
(- Identical({X},{Y}) -).
To decide if (x - an object) is the same kind as (y - an object):
(- ({x}.i7_kind()=={y}.i7_kind()) -).
Section - New Phrases to Determine / Say
To decide what number is the level (n - a number) parent kind of (x - an
object):
(- kindof ({n},{x}); -).
Include (-
[ kindof n x;
return x.&i7_kind-->n;
]; -).
To decide what number is the kind of (x - an object):
let k be the level 0 parent kind of x;
decide on k.
To decide what number is the parent kind of (x - an object):
let k be the level 1 parent kind of x;
decide on k.
To say kind name of (n - a number):
(- print (I7_Kind_Name) {n}; -)
To say the level (n - a number) parent kind of (x - an object):
(- print (I7_Kind_Name) {x}.&i7_kind-->{n}; -).
To say kind of (x - an object):
say the level 0 parent kind of x.
To say the parent kind of (x - an object):
say the level 1 parent kind of x.
Section - Victor's Additions
The thingummy is a thing.
To say whether (x - an object) is the same general kind as (y - an object):
let d be 0;
let e be the level 0 parent kind of thingummy;
repeat with counter running from 0 to 100:
let a be the level 0 parent kind of x;
let b be the level counter parent kind of y;
if b is e, break;
if a is b, now d is 1;
repeat with counter running from 0 to 100:
let a be the level 0 parent kind of y;
let b be the level counter parent kind of x;
if b is e, break;
if a is b, now d is 2;
if d is 0, say "[The noun] and [the second noun] are not of the same
kind.";
if d is 1, say "[The noun] and [the second noun] are both of the kind
[kind of noun].";
if d is 2, say "[The noun] and [the second noun] are both of the kind
[kind of second noun].".
General comparing is an action applying to two things. Understand
"gcompare [thing] with [thing]" as general comparing.
Carry out general comparing:
say whether the noun is the same general kind as the second noun.
Section - Example
Stored-kind is a number that varies.
Storing is an action applying to one thing. Understand "store [a thing]"
as storing.
Carry out storing:
now Stored-kind is the kind of the noun;
say "Ok, [the noun]'s kind is stored. ([Stored-kind] - [kind name of
stored-kind], kind of [the parent kind of noun]).".
Checking is an action applying to one thing. Understand "check [a
thing]" as checking.
Carry out checking:
let x be the kind of the noun;
if x is the stored-kind, say "Is ";
otherwise say "Not ";
say "a direct kind of [kind name of stored-kind].".
Comparing is an action applying to two things. Understand "compare
[thing] with [thing]" as comparing.
Carry out comparing:
say "Identical to: ";
if the noun is identical to the second noun, say "Yes.";
otherwise say "No.";
say "Same kind as: ";
if the noun is the same kind as the second noun, say "Yes -- ";
otherwise say "No -- ";
say "([kind of noun] and [kind of second noun]).".
The Lab is a room. A coin is a kind of thing. In the lab are three
coins. The can is a thing in the lab. The hat is a wearable thing in the
lab.
A penny is a coin in the lab. A dime is a coin in the lab.
A German coin is a kind of coin.
A pfennig is a German coin in the lab. A mark is a German coin in the lab.
John is a man in the lab.
test compare with "compare coin with coin / compare coin with can /
compare hat with can / compare coin with penny / compare penny with dime
/ compare dime with pfennig / compare pfennig with coin / compare
pfennig with mark / compare hat with mark".
test store with "store coin / check hat / check coin / check penny /
check pfennig / store mark / check penny / check coin / check pfennig".
test all with "test compare / test store".
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkr8JwAACgkQoiOrMwvIZLy5OwCfaxYws9zkWtDo/6HUIMgx+nQs
OcEAn3/mU6kWjVO/RCSK2Edy7Lww7+tB
=33My
-----END PGP SIGNATURE-----
Do you need to? It will always be cheaper to store the object itself,
and then print out its name when desired.
If you do want to do this, the conversion would be:
let T be an indexed text; [create a local variable]
let T be "[obj]"; [set it]
...a little strange, because "let" is being used in two senses. You'd
set an indexed-text property or global the same way.
--Z
--
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
I can see Victor has already answered this, but fwiw, this is what I
came up with:
<code>
The Workshop is a room. The table is a supporter in the workshop. The
toolbox is an open container on the table. In the toolbox is a
spanner. The mechanic is a woman in the workshop.
After printing the name of something: say " ([the kind of the item
described])";
Every turn: say "The kind of the noun was [the kind of the noun]."
Test me with "go north / i / x me".
To say the/-- kind of (item - an object): (- PrintKindOf({item}); -).
Include (-
[ PrintKindOf obj;
if (obj provides IK_0) print (I7_Kind_Name)KindHierarchy-->((obj.IK_0)
*2);
else print "nothing";
]; -).
</code>
Andrew: I was more curious than anything. I guess I could just use the
printed name property, eh?
Printed Name was certainly the first thing that came to my mind.
Also, yay to Victor & whaz-his-email for the nifty code. Victor you
really ought to wrap that up as an extension.
-R
I have it on (ahem) *very* good authority that the I7 kinds mechanism is
being rewritten, presumably for the next release. While I have
absolutely no details, it's my hope that Victor's requests (which he was
kind enough to share with me a while back) will be incorporated in some
manner. :)
In the short - term, packaging up the code upthread as an extension
might turn out to be a waste of time as it will almost certainly not
work with the upcoming release. If Victor's suggestions are implemented,
there will be syntax to do what Roger needs built - into Inform. If not,
it's my plan to update the code as necessary and release that as an
extension. Also, Roger, if you're working on a long - term project, I
would put the code above in a separate, easily identifiable section so
it can be easily edited / excised later.
with fingers crossed and baited breath (whatever that means),
Skinny Mike
The correct spelling is "bated breath." As in "abate," as in "hold back"
or "restrain."
--JA
Actually I hope to be done with this project in less than a week. It's
just a silly little thing but it uses a lot of non-standard stuff so
I've been pushing the envelope of my ever-increasing knowledge of I7
(and I6).
But thank you for the heads up! It's good to know that kinds are being
rewritten. I'm hoping that common properties can apply to different
kinds in this future release (like a "bonus" property that can apply
to multiple kinds - another issue I'm having but have managed to work
around for now).
And again thank you to everyone who provided code, advice, and
information.
> I'm hoping that common properties can apply to different
> kinds in this future release (like a "bonus" property that can apply
> to multiple kinds - another issue I'm having but have managed to work
> around for now).
This is already implemented (in 5Z71 at least; I'm not sure how long ago
it became possible). I'm doing it in my WIP. Maybe you should post the
code that's giving you trouble?
Ah... thanks, Jim -- I thought it had something to do with fish. ;)
SM
Hmm... Well I already edited it out of my code, actually...I'll see if
I re-assemble the issue I was having by tomorrow.
Awesome.
Perhaps the object's name might change.
PHOTOGRAPH THE WHITE CUBE
PAINT THE CUBE BLUE
EXAMINE POLAROID PHOTOGRPAH
should describe a white cube, not a blue one.