More trouble with naming

[code]Your footlocker is a container in the touring cabin. It is closed, openable, lockable and locked. Your footlocker key unlocks your footlocker. Understand “my footlocker” as your footlocker.

Your footlocker key is carried. Understand “my footlocker key” as your footlocker key.
[/code]

Trying to “unlock my footlocker” gives this

unlock my footlocker
(with your footlocker key)
That doesn’t seem to be something you can unlock.

unlock my footlocker with my footlocker key
That doesn’t seem to be something you can unlock.

I’m sorry if I’m acting a little n00by here. This is my first stab at this with Inform7. At this rate, you guys will see the whole game before I put it out there!

Thanks for your feedback!!

~~ CP ~~

Examine this test I made with that code and you’ll see the core of the problem:

Welcome
An Interactive Fiction
Release 1 / Serial number 091209 / Inform 7 build 5Z71 (I6/v6.31 lib 6/12N) SD

Touring Cabin
You can see your footlocker (closed) here.

>i
You are carrying:
  your footlocker key

>unlock footlocker
(your footlocker key with your footlocker key)                  <--------- problem is here
That doesn't seem to be something you can unlock.

The way the code is written the game isn’t distinguishing properly between the footlocker and the footlocker key, because the game only reads the first 9 characters of a phrase to distinguish objects, and in your case the first nine characters are identical. See 3.1 of the documentation.

A simple fix is like this:

Touring Cabin is a room.

Your footlocker is a container in the touring cabin.  It is closed, openable, lockable and locked. Your locker key unlocks your footlocker.  Understand "my footlocker" as your footlocker.

Your locker key is carried.  Understand "my locker key" as your locker key.

Which gives the output:


Welcome
An Interactive Fiction
Release 1 / Serial number 091209 / Inform 7 build 5Z71 (I6/v6.31 lib 6/12N) SD

Touring Cabin
You can see your footlocker (closed) here.

>unlock footlocker with my locker key
You unlock your footlocker.

Excellent! Thanks!

Let me ask a question. Is there any way to extend the nine character limit?

Also, this is explanation and example actually in section 17.31 Activities in the documentation; I see, however, that the example is from section 3. Thanks again for the fix!

I’m not sure if your last post meant you found an answer to the question:

If not, you can set your project to compile to glulx and use the variable “Use DICT_WORD_SIZE of [xx]” to change the maximum length of understood words. For example:

Use DICT_WORD_SIZE of 17

should probably take care most items the character would likely interact with; if not you could just increase the number to whatever length needed.

Thanks a bunch! I had not actually found that fix in the code.

Is it detrimental to a game to post questions on this forum? I’m a programmer by day, and I don’t want to spoil everything for the whole community by posting my questions here, but you guys are a GREAT resource!!

Thanks again!

~~ CP ~~

I’d say just ask away until you get all the help you need, and if you don’t understand any particular answer don’t hesitate to ask for clarification. Without at all meaning to single out anything that goes on here at this forum, I’d say that in every sort of noncommercial gaming community many people unnecessarily limit themselves by, for whatever reason, being reluctant to ask questions.

If I had what I thought was a cool idea for a game that I was intending to release at some point, I’d phrase the question for myself in the following way:

Is it better to never finish my game because there are technical issues I can’t understand, rather than ask for help when I need it?

Agreed, we’re all here to discuss and learn about IF CP, so ask away.

Actually, the 9 character limit isn’t the problem here. That limit means 9 characters per word. “Footlocker key” is two words. Inform can’t distinguish “footlockezzzzz key” from “footlocker key”, but it can distinguish “footlocker crowbar” from “footlocker key”.

The problem is that Inform’s parser will normally accept any combination of words in an object’s name, and doesn’t really care if you leave some words out. So “footlocker” matches the footlocker and the key equally well. George’s solution works because it takes the word “footlocker” out of the key’s name.

Another solution would be to specify the key’s name in a way that prevents the word “footlocker” from matching by itself. The trick here is (1) make the object privately-named so Inform doesn’t understand its name by default, then (2) use understand lines to add “footlocker key” back as a phrase, which Inform won’t break apart and match as separate words: Your footlocker key is carried. It is privately-named. Understand "key" or "footlocker key" or "your/my key" or "your/my footlocker key" as your footlocker key.

A third solution in some situations is to leave the name as-is and use “does the player mean” rules to eliminate nonsensical actions:Does the player mean unlocking your footlocker with the second noun: it is likely. Does the player mean unlocking your footlocker key with the second noun: it is unlikely. Does the player mean unlocking something with your footlocker: it is unlikely.
However, that doesn’t work well in this particular case, because of the word “my”. Inform sometimes (not sure exactly when) takes that to mean “the one I’m carrying”, and in this case the only object matching “footlocker” that you’re carrying is the key.

Thanks for the explanation vw, that makes more sense.

Gosh, that sure sounds familiar. :blush:

I know you’ve gotten some good responses to this question, but I’d add one more thing. You could call your variable asdfkjls if you wanted to and still have it print and respond to the word “footlocker key”. I ran into this problem and solution when I had a bunch of similarly named variables all pertaining to airplane parts.

The locker key is a key. Understand "footlocker key" as the locker key. The printed name of the locker key is "footlocker key".

I wouldn’t actually call the variable asdfkjls, by the way, just in case inform does some unexpected reporting of some kind, like “Which do you mean, the skeleton key or the asdfkjls?” I actually don’t think that particular one would happen, but I recall it happening somewhere and surprising me. So give it an inoffensive synonym.

If you make it privately-named, that shouldn’t be a problem.

To stop that from happening, you could change its printed name. Or, as a last resort, write something like “Rule for printing the name of the asdfkjls when asking which do you mean: say ‘something goes here’.”