Scoring based on "handled" property - not working in 7.9.3 (build 6M62)?

I dug up an old Inform7 game I wrote back in 2011 using, I’m guessing, the current version at the time: 7.8.5 (build 6G60).

Now I’m trying to run that game in 7.9.3 (build 6M62). After fixing some syntax issues, I got it to compile and run but am now having issues with scoring based on the “handled” property of an object. Most of the scoring is done when the player takes an object for the first time. So I have a lot of code like this:

After taking the flashlight when the flashlight is not handled: 
	say "Good idea, you might need it.";
	increase the score by 1; 

With the current release of Inform7, the player never gets a point for taking an object (like the flashlight above) for the first time … or ever.

If I change the code to “Before taking” it works, but then if the “take” fails, you still get the point and then can keep getting points by continually trying to take the object and failing. So “after taking” is definitely what I still want.

So why doesn’t this work anymore? Do I need to create a custom property of an object in order to do this now?

From a quick check, it looks like the issue is probably a change in when the “handled” property gets set. (Unfortunately, my copy of 6G60 is hanging up when I try to open the Standard Rules, so I can’t make sure.)

In 6M62, a thing will be set to “handled” as part of the standard taking rule, during the Carry out taking phase. That means that when you check whether it’s handled in the After phase, it’s already been set to handled, even if this was the first time you took it.

It looks like you can fix this by changing “is not handled” to “was not handled”–the “was” checks for whether the condition was true at the start of the turn. See §9.13 of Writing with Inform.

Use scoring.

Lab is a room. A flashlight is in Lab.

After taking the flashlight when the flashlight was not handled: 
	say "Good idea, you might need it.";
	increase the score by 1.

Also this is a bug in the documentation, as §9.2 recommends awarding points in exactly the way you do it. I’ll report it!

2 Likes

Thanks for the quick reply! Switching to “was not handled” seems to work. I’ll have to do some more testing to make sure that doesn’t break some other scoring-related code (like using ‘put’ to move an object directly to a holdall the first time), but at least for now that gets me moving.

Thanks again!

I confirm the 9.2 documentation “bug” (i prefer the ancient term “errata” in the context of non-interactive text…) also because the same thing happened to me (but I used “visited” in my fooling around…)

Best regards from Italy,
dott. Piergiorgio.

Just as a followup, I managed to check and the standard taking rule in 6G60 indeed doesn’t set the “handled” property.

It looks like in 6G60 “handled” didn’t get set during the standard rules, but rather as part of the “note object acquisitions” rule that runs last in the turn sequence and did its work in I6 (where the “handled” property translates as “moved”). This rule also was in charge of seeing if it could find a new player’s holdall when the player had dropped the old one, which seems like something that doesn’t come up much. The rule is still there in 6M62 but I’m not quite up to diving into the I6 templates to see what may or may not have changed.

I’ve run into another handled/scoring issue (sorry to keep pestering you, @matt_weiner!).

My old code gave points when the player picked up a battery for the first time (and there are four batteries in the game):

A battery is a kind of thing. The description of a battery is "A standard D-cell battery."

[ initial battery locations ]
There is a battery in room1.
There is a battery in room2.
There is a battery in room3.
There is a battery in room4.

[ score a point when finding a battery ]
After taking a battery when the battery is not handled:
	increase the score by 1;
	continue the action;

Per my original post (and Matt’s solution), I had to switch to “was not handled”:

After taking a battery when a battery was not handled:

But I also had to switch to “when a battery” instead of “when the battery” otherwise I’d get a compile error (In ‘After taking a battery when the battery was not handled’, I’m not able to understand what specific thing is meant by the phrase ‘the battery’. You use the definite article ‘the’, which suggests you have a particular thing in mind, but then you go on to refer to a kind rather than something definite.).

Anyway, my point here (heh, no pun intended) is that now the player only gets a point when they pick up a battery (any battery) the first time. After that, none of the other three batteries grant points. As this used to work, I’m guessing I’m doing something incorrectly when it comes to multiple instances of an object/kind.

I can replicate the problem with this test code:

Use scoring.

The Void is a room.

A battery is a kind of thing. The description of a battery is "A standard D-cell battery."

After taking a battery when a battery was not handled:
	increase the score by 1;
	continue the action;

There is a battery in The Void.
There is a battery in The Void.
There is a battery in The Void.
There is a battery in The Void.	
[ I've also tried: 'There are four batteries in The Void.' - doesn't seem to matter]

If I take all the batteries at once, it works:

>take batteries
battery: Taken.
battery: Taken.
battery: Taken.
battery: Taken.

[Your score has just gone up by four points.]

But if I take them individually:

>take battery
Taken.

[Your score has just gone up by one point.]

>take battery
Taken.

So I only get a point for the first battery taken. So I’m not sure what’s going on with the handled property for the individual batteries.

The problem is “…when a battery was not handled”. If you want to refer to the specific battery being taken, you need “…when the noun was not handled”.

I’m not sure if you can use “was” with variables like “the noun”; if you can’t, you might have to put this at an earlier stage than After.

1 Like

Ah, okay, thanks for that tip. I switched to this:

Carry out taking a battery:
	if the noun is not handled:
		increase the score by 1;

And that seems to work. From what I can tell reading the documentation (§12.2), “carry out taking” should fire after a successful “check taking” has occurred but before “after” so this way the player doesn’t get a point when the take fails (i.e., they can’t carry any more). And they don’t get points after dropping and re-taking a battery.

Looks good, thank you!

Looks good to me! Score changes are also announced only at the end of the turn, so it doesn’t matter where in the process you award the points (which is really convenient).

2 Likes

Looks like you’ve got this handled, but popping in to confirm that you can’t use “the noun” in a “was” clause.

The way “was” clauses work under the hood is that they compile to some sort of Inform 6 thing that gets checked at the appropriate moment–when you have a unique flashlight and you write “when the battery was handled,” the I7-to-I6 compiler will create a thingy that stores whether the battery is handled, I guess update it at every turn, and during the turn it’s available for checking.

So you can’t use a temp variable like “the noun,” because the compiler won’t know what to what to use in its thingy. If this were taken care of by storing “Is this handled?” for ever thing at the beginning of the turn, it would be possible to do it with temp variables, but that would probably be very memory-hungry.

(I forget how I learned this. As you can tell from the super-technical term “thingy,” I’m not always expert on the internals.)

1 Like