Pocket issues [now with even more issues]

So I have a uniform that the player wears, which has a pocket, which has a pair of glasses in it. Should the player attempt to take the pocket, a standard “that seems to be part of the uniform” is printed, which is fine. But should the player attempt to take the glasses, the same message is printed. Am I missing something here? The DM4 doesn’t mention anything about such an issue.

By the way, I’m writing in Inform 6.

EDIT: New problem - The glasses now cause the game to crash - see below.

The solution is a teensy bit tricky, but not hard to implement. Don’t make the pocket part of the uniform. Instead, use add_to_scope in the uniform object to add the pocket to scope, and then have the pocket itself reject (in a before routine) any attempt to detach it from the uniform.

Here’s an example. Note that I’ve used ChangePlayer(bob) in Initialise in order to have a real player object in my code. (I’ve also defined a Room class.)

[code]
Room study “Your study”
with description “There is a doorway to the east of this austere room.”,
e_to hallway;

Object bob “you” study
with name ‘bob’ ‘me’,
description “You’re lookin’ good.”
;

Object uniform “uniform” bob
with
name ‘uniform’,
description “Your uniform is freshly pressed.”,
add_to_scope pocket,
has transparent clothing
;

Object pocket “pocket”
with
name ‘pocket’,
description “Handy, isn’t it?”,
before [;
Take: “That seems to be part of the uniform.”;
],
has container open
;

Object glasses “glasses” pocket
with
name ‘glasses’,
description “Spectacular.”,
has clothing
;[/code]

This is just for testing purposes. It’s defective in many ways, such as reporting “a glasses” and “an uniform” in the output. But hopefully it will get you pointed in the right direction.

Dude, you’re a lifesaver. Thanks!

Ooh, okay, ran into another bug. Maybe it’s not related entirely to this, but I feel it is.

Whenever the game has to list the glasses as the contents of something (i.e, looking in the pocket, taking inventory with the glasses in the player’s hand, etc.), the interpreter crashes, with the message “Call to non-routine”.

Umm, any solutions for this? No clue what’s causing it.

You’ll need to post your code for the glasses. When I run my test game, it works fine:

Object  player_uniform "janitor's uniform"
  with  name 'my' 'mine' 'uniform' 'jumpsuit' 'gray' 'grey',
	article "your",
	description
	"Your trusty janitor's uniform. It's a dull slate-gray jumpsuit that zips up in the front, with a front pocket and two back pockets, and a 
	nametag sewn onto the left breast.",
	before [;
	  Disrobe:
	    "Company policy says you can't take off your uniform until your shift's over. Common sense says you shouldn't take off your uniform
	    in a concrete building with faulty heating in the middle of winter.";
	],
	add_to_scope front_pocket player_nametag,
   has  clothing;

Class   UniComp		! Uniform Component
  with  before [;
	  Take, Remove: print "Bad idea. You rip it off the uniform, you buy it (the uniform, not just "; print (the) self; print ").^"; return true;
	];

UniComp player_nametag "nametag"
  with  name 'my' 'mine' 'name' 'tag' 'nametag' 'vinyl',
	article "your",
	description
	"It's a little vinyl nametag sewn onto your uniform, reading ~PARK~.",
   has  ;

UniComp front_pocket "front pocket"
  with  name 'front' 'pocket',
	capacity 1,
   has  container open transparent;

Object  reading_glasses "pair of reading glasses" front_pocket
  with  name 'my' 'black' 'reading' 'glasses' 'specs',
	article 'your',
	description
	"It's the same trusty pair of black reading glasses you've had for quite some time now.",
   has  clothing pluralname;

The problem is the same whether or not I use ChangePlayer. At first I thought that something related to scope was conflicting with my personalized InvSub replacement, but that turned out not to be the case either.

A simple error, but not easy to catch: In the reading_glasses object, you defined:

article 'your',

when you wanted:

article "your",

When I fixed that, the inventory and look-in code ran as expected.

Ah, thank you! I was completely stumped by why that particular object was causing trouble but nothing else was. Jeez, I need to stop coding so early in the morning or something. Anyway, thanks for catching that for me, Jim.