Problem with counting actions and if statements

Hi,

I am struggling here. The problem is pretty simple. Every 3d, 5th, 8th or 10th turn you should smell something. You can also type smell, and then it wouldn’t be needed for the 10th. This is what I have so far, and is working as I want it to be:

[code]Every turn during Preparing Clubnight:
if you are smelly:
if Smellcounter is less than four:
if Preparing Clubnight has been happening for exactly three turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly five turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly eight turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly ten turns:
try smelling;

Smellcounter is a number variable. Smellcounter is 0.

Instead of smelling during Preparing Clubnight:
if you are smelly:
increase Smellcounter by one;
say “[one of]Sniff, sniff. You notice a bad smell…[or]Sniff. The smell you noticed, seems to be coming from you…[or]Sniff. Yes, most definitely. You are the one where this smell is coming from.[or]Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.[stopping]”;
[/code]

The thing is though, that I am positive that this should be possible in a much easier way, without for instance the ugly “smellcounter” variable. http://inform7.com/learn/man/doc155.html gives examples of it, but I haven’t been able to use the “if smelling for less than four times”. It compiles, but doesn’t work as it should. Any idea how to fix this? Using stuff like “if the player has smelled” or “if the player smelled” or “if the player has been smelling” gives compiler errors.

I don’t know if counters are necessarily ugly, but this particular one, the smellcounter, as it is applied in your sample code, seems to make no difference.

This works just as well without the smellcounter:

[code]The Place is a room.

Preparing Clubnight is a scene. Preparing Clubnight begins when play begins.
A person can be smelly. The player is smelly.

Every turn during Preparing Clubnight:
if the player is smelly:
if Preparing Clubnight has been happening for exactly three turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly five turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly eight turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly ten turns:
try smelling;

Instead of smelling during Preparing Clubnight:
if the player is smelly:
say “[one of]Sniff, sniff. You notice a bad smell…[or]Sniff. The smell you noticed, seems to be coming from you…[or]Sniff. Yes, most definitely. You are the one where this smell is coming from.[or]Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.[stopping]”;
[/code]

Hi, thank you for your answer. Your version of the code was what I had before I added the counter, and does not do the same as with the counter. The difference is, that without counter, you get extra automatic generated “Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.” messages at the end, since you cycle through the smell messages when the player types “smell” himself.

If the player does nothing and just waits 10 turns, the effect is identical.

If the player types “smell”, the message is cycled, and the automatically generated smell message with the “otherwise if Preparing Clubnight has been happening for exactly ten turns:” will have the same “Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.”. In an extreme case: if the player types smell four times in a row, the automatic messages on the exactly after five, exactly after eight, exactly after ten, will all give the same “Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.” I want to avoid that. The four different smell messages are all the information the player needs. Either by typing smell himself a couple of times, and/or, with the automatically generated smell messages. But I want no duplicates of the last message.

So what I was looking for, and maybe this doesn’t exist but I can’t believe that so far, is a way of checking the amount of “smell” commands has given. I tried all kinds of variations of “if the player has smelled 5 times” or something, but they all failed.

Oh, I totally missed that.

If you like, you can prevent that result by adding a condition to the every turn rule to exempt turns when the player is already taking a smelling course of action:

[code]The Place is a room.

Preparing Clubnight is a scene. Preparing Clubnight begins when play begins.
A person can be smelly. The player is smelly.

Every turn when we are not smelling during Preparing Clubnight:
if the player is smelly:
if Preparing Clubnight has been happening for exactly three turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly five turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly eight turns:
try smelling;
otherwise if Preparing Clubnight has been happening for exactly ten turns:
try smelling;

Instead of smelling during Preparing Clubnight:
If the player is smelly:
say “[one of]Sniff, sniff. You notice a bad smell…[or]Sniff. The smell you noticed, seems to be coming from you…[or]Sniff. Yes, most definitely. You are the one where this smell is coming from.[or]Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.[stopping]”;[/code]

Hi, thanks again for your answer. I didn’t know about the “when the player is not smelling” that’s neat. But it still does not solve the extra last messages, if the player did some smelling of his own at the start. This results in output like this:

[code]Welcome
An Interactive Fiction
Release 1 / Serial number 130901 / Inform 7 build 6G60 (I6/v6.32 lib 6/12N) SD

Place

smell
Sniff, sniff. You notice a bad smell…

smell
Sniff. The smell you noticed, seems to be coming from you…

l
Place

l
Place
Sniff. Yes, most definitely. You are the one where this smell is coming from.

l
Place

l
Place
Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.

l
Place

l
Place

l
Place
Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.

l
Place

l
Place
Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.
[/code]
Those last two “Sniff, sniff. You check it out thoroughly and find out that it is a sweaty smell coming from your armpits.” are not needed. So I used a smellcounter to count the times a smell message has been displayed. But I hoped that there could be some kind of referring to the amount of smelled commands before. Like “if the player has been here three times” which is usable with locations. So I tried “if the player has smelled three times” or stuff like that. But for an action I have not been able to succesfully incorporate the amount of times the player has performed that action. Maybe I’m using the wrong syntax, maybe it just isn’t possible. I was hoping that some of you might know how to make that work, instead of using a seperate counter.

The syntax is “if we have smelled three times: …”

However, this runs into a quirk of the action sequence, which is that the smelling action normally fails – the messages that report the result are technically failure messages – and so Inform never considers “we have smelled” to be true. So your counter is the simplest working solution.

Thanks for your answer!