Checking value in every object carried? [SOLVED]

Hi there!

First things first: I’m new both to the forum and to writing IF. I’ve stumbled upon Inform7 and absolutelly loved it from the very beggining.

Now for the “help me please” part: I’m in the process of writing my first IF work, a short game that I’m using mainly to learn how to work with the language.

I’ve been having some issues, but the tons of documentation (examples, how-tos, etc) have been helping me. But now I’m stuck.

The situation:
I want the player to have four hooks with him that have a tension value. Through the game, events will result in the tension value going up or down. In every turn, I want the game to check what is the tension in each of the four hooks. If that tension reaches zero, the hook falls off and the remaining cables pull the player to the center again.

[code][----- things -----]

A hook is a kind of thing.
Understand “cable” as hook.
Hooks have a number called tension. The tension of a hook is usually 3.

[----- the different hooks -----]

The bronze hook is carried by the player. The bronze hook is a hook. The description is “Lets see… [if the tension of the noun is 5]The hook helds you tight in place[otherwise If the tension of the noun is 4]The hook gives you a firm, hardly bearable, pull[otherwise if the tension of the noun is 1]The hook hardly pulls you[otherwise]The hook pulls you gently[end if].”

[----- check the hooks tension -----]

Every turn:
if the tension of the bronze hook is 0:
say “The bronze hook detaches itself from you and you loose the only mean to find the bronze room. You’re back in the center room”;
remove the bronze hook from play;
move the player to the center room.

[----- rooms and things in rooms -----]

The center room is a room. “Just a center room.”
The bronze room is north from the center room. “Just a bronze room.”

The bronze lever is in the bronze room.
Instead of pushing the bronze lever:
decrease the tension of the bronze hook by 1;
if the tension in the bronze hook is not 0, say “You feel the tension in the bronze hook diminish.”

[/code]

I’ve managed to create a code that checks the tension in one hook. I could just copy+paste that code and change the bronze hook to the copper hook, etc, but I think it’s a clumbsy way to do it. Is there an alternative?

Thanks!

The most generally applicable way to do this is with a loop:

Repeat with item running through hooks carried by the player: if the tension of the item is 0: remove the item from play; [etc.]

–Erik

It worked and it taught me something new.

Thanks!