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.)
Room study “Your study”
with description “There is a doorway to the east of this austere room.”,
Object bob “you” study
with name ‘bob’ ‘me’,
description “You’re lookin’ good.”
Object uniform “uniform” bob
description “Your uniform is freshly pressed.”,
has transparent clothing
Object pocket “pocket”
description “Handy, isn’t it?”,
Take: “That seems to be part of the uniform.”;
has container open
Object glasses “glasses” pocket
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.
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.
Object player_uniform "janitor's uniform"
with name 'my' 'mine' 'uniform' 'jumpsuit' 'gray' 'grey',
"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.",
"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,
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',
"It's a little vinyl nametag sewn onto your uniform, reading ~PARK~.",
UniComp front_pocket "front pocket"
with name 'front' 'pocket',
has container open transparent;
Object reading_glasses "pair of reading glasses" front_pocket
with name 'my' 'black' 'reading' 'glasses' 'specs',
"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.
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.