Bug - Cannot take Portable object off of Supporter

I am trying to fix a bug in The Time Machine that someone discovered.

There is a pocket watch that you can pick up and later in the game one of the NPCs tells you to put it on a desk. After you put it on the desk, when you try and pick up the watch you get a “That’s hardly portable.” message.

I created a small example with the same elements to test in isolation.

The player is in the Entryway.

The Entryway is a room. 

The pocket watch is a thing.
The pocket watch is in the Entryway.
The pocket watch is portable.

The Library is a room. 
The Library is west of the Entryway. 
The description of the Library is "There is a desk here."

The desk is a thing.
The desk is scenery in the Library.
The desk is a supporter.
The description of the desk is "A small standing desk."

The Parlor is a room. 
The Parlor is north of the Library.

When run this code allows you to pick up the watch, put it on the desk in the library, and pick it up a second time.

Entryway
You can see a pocket watch here.

>take watch
Taken.

>w

Library
There is a desk here.

>put watch on desk
You put the pocket watch on the desk.

>take watch
Taken.

In the actual game, when you perform the same actions listed above you get the “That’s hardly portable.” message when trying to take the watch from the desk in the library.

With >action turned on in the actual game here is what is displayed when you perform the actions listed in the example (some interim steps are removed for clarity).

>take watch
[taking the pocket watch]
Taken.
[taking the pocket watch - succeeded]

>put watch on desk
[putting the pocket watch on the desk]
You put the pocket watch on the desk.
[putting the pocket watch on the desk - succeeded]

>take watch
[taking the pocket watch]
That's hardly portable.
[taking the pocket watch - failed]

A >showme of the watch and desk in the actual game returns this.

>showme watch
pocket watch - thing
location: on the desk in the Library
singular-named, improper-named; unlit, inedible, portable, handled
list grouping key: none
printed name: "pocket watch"
printed plural name: none
indefinite article: none
description: "A simple pocket watch."
initial appearance: none

>showme desk
desk - supporter
    pocket watch
    papers
location: in the Library
singular-named, improper-named; unlit, inedible, fixed in place, scenery; list grouping key: none
printed name: "desk"
printed plural name: "supporters"
indefinite article: none
description: "A small standing desk."
initial appearance: none
carrying capacity: 100

There must be some side effect introduced in the source code but I have not been able to discover anything yet. This is my first Inform 7 game so while I continue debugging this I thought I would post here to see if anyone else has ever run into a situation like this before.

I’m developing on a Mac using Inform v1.68.1 (6M62). The only extensions I’m using besides the ones included by default are:

Include Basic Help Menu by Emily Short.
Include Punctuation Removal by Emily Short.

If anyone needs additional information please let me know.

2 Likes

Have you tried attempting to grab the watch with RULES turned on? There must be some other rule intercepting the action but without seeing all your code it’s hard to guess what that might be (RULES, if you haven’t used it before, is a testing command that shows each rule as it fires. So whatever rule is running before you get the “can’t take that” error is likely the culprit).

@DeusIrae Thanks Mike. Forgot about RULES. Let me check and report back.

1 Like

Ah, just saw you linked to your source code – here’s the culprit!

Instead of taking something in the Library:
	if the noun provides the property type:
		if the type of the noun is reference:
			choose a random row from Table of Encyclopaedia Volumes; 
			say "You take the volume labeled '[Label entry]' and leaf through the pages from '[Start-Word entry]' to '[End-Word entry]' until you get bored and place the volume back on the shelf.";
		else if the type of the noun is magazine:
			choose a random row from Table of Periodicals;
			say "You take a copy of '[Name entry]' off the shelf and leaf through [Note entry] before placing it back with the other issues.";
		else if the type of the noun is hardcover:
			choose a random row from Table of Books;
			say "You take a copy of '[Name entry]' off the shelf and leaf through a few pages before placing it back on the shelf.";
		otherwise:
		 	say "READING [the type of the noun].";
	otherwise:
		say "That's hardly portable.".

Looks like this rule is to cleanly handle players mucking about with the reading material in the library, but your final Otherwise is too broad – dropping the watch (or anything else) anywhere in the library, not just on the desk, will mean you can’t take it again. So you just either need to change the header so the rule applies more narrowly, or add in a “continue the action” after the big reading section of the rule to revert to typical behavior (or you could rewrite this as a Before rule… lots of choices!)

EDIT: just noticed this was posted in Technical Development rather than Authoring, so I moved it over – the former is more for development of non-game stuff like interpreters, compilers, etc. So you might get more eyes on a post like this, about finding a bug in your game code, if you put it in Authoring!

3 Likes

@DeusIrae I comparing my test and the game with RULES enabled and found this.

[Rule "Instead of taking something in the Library" applies.]
That's hardly portable.

That’s the side effect I was looking for (don’t know why I didn’t see it before). Tripped up by my own cleverness, I guess.

Thanks again Mike. For reminding me of RULES, the second set of eyes on the source, and for correcting my post categorization.

3 Likes

As @DeusIrae pointed out, it was my overly generous otherwise: statement in the Instead of taking something in the Library: rule that was causing the issue. Buried in the Library | Reading section, which is why I didn’t notice it right way, I probably would have spent many more hours searching for a solution if not for the >rules command (thanks again Mike).

Replacing the “say ‘That’s hardly portable.’” with “continue the action.” solved the problem.

Instead of taking something in the Library:
	if the noun provides the property type:
		if the type of the noun is reference:
			choose a random row from Table of Encyclopaedia Volumes; 
			say "You take the volume labeled '[Label entry]' and leaf through the pages from '[Start-Word entry]' to '[End-Word entry]' until you get bored and place the volume back on the shelf.";
		else if the type of the noun is magazine:
			choose a random row from Table of Periodicals;
			say "You take a copy of '[Name entry]' off the shelf and leaf through [Note entry] before placing it back with the other issues.";
		else if the type of the noun is hardcover:
			choose a random row from Table of Books;
			say "You take a copy of '[Name entry]' off the shelf and leaf through a few pages before placing it back on the shelf.";
		otherwise:
		 	say "READING [the type of the noun].";
	otherwise:
		[say "That's hardly portable.".]
		continue the action.
1 Like