Action counter for each floor.

Hi Guys,

Im new to this forum and Inform7.
Im tryn to create my first world , an need some help.

I want to implement a action counter for each action, concrete the counter shall count the actions on each floor separately. I mean if your in floor 1 of two for example , than the counter shall count all actions in floor 1 an save it when you leave to floor.
Is that possible?
I just know that " Every turn: Say “Action-Nr.: [turn count].” " but that counts everythin.

Assuming you’ve already created a “floor” kind of room:

A floor has a number called action count. Every turn: increment the action count of the location.

Variables default to zero, so all floors start with an action count of zero. Every turn the player is in there, the action count goes up by one.

You could also use regions if your floors encompass more than one room.

Thx for your help, but the problem is still there. In my code there are rooms, floors and region, only the Every turn: Say "Action-Nr.: [turn count] works fine, everythin else wount.
Can you write down an exact code that i can copy 1 to 1 an try it out?

So what is a “floor” defined as in your code? If it isn’t a room and it isn’t a region, I’m not sure what it would be.

A Floor is a Room in my code and a Room is also defined as a Room.
For example :

Suedflur is a region: Floor_EG are in Suedflur

The Floor_EG is a Room.
The Raum_1 is a Room. The Raum_252 is west of the Floor_EG
.
.
.

What might really help is to define Floor as a kind of room. Then you can give all the floors a special number, as in Draconis’s code, and also do things like check whether the location (the room the player is in) is a floor.

So something like this:

[code]A floor is a kind of room.
A floor has a number called action count. Every turn: increment the action count of the location.

Every turn when the location is a floor:
increment the action count of the location;
say “Action count: [action count of the location].”

The Floor_EG is a floor. The Raum_252 is west of The Floor_EG.
The Floor_2 is up from The Floor_EG.[/code]

To clarify, since my German is rusty: but by “floor”, you mean die Etage (= vertical division of a building), not der Boden (= thing you stand on) or der Flur (= corridor), right? English, annoyingly, has no word for Etage which isn’t ambiguous in this context (while German has Etage, Geschoss, Stockwerk…it’s rather unfair :stuck_out_tongue: )

Hi :slight_smile:

the floor is in my code like a corridor. A region is like an Etage.

Ahh okay, I understand now. It might reduce confusion to call them “hallways” instead, but as long as a floor is a single room, Matt W’s code should do what you need.

I wount work " *** Run-time problem P10: Since the Raum_252 is not allowed the property “action count”, it is against the rules to try to use it." :question:

Try this (changed the indentation a bit and removed a redundant line - should copy paste better).

[code]

A floor is a kind of room.  A floor has a number called action count.
Every turn when the location is a floor:
    increment the action count of the location;
    say "Action count: [action count of the location]."

[A few rooms to play around with]
The Floor_EG is a floor. The Raum_252 is west of The Floor_EG. 
The Floor_2 is a floor. The Floor_2 is above the Floor_EG.

When paste it, nothing happen when i move.

I try this,
"
A Room has a number called action count.

Every turn when the location is a Room:
increment the action count of the location;
say “Action count: [action count of the location].”

But the problem is when i move west-west-west, the counter still stays on 1, normaly it sould increase up to 3.

Every thing is a Room in on my Map, the givin name is Flur ( floor) or so but all of them are Rooms.

Isn’t this what you want? Try using “wait” for a few turns and watch the counter go up, or go “west” then “east”.

When you go west, then west, then west, you’re in a different room for each action. So each room’s counter only goes up by 1.

Is it that you want the action count to go up for different rooms on the same floor? (Sorry, I don’t know German at all, so if I try to use the German terms I will fail…) That’s a bit trickier but doable. You have to define a floor as a kind of region, give floors an action count, and check whether the player is in a floor so you can increment the action count of the proper floor. Like this:

[code]A floor is a kind of region. A floor has a number called action count.

Floor 1 Hallway is a room. Floor 1 Hallway is north of Room 101. Floor 1 Hallway is south of Room 102.

Floor 2 Hallway is above Floor 1 Hallway. Floor 2 Hallway is north of Room 201. Floor 2 Hallway is south of Room 202.

First Floor is a floor. Floor 1 Hallway is in First Floor. Room 101 is in First Floor. Room 102 is in First Floor.

Second Floor is a floor. Floor 2 Hallway is in Second Floor. Room 201 is in Second Floor. Room 202 is in Second Floor.

Every turn when the player is regionally in a floor (called the current floor) (this is the increment and report the action count rule):
increment the action count of the current floor;
say “Action count: [action count of the current floor].”

Street is outside from Floor 1 Hallway.[/code]

That “(called the current floor)” is a very useful thing. It means that “when the player is regionally in a floor” not only tests whether the player is in a floor to see whether the rule should run, but also stores the floor that the player is in as the temporary variable “the current floor,” which we can use for the rest of the rule.

(IN a test like this, if the player is in more than one floor it picks one more-or-less arbitrarily to be the current floor–but you probably won’t have that happen.)

Also, there’s a subtle thing about why we have to say “regionally in” instead of “in,” which is explained in §6.11 of the documentation. Basically, being “in” a region isn’t the same as being “in” a room or a container; if we say something like “if the player is in First Floor” then Inform knows that we’re looking at a region and automatically interprets that as a region test, but in this case since we didn’t use the name of a specific region we have to explicitly tell Inform to use the region test. That’s what “regionally in” does.

Also, in case you’re wondering where the room declarations are, when you specify the map connections Inform automatically infers that all those things you’re placing are rooms. I didn’t even really have to say “Floor 1 Hallway is a room”!

Thx for the healp

OK, that looks like the effect I was trying to get using regions–hope it helps!

[code]A floor is a kind of region. A floor has a number called action count.

Floor 1 Hallway is a room. Floor 1 Hallway is north of Room 101. Floor 1 Hallway is south of Room 102.

Floor 2 Hallway is above Floor 1 Hallway. Floor 2 Hallway is north of Room 201. Floor 2 Hallway is south of Room 202.

First Floor is a floor. Floor 1 Hallway is in First Floor. Room 101 is in First Floor. Room 102 is in First Floor.

Second Floor is a floor. Floor 2 Hallway is in Second Floor. Room 201 is in Second Floor. Room 202 is in Second Floor.

Every turn when the player is regionally in a floor (called the current floor) (this is the increment and report the action count rule):
increment the action count of the current floor;
say “Action count: [action count of the current floor].”

Street is outside from Floor 1 Hallway.[/code]

It works great, i changed the floor to a region and i start with “A region has a number called action count…”.
Now it perfectly count each action on every “Etage” region very well, and on top it remebers the counter wenn jo go back to a region!!!

THANK YOU GUYS SO MUCH, great job!!!

:slight_smile:

You got an idea for a limitation ? Like 1/30 moves. After 30 moves the game quits?

Before reading a command when the turn count is 31 (this is the time limit rule): say "Egad! You've run out of turns!"; end the game saying "Better luck next time".
We check whether the turn count is 31 because the first turn, before the player has actually done anything, counts as a turn for the turn count.

@chinkeeyong

Works fine :slight_smile: i just changed a lil bit , now everythin is running.

It is possible to write a counter for “things” like a bottle with limited sips? After 7 sips or so the player sould drop the bottle?